浏览代码

Restore stub

bghgary 5 年之前
父节点
当前提交
054ef35133
共有 1 个文件被更改,包括 4 次插入2 次删除
  1. 4 2
      tests/unit/babylon/src/Loading/babylon.sceneLoader.tests.ts

+ 4 - 2
tests/unit/babylon/src/Loading/babylon.sceneLoader.tests.ts

@@ -414,14 +414,14 @@ describe('Babylon Scene Loader', function() {
 
             const setRequestHeaderCalls = new Array<string>();
             const origSetRequestHeader = BABYLON.WebRequest.prototype.setRequestHeader;
-            sinon.stub(BABYLON.WebRequest.prototype, "setRequestHeader").callsFake(function(...args) {
+            const setRequestHeaderStub = sinon.stub(BABYLON.WebRequest.prototype, "setRequestHeader").callsFake(function(...args) {
                 setRequestHeaderCalls.push(args.join(": "));
                 origSetRequestHeader.apply(this, args);
             });
 
             // Simulate default CORS policy on some web servers that reject getResponseHeader calls with `Content-Range`.
             const origGetResponseHeader = BABYLON.WebRequest.prototype.getResponseHeader;
-            sinon.stub(BABYLON.WebRequest.prototype, "getResponseHeader").callsFake(function(...args) {
+            const getResponseHeaderStub = sinon.stub(BABYLON.WebRequest.prototype, "getResponseHeader").callsFake(function(...args) {
                 return (args[0] === "Content-Range") ? null : origGetResponseHeader.apply(this, args);
             });
 
@@ -432,6 +432,8 @@ describe('Babylon Scene Loader', function() {
 
             promises.push(BABYLON.SceneLoader.AppendAsync("/Playground/scenes/", "LevelOfDetail.glb", scene).then(() => {
                 expect(setRequestHeaderCalls, "setRequestHeaderCalls").to.have.ordered.members(expectedSetRequestHeaderCalls);
+                setRequestHeaderStub.restore();
+                getResponseHeaderStub.restore();
             }));
 
             return Promise.all(promises);