Skip to content

Commit

Permalink
Merge pull request #7807 from AnalyticalGraphicsInc/testCleanup
Browse files Browse the repository at this point in the history
Test code cleanup.
  • Loading branch information
mramato authored May 3, 2019
2 parents f84594a + ea90bf9 commit 284b70b
Show file tree
Hide file tree
Showing 22 changed files with 108 additions and 94 deletions.
3 changes: 1 addition & 2 deletions Specs/Core/CesiumTerrainProviderSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,7 @@ defineSuite([
return pollToPromise(function() {
return provider.ready;
}).then(function() {
var tilingScheme = provider.tilingScheme;
expect(tilingScheme instanceof GeographicTilingScheme).toBe(true);
expect(provider.tilingScheme).toBeInstanceOf(GeographicTilingScheme);
});
});

Expand Down
12 changes: 6 additions & 6 deletions Specs/Core/ColorSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,17 +103,17 @@ defineSuite([

it('clone with no parameters returns a new identical copy.', function() {
var v = new Color(0.1, 0.2, 0.3, 0.4);
var v2 = v.clone();
expect(v).toEqual(v2);
expect(v === v2).toEqual(false);
var clone = v.clone();
expect(clone).toEqual(v);
expect(clone).not.toBe(v);
});

it('clone with a parameter modifies the parameter.', function() {
var v = new Color(0.1, 0.2, 0.3, 0.4);
var v2 = new Color();
var v3 = v.clone(v2);
expect(v).toEqual(v2);
expect(v3 === v2).toEqual(true);
var clone = v.clone(v2);
expect(clone).toEqual(v2);
expect(clone).toBe(v2);
});

it('equals works', function() {
Expand Down
4 changes: 2 additions & 2 deletions Specs/Core/EllipsoidSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ defineSuite([
};

var cloned = Ellipsoid.clone(myEllipsoid);
expect(cloned instanceof Ellipsoid).toBe(true);
expect(cloned).toBeInstanceOf(Ellipsoid);
expect(cloned).toEqual(myEllipsoid);
});

Expand Down Expand Up @@ -460,7 +460,7 @@ defineSuite([
var cartographic = Cartographic.fromDegrees(35.23,33.23);
var cartesianOnTheSurface = ellipsoid.cartographicToCartesian(cartographic);
var returnedResult = ellipsoid.getSurfaceNormalIntersectionWithZAxis(cartesianOnTheSurface);
expect(returnedResult instanceof Cartesian3).toBe(true);
expect(returnedResult).toBeInstanceOf(Cartesian3);
});

it('getSurfaceNormalIntersectionWithZAxis works with a result parameter', function() {
Expand Down
3 changes: 1 addition & 2 deletions Specs/Core/GoogleEarthEnterpriseTerrainProviderSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,7 @@ defineSuite([
return pollToPromise(function() {
return terrainProvider.ready;
}).then(function() {
var tilingScheme = terrainProvider.tilingScheme;
expect(tilingScheme instanceof GeographicTilingScheme).toBe(true);
expect(terrainProvider.tilingScheme).toBeInstanceOf(GeographicTilingScheme);
});
});

Expand Down
20 changes: 10 additions & 10 deletions Specs/Core/GroundPolylineGeometrySpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,16 +112,16 @@ defineSuite([

// Expect rightNormalAndTextureCoordinateNormalizationY and texcoordNormalization2D.y to encode if the vertex is on the bottom
values = rightNormalAndTextureCoordinateNormalizationY.values;
expect(values[3] > 1.0).toBe(true);
expect(values[1 * 4 + 3] > 1.0).toBe(true);
expect(values[4 * 4 + 3] > 1.0).toBe(true);
expect(values[5 * 4 + 3] > 1.0).toBe(true);
expect(values[3]).toBeGreaterThan(1.0);
expect(values[1 * 4 + 3]).toBeGreaterThan(1.0);
expect(values[4 * 4 + 3]).toBeGreaterThan(1.0);
expect(values[5 * 4 + 3]).toBeGreaterThan(1.0);

values = texcoordNormalization2D.values;
expect(values[1] > 1.0).toBe(true);
expect(values[1 * 2 + 1] > 1.0).toBe(true);
expect(values[4 * 2 + 1] > 1.0).toBe(true);
expect(values[5 * 2 + 1] > 1.0).toBe(true);
expect(values[1]).toBeGreaterThan(1.0);
expect(values[1 * 2 + 1]).toBeGreaterThan(1.0);
expect(values[4 * 2 + 1]).toBeGreaterThan(1.0);
expect(values[5 * 2 + 1]).toBeGreaterThan(1.0);

// Line segment geometry is encoded as:
// - start position
Expand Down Expand Up @@ -635,8 +635,8 @@ defineSuite([
var boundingSphere = geometry.boundingSphere;
var pointsDistance = Cartesian3.distance(positions[0], positions[1]);

expect(boundingSphere.radius > pointsDistance).toBe(true);
expect(boundingSphere.radius > 1000.0).toBe(true); // starting top/bottom height
expect(boundingSphere.radius).toBeGreaterThan(pointsDistance);
expect(boundingSphere.radius).toBeGreaterThan(1000.0); // starting top/bottom height
});

var packedInstance = [positions.length];
Expand Down
2 changes: 1 addition & 1 deletion Specs/Core/HeapSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ defineSuite([
pass = pass && checkHeap(heap, comparator);
}
expect(pass).toBe(true);
expect(heap.length <= heap.maximumLength).toBe(true);
expect(heap.length).toBeLessThanOrEqualTo(heap.maximumLength);
// allowed one extra slot for swapping
expect(heap.internalArray.length).toBeLessThanOrEqualTo(heap.maximumLength + 1);
});
Expand Down
14 changes: 7 additions & 7 deletions Specs/Core/ResourceSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1228,7 +1228,7 @@ defineSuite([
}).then(function(loadedImage) {
expect(loadedImage.width).toEqual(1);
expect(loadedImage.height).toEqual(1);
expect(loadedImage instanceof ImageBitmap);
expect(loadedImage).toBeInstanceOf(ImageBitmap);
});
});

Expand Down Expand Up @@ -1766,7 +1766,7 @@ defineSuite([
}).then(function() {
fail('expected promise to reject');
}).otherwise(function(err) {
expect(err instanceof RequestErrorEvent).toBe(true);
expect(err).toBeInstanceOf(RequestErrorEvent);
});
});

Expand All @@ -1778,7 +1778,7 @@ defineSuite([
fail('expected promise to reject');
}).otherwise(function(err) {
expect(err).toBeDefined();
expect(err instanceof Error).toBe(true);
expect(err).toBeInstanceOf(Error);
});
});
});
Expand Down Expand Up @@ -1865,7 +1865,7 @@ defineSuite([

fakeXHR.simulateError();
expect(resolvedValue).toBeUndefined();
expect(rejectedError instanceof RequestErrorEvent).toBe(true);
expect(rejectedError).toBeInstanceOf(RequestErrorEvent);
});

