Skip to content

Commit 6bc6bf0

Browse files
improve assertions (#1401)
1 parent 040ad3c commit 6bc6bf0

File tree

5 files changed

+12
-12
lines changed

5 files changed

+12
-12
lines changed

src/expression/types/color_array.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,6 @@ describe('ColorArray', () => {
4343

4444
expect(() => {
4545
ColorArray.interpolate(colorArray, targetColorArray, 0.5);
46-
}).toThrow('colorArray: Arrays have mismatched length (2 vs. 1), cannot interpolate.');
46+
}).toThrowError('colorArray: Arrays have mismatched length (2 vs. 1), cannot interpolate.');
4747
});
4848
});

src/expression/types/variable_anchor_offset_collection.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,12 @@ describe('VariableAnchorOffsetCollection', () => {
3939
test('should throw with mismatched endpoints', () => {
4040
expect(() =>
4141
i11nFn(parseFn(['top', [0, 0]]), parseFn(['bottom', [1, 1]]), 0.5)
42-
).toThrow(
42+
).toThrowError(
4343
'Cannot interpolate values containing mismatched anchors. from[0]: top, to[0]: bottom'
4444
);
4545
expect(() =>
4646
i11nFn(parseFn(['top', [0, 0]]), parseFn(['top', [1, 1], 'bottom', [2, 2]]), 0.5)
47-
).toThrow(
47+
).toThrowError(
4848
'Cannot interpolate values of different length. from: ["top",[0,0]], to: ["top",[1,1],"bottom",[2,2]]'
4949
);
5050
});

src/feature_filter/feature_filter.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,15 +88,15 @@ describe('filter', () => {
8888
test('expression, type error', () => {
8989
expect(() => {
9090
featureFilter(['==', ['number', ['get', 'x']], ['string', ['get', 'y']]]);
91-
}).toThrow();
91+
}).toThrowError(': Cannot compare types \'number\' and \'string\'.');
9292

9393
expect(() => {
9494
featureFilter(['number', ['get', 'x']]);
95-
}).toThrow();
95+
}).toThrowError(": Expected boolean but found number instead.");
9696

9797
expect(() => {
9898
featureFilter(['boolean', ['get', 'x']]);
99-
}).not.toThrow();
99+
}).not.toThrowError();
100100
});
101101

102102
test('expression, within', () => {

src/function/index.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ describe('exponential function', () => {
284284
type: 'color'
285285
}
286286
);
287-
}).toThrow('Unknown color space: "invalid"');
287+
}).toThrowError('Unknown color space: "invalid"');
288288
});
289289

290290
test('exponential interpolation of colorArray', () => {
@@ -367,7 +367,7 @@ describe('exponential function', () => {
367367
type: 'colorArray'
368368
}
369369
);
370-
}).toThrow('Unknown color space: "invalid"');
370+
}).toThrowError('Unknown color space: "invalid"');
371371
});
372372

373373
test('exponential interpolation of numberArray', () => {
@@ -1536,7 +1536,7 @@ test('unknown function', () => {
15361536
type: 'string'
15371537
}
15381538
)
1539-
).toThrow(/Unknown function type "nonesuch"/);
1539+
).toThrowError(/Unknown function type "nonesuch"/);
15401540
});
15411541

15421542
describe('kind', () => {

src/migrate.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ describe('migrate', () => {
99
test('does not migrate from version 5', () => {
1010
expect(() => {
1111
migrate({version: 5, layers: []} as any);
12-
}).toThrow(new Error('Cannot migrate from 5'));
12+
}).toThrowError('Cannot migrate from 5');
1313
});
1414

1515
test('does not migrate from version 6', () => {
1616
expect(() => {
1717
migrate({version: 6, layers: []} as any);
18-
}).toThrow(new Error('Cannot migrate from 6'));
18+
}).toThrowError('Cannot migrate from 6');
1919
});
2020

2121
test('migrates to latest version from version 7', () => {
@@ -181,7 +181,7 @@ describe('migrate', () => {
181181
]
182182
};
183183

184-
expect(() => migrate(style)).not.toThrow();
184+
expect(() => migrate(style)).not.toThrowError();
185185
expect(style.layers[0].paint).toEqual({
186186
'icon-color': 'hsl(100,30%,20%)',
187187
'icon-opacity-transition': {duration: 0}

0 commit comments

Comments
 (0)