Skip to content

Commit 6ce7490

Browse files
committed
chore(tests): Update tests to use better matchers
1 parent 647e8d2 commit 6ce7490

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

src/components/__tests__/Tabs-test.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ describe('<Tabs />', () => {
196196
console.error = oldConsoleError; // eslint-disable-line no-console
197197

198198
const result = Tabs.propTypes.children(wrapper.props(), 'children', 'Tabs');
199-
expect(result instanceof Error).toBe(true);
199+
expect(result).toBeInstanceOf(Error);
200200
});
201201

202202
test('should result with warning when tab outside of tablist', () => {
@@ -215,7 +215,7 @@ describe('<Tabs />', () => {
215215
console.error = oldConsoleError; // eslint-disable-line no-console
216216

217217
const result = Tabs.propTypes.children(wrapper.props(), 'children', 'Tabs');
218-
expect(result instanceof Error).toBe(true);
218+
expect(result).toBeInstanceOf(Error);
219219
});
220220

221221
test('should result with warning when multiple tablist components exist', () => {
@@ -236,15 +236,15 @@ describe('<Tabs />', () => {
236236
console.error = oldConsoleError; // eslint-disable-line no-console
237237

238238
const result = Tabs.propTypes.children(wrapper.props(), 'children', 'Tabs');
239-
expect(result instanceof Error).toBe(true);
239+
expect(result).toBeInstanceOf(Error);
240240
});
241241

242242
test('should result with warning when onSelect missing when selectedIndex set', () => {
243243
const oldConsoleError = console.error; // eslint-disable-line no-console
244-
const catchedErrors = [];
244+
let catchedError;
245245
// eslint-disable-next-line no-console
246246
console.error = error => {
247-
catchedErrors.push(error);
247+
catchedError = error;
248248
};
249249
shallow(
250250
<Tabs selectedIndex={1}>
@@ -258,15 +258,15 @@ describe('<Tabs />', () => {
258258

259259
const expectedMessage =
260260
'The prop `onSelect` is marked as required in `Tabs`, but its value is `undefined` or `null`.';
261-
expect(catchedErrors.some(msg => msg.indexOf(expectedMessage) > -1)).toBe(true);
261+
expect(catchedError).toMatch(expectedMessage);
262262
});
263263

264264
test('should result with warning when defaultIndex and selectedIndex set', () => {
265265
const oldConsoleError = console.error; // eslint-disable-line no-console
266-
const catchedErrors = [];
266+
let catchedError;
267267
// eslint-disable-next-line no-console
268268
console.error = error => {
269-
catchedErrors.push(error);
269+
catchedError = error;
270270
};
271271
shallow(
272272
<Tabs selectedIndex={1} defaultIndex={1}>
@@ -280,7 +280,7 @@ describe('<Tabs />', () => {
280280

281281
const expectedMessage =
282282
'The prop `selectedIndex` cannot be used together with `defaultIndex` in `Tabs`.';
283-
expect(catchedErrors.some(msg => msg.indexOf(expectedMessage) > -1)).toBe(true);
283+
expect(catchedError).toMatch(expectedMessage);
284284
});
285285

286286
test('should result with warning when tabs/panels are imbalanced and it should ignore non tab children', () => {
@@ -300,7 +300,7 @@ describe('<Tabs />', () => {
300300
console.error = oldConsoleError; // eslint-disable-line no-console
301301

302302
const result = Tabs.propTypes.children(wrapper.props(), 'children', 'Tabs');
303-
expect(result instanceof Error).toBe(true);
303+
expect(result).toBeInstanceOf(Error);
304304
});
305305

306306
test('should allow random order for elements', () => {

0 commit comments

Comments
 (0)