it('results in an HTTP status code less than 200', function() {
Expand All @@ -1888,7 +1888,7 @@ defineSuite([

fakeXHR.simulateHttpResponse(199);
expect(resolvedValue).toBeUndefined();
expect(rejectedError instanceof RequestErrorEvent).toBe(true);
expect(rejectedError).toBeInstanceOf(RequestErrorEvent);
});

it('resolves undefined for status code 204', function() {
Expand Down Expand Up @@ -2061,7 +2061,7 @@ defineSuite([

fakeXHR.simulateError(); // This fails because we only retry once
expect(resolvedValue).toBeUndefined();
expect(rejectedError instanceof RequestErrorEvent).toBe(true);
expect(rejectedError).toBeInstanceOf(RequestErrorEvent);
});

it('rejects after callback returns false', function() {
Expand Down Expand Up @@ -2090,7 +2090,7 @@ defineSuite([

fakeXHR.simulateError(); // This fails because the callback returns false
expect(resolvedValue).toBeUndefined();
expect(rejectedError instanceof RequestErrorEvent).toBe(true);
expect(rejectedError).toBeInstanceOf(RequestErrorEvent);

expect(cb.calls.count()).toEqual(1);
var receivedResource = cb.calls.argsFor(0)[0];
Expand Down
37 changes: 19 additions & 18 deletions Specs/Core/SphericalSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,22 +50,23 @@ defineSuite([

it('Cloning with no result parameter returns a new instance.', function() {
var v = new Spherical(1, 2, 3);
var w = v.clone();
expect(v === w).toEqual(false);
expect(v).toEqual(w);
var clone = v.clone();
expect(clone).not.toBe(v);
expect(clone).toBeInstanceOf(Spherical);
expect(clone).toEqual(v);
});

it('Cloning with result modifies existing instance and returns it.', function() {
var v = new Spherical(1, 2, 3);
var w = new NotSpherical();
expect(NotSpherical.areEqual(v, w)).toEqual(false);
var q = v.clone(w);
expect(v === w).toEqual(false);
expect(q === w).toEqual(true);
var clone = v.clone(w);
expect(clone).not.toBe(v);
expect(clone).toBe(w);
expect(NotSpherical.areEqual(v, w)).toEqual(true);
});

it('Normalizing with no result parameter creates new instance and sets magntitude to 1.0', function() {
it('Normalizing with no result parameter creates new instance and sets magnitude to 1.0', function() {
var v = new Spherical(0, 2, 3);
var w = Spherical.normalize(v);
expect(w).not.toEqual(v);
Expand All @@ -74,24 +75,24 @@ defineSuite([
expect(w.magnitude).toEqual(1);
});

it('Normalizing with result parameter modifies instance and sets magntitude to 1.0', function() {
it('Normalizing with result parameter modifies instance and sets magnitude to 1.0', function() {
var v = new Spherical(0, 2, 3);
var w = new NotSpherical();
var q = Spherical.normalize(v, w);
expect(w).not.toEqual(v);
expect(w === q).toEqual(true);
expect(w.clock).toEqual(0);
expect(w.cone).toEqual(2);
expect(w.magnitude).toEqual(1);
expect(q).not.toEqual(v);
expect(q).toBe(w);
expect(q.clock).toEqual(0);
expect(q.cone).toEqual(2);
expect(q.magnitude).toEqual(1);
});

it('Normalizing with this as result parameter modifies instance and sets magntitude to 1.0', function() {
it('Normalizing with this as result parameter modifies instance and sets magnitude to 1.0', function() {
var v = new Spherical(0, 2, 3);
var q = Spherical.normalize(v, v);
expect(v === q).toEqual(true);
expect(v.clock).toEqual(0);
expect(v.cone).toEqual(2);
expect(v.magnitude).toEqual(1);
expect(q).toBe(v);
expect(q.clock).toEqual(0);
expect(q.cone).toEqual(2);
expect(q.magnitude).toEqual(1);
});

it('equalsEpsilon returns true for expected values.', function() {
Expand Down
8 changes: 4 additions & 4 deletions Specs/Core/VRTheWorldTerrainProviderSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -256,10 +256,10 @@ defineSuite([
return pollToPromise(function() {
return terrainProvider.ready;
}).then(function() {
expect(terrainProvider.tilingScheme instanceof GeographicTilingScheme).toBe(true);
return terrainProvider.requestTileGeometry(0, 0, 0).then(function(loadedData) {
expect(loadedData).toBeInstanceOf(HeightmapTerrainData);
});
expect(terrainProvider.tilingScheme).toBeInstanceOf(GeographicTilingScheme);
return terrainProvider.requestTileGeometry(0, 0, 0);
}).then(function(loadedData) {
expect(loadedData).toBeInstanceOf(HeightmapTerrainData);
});
});

Expand Down
2 changes: 1 addition & 1 deletion Specs/Core/VertexFormatSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ defineSuite([
normal : true
});
var cloned = VertexFormat.clone(vertexFormat);
expect(cloned instanceof VertexFormat).toBe(true);
expect(cloned).toBeInstanceOf(VertexFormat);
expect(cloned).toEqual(vertexFormat);
});

Expand Down
4 changes: 2 additions & 2 deletions Specs/Core/loadCRNSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ defineSuite([

fakeXHR.simulateError();
expect(resolvedValue).toBeUndefined();
expect(rejectedError instanceof RequestErrorEvent).toBe(true);
expect(rejectedError).toBeInstanceOf(RequestErrorEvent);
expect(rejectedError.statusCode).toBeUndefined();
expect(rejectedError.response).toBeUndefined();
});
Expand All @@ -118,7 +118,7 @@ defineSuite([
var error = 'some error';
fakeXHR.simulateHttpResponse(404, error);
expect(resolvedValue).toBeUndefined();
expect(rejectedError instanceof RequestErrorEvent).toBe(true);
expect(rejectedError).toBeInstanceOf(RequestErrorEvent);
expect(rejectedError.statusCode).toEqual(404);
expect(rejectedError.response).toEqual(error);
});
Expand Down
20 changes: 10 additions & 10 deletions Specs/Core/loadKTXSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ defineSuite([

fakeXHR.simulateError();
expect(resolvedValue).toBeUndefined();
expect(rejectedError instanceof RequestErrorEvent).toBe(true);
expect(rejectedError).toBeInstanceOf(RequestErrorEvent);
expect(rejectedError.statusCode).toBeUndefined();
expect(rejectedError.response).toBeUndefined();
});
Expand All @@ -104,7 +104,7 @@ defineSuite([
var error = 'some error';
fakeXHR.simulateHttpResponse(404, error);
expect(resolvedValue).toBeUndefined();
expect(rejectedError instanceof RequestErrorEvent).toBe(true);
expect(rejectedError).toBeInstanceOf(RequestErrorEvent);
expect(rejectedError.statusCode).toEqual(404);
expect(rejectedError.response).toEqual(error);
});
Expand Down Expand Up @@ -259,7 +259,7 @@ defineSuite([
});

expect(resolvedValue).toBeUndefined();
expect(rejectedError instanceof RuntimeError).toEqual(true);
expect(rejectedError).toBeInstanceOf(RuntimeError);
expect(rejectedError.message).toEqual('Invalid KTX file.');
});

Expand All @@ -279,7 +279,7 @@ defineSuite([
});

expect(resolvedValue).toBeUndefined();
expect(rejectedError instanceof RuntimeError).toEqual(true);
expect(rejectedError).toBeInstanceOf(RuntimeError);
expect(rejectedError.message).toEqual('File is the wrong endianness.');
});

Expand All @@ -299,7 +299,7 @@ defineSuite([
});

expect(resolvedValue).toBeUndefined();
expect(rejectedError instanceof RuntimeError).toEqual(true);
expect(rejectedError).toBeInstanceOf(RuntimeError);
expect(rejectedError.message).toEqual('glInternalFormat is not a valid format.');
});

Expand All @@ -319,7 +319,7 @@ defineSuite([
});

expect(resolvedValue).toBeUndefined();
expect(rejectedError instanceof RuntimeError).toEqual(true);
expect(rejectedError).toBeInstanceOf(RuntimeError);
expect(rejectedError.message).toEqual('glType must be zero when the texture is compressed.');
});

Expand All @@ -339,7 +339,7 @@ defineSuite([
});

expect(resolvedValue).toBeUndefined();
expect(rejectedError instanceof RuntimeError).toEqual(true);
expect(rejectedError).toBeInstanceOf(RuntimeError);
expect(rejectedError.message).toEqual('The type size for compressed textures must be 1.');
});

Expand All @@ -359,7 +359,7 @@ defineSuite([
});

expect(resolvedValue).toBeUndefined();
expect(rejectedError instanceof RuntimeError).toEqual(true);
expect(rejectedError).toBeInstanceOf(RuntimeError);
expect(rejectedError.message).toEqual('The base internal format must be the same as the format for uncompressed textures.');
});

Expand All @@ -379,7 +379,7 @@ defineSuite([
});

expect(resolvedValue).toBeUndefined();
expect(rejectedError instanceof RuntimeError).toEqual(true);
expect(rejectedError).toBeInstanceOf(RuntimeError);
expect(rejectedError.message).toEqual('3D textures are unsupported.');
});

Expand All @@ -399,7 +399,7 @@ defineSuite([
});

expect(resolvedValue).toBeUndefined();
expect(rejectedError instanceof RuntimeError).toEqual(true);
expect(rejectedError).toBeInstanceOf(RuntimeError);
expect(rejectedError.message).toEqual('Texture arrays are unsupported.');
});

Expand Down
Loading

0 comments on commit 284b70b

Please sign in to comment.