Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test code cleanup. #7807

Merged
merged 1 commit into from
May 3, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions Specs/Core/CesiumTerrainProviderSpec.js
Original file line number Diff line number Diff line change
@@ -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);
});
});

12 changes: 6 additions & 6 deletions Specs/Core/ColorSpec.js
Original file line number Diff line number Diff line change
@@ -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() {
4 changes: 2 additions & 2 deletions Specs/Core/EllipsoidSpec.js
Original file line number Diff line number Diff line change
@@ -411,7 +411,7 @@ defineSuite([
};

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

@@ -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() {
3 changes: 1 addition & 2 deletions Specs/Core/GoogleEarthEnterpriseTerrainProviderSpec.js
Original file line number Diff line number Diff line change
@@ -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);
});
});

20 changes: 10 additions & 10 deletions Specs/Core/GroundPolylineGeometrySpec.js
Original file line number Diff line number Diff line change
@@ -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
@@ -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];
2 changes: 1 addition & 1 deletion Specs/Core/HeapSpec.js
Original file line number Diff line number Diff line change
@@ -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);
});
14 changes: 7 additions & 7 deletions Specs/Core/ResourceSpec.js
Original file line number Diff line number Diff line change
@@ -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);
});
});

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

@@ -1757,7 +1757,7 @@ defineSuite([
fail('expected promise to reject');
}).otherwise(function(err) {
expect(err).toBeDefined();
expect(err instanceof Error).toBe(true);
expect(err).toBeInstanceOf(Error);
});
});
});
@@ -1844,7 +1844,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() {
@@ -1867,7 +1867,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() {
@@ -2040,7 +2040,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() {
@@ -2069,7 +2069,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];
37 changes: 19 additions & 18 deletions Specs/Core/SphericalSpec.js
Original file line number Diff line number Diff line change
@@ -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);
@@ -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() {
8 changes: 4 additions & 4 deletions Specs/Core/VRTheWorldTerrainProviderSpec.js
Original file line number Diff line number Diff line change
@@ -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);
});
});

2 changes: 1 addition & 1 deletion Specs/Core/VertexFormatSpec.js
Original file line number Diff line number Diff line change
@@ -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);
});

4 changes: 2 additions & 2 deletions Specs/Core/loadCRNSpec.js
Original file line number Diff line number Diff line change
@@ -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();
});
@@ -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);
});
20 changes: 10 additions & 10 deletions Specs/Core/loadKTXSpec.js
Original file line number Diff line number Diff line change
@@ -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();
});
@@ -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);
});
@@ -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.');
});

@@ -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.');
});

@@ -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.');
});

@@ -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.');
});

@@ -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.');
});

@@ -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.');
});

@@ -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.');
});

@@ -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.');
});

Loading