From 2e3b0debbc976160032f9fe8d4c0d0be2ccc30dd Mon Sep 17 00:00:00 2001 From: Robert Taglang Date: Wed, 4 Jan 2017 15:32:24 -0500 Subject: [PATCH 1/2] Mock deprecation warning function to fix failing test --- Source/Scene/Batched3DModel3DTileContent.js | 5 ++++- .../Scene/Batched3DModel3DTileContentSpec.js | 19 ++++++++++++++----- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/Source/Scene/Batched3DModel3DTileContent.js b/Source/Scene/Batched3DModel3DTileContent.js index 678e4050b48d..d51112ba0ed6 100644 --- a/Source/Scene/Batched3DModel3DTileContent.js +++ b/Source/Scene/Batched3DModel3DTileContent.js @@ -72,6 +72,9 @@ define([ this._features = undefined; } + // This can be overridden for testing purposes + Batched3DModel3DTileContent._deprecationWarning = deprecationWarning; + defineProperties(Batched3DModel3DTileContent.prototype, { /** * Part of the {@link Cesium3DTileContent} interface. @@ -183,7 +186,7 @@ define([ if (!defined(batchIdAttributeName)) { batchIdAttributeName = getAttributeOrUniformBySemantic(gltf, 'BATCHID'); if (defined(batchIdAttributeName)) { - deprecationWarning('b3dm-legacy-batchid', 'The glTF in this b3dm uses the semantic `BATCHID`. Application-specific semantics should be prefixed with an underscore: `_BATCHID`.'); + Batched3DModel3DTileContent._deprecationWarning('b3dm-legacy-batchid', 'The glTF in this b3dm uses the semantic `BATCHID`. Application-specific semantics should be prefixed with an underscore: `_BATCHID`.'); } } return batchIdAttributeName; diff --git a/Specs/Scene/Batched3DModel3DTileContentSpec.js b/Specs/Scene/Batched3DModel3DTileContentSpec.js index 182e05286be5..f1efc8846aa6 100644 --- a/Specs/Scene/Batched3DModel3DTileContentSpec.js +++ b/Specs/Scene/Batched3DModel3DTileContentSpec.js @@ -103,11 +103,20 @@ defineSuite([ }); it('logs deprecation warning for use of BATCHID without prefixed underscore', function() { - var deprecationWarningSpy = jasmine.createSpy(deprecationWarning); - return Cesium3DTilesTester.loadTileset(scene, withBatchTableUrl).then(function(tileset) { - expect(deprecationWarningSpy).toHaveBeenCalled(); - Cesium3DTilesTester.expectRenderTileset(scene, tileset); - }); + var called = false; + var originalDeprecationWarning = Batched3DModel3DTileContent._deprecationWarning; + Batched3DModel3DTileContent._deprecationWarning = function() { + called = true; + }; + return Cesium3DTilesTester.loadTileset(scene, withBatchTableUrl) + .then(function(tileset) { + expect(called).toEqual(true); + Cesium3DTilesTester.expectRenderTileset(scene, tileset); + Batched3DModel3DTileContent._deprecationWarning = originalDeprecationWarning; + }) + .otherwise(function() { + Batched3DModel3DTileContent._deprecationWarning = originalDeprecationWarning; + }); }); it('throws with empty gltf', function() { From a69beb5f7ab6dff915cc53c821a6d771483882ae Mon Sep 17 00:00:00 2001 From: Robert Taglang Date: Wed, 4 Jan 2017 16:09:43 -0500 Subject: [PATCH 2/2] Use spyOn --- Specs/Scene/Batched3DModel3DTileContentSpec.js | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/Specs/Scene/Batched3DModel3DTileContentSpec.js b/Specs/Scene/Batched3DModel3DTileContentSpec.js index f1efc8846aa6..255fd33acbb9 100644 --- a/Specs/Scene/Batched3DModel3DTileContentSpec.js +++ b/Specs/Scene/Batched3DModel3DTileContentSpec.js @@ -103,19 +103,11 @@ defineSuite([ }); it('logs deprecation warning for use of BATCHID without prefixed underscore', function() { - var called = false; - var originalDeprecationWarning = Batched3DModel3DTileContent._deprecationWarning; - Batched3DModel3DTileContent._deprecationWarning = function() { - called = true; - }; + spyOn(Batched3DModel3DTileContent, '_deprecationWarning'); return Cesium3DTilesTester.loadTileset(scene, withBatchTableUrl) .then(function(tileset) { - expect(called).toEqual(true); + expect(Batched3DModel3DTileContent._deprecationWarning).toHaveBeenCalled(); Cesium3DTilesTester.expectRenderTileset(scene, tileset); - Batched3DModel3DTileContent._deprecationWarning = originalDeprecationWarning; - }) - .otherwise(function() { - Batched3DModel3DTileContent._deprecationWarning = originalDeprecationWarning; }); });