Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Fix linter errors in react-error-overlay tests
  • Loading branch information
nickserv committed Apr 23, 2020
commit 3679e2ff89d102a22b221cc41ba4bb52cd3cce4e
13 changes: 3 additions & 10 deletions packages/react-error-overlay/src/__tests__/extract-source-map.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,8 @@ test('extracts last source map directive', async () => {
});

test('errors when no source map', async () => {
expect.assertions(1);

const testFileName = 'test.js';
try {
await extractSourceMapUrl(
testFileName,
`console.log('hi')\n\nconsole.log('bye')`
);
} catch (e) {
expect(e).toBe(`Cannot find a source map directive for ${testFileName}.`);
}
await expect(
extractSourceMapUrl(testFileName, `console.log('hi')\n\nconsole.log('bye')`)
).rejects.toBe(`Cannot find a source map directive for ${testFileName}.`);
});
13 changes: 3 additions & 10 deletions packages/react-error-overlay/src/__tests__/get-source-map.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,10 @@ test('find an inline source map', async () => {
});

test('error on a source map with unsupported encoding', async () => {
expect.assertions(2);

const file = fs
.readFileSync(resolve(__dirname, '../../fixtures/junk-inline.mjs'))
.toString('utf8');
try {
await getSourceMap('/', file);
} catch (e) {
expect(e instanceof Error).toBe(true);
expect(e.message).toBe(
'Sorry, non-base64 inline source-map encoding is not supported.'
);
}
await expect(getSourceMap('/', file)).rejects.toThrow(
new Error('Sorry, non-base64 inline source-map encoding is not supported.')
);
});
22 changes: 6 additions & 16 deletions packages/react-error-overlay/src/__tests__/parser/generic.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,13 @@
import { parse } from '../../utils/parser';

test('throws on null', () => {
expect.assertions(2);
try {
parse(null);
} catch (e) {
expect(e instanceof Error).toBe(true);
expect(e.message).toBe('You cannot pass a null object.');
}
expect(() => parse(null)).toThrow(
new Error('You cannot pass a null object.')
);
});

test('throws on unparsable', () => {
expect.assertions(2);
try {
parse({});
} catch (e) {
expect(e instanceof Error).toBe(true);
expect(e.message).toBe(
'The error you provided does not contain a stack trace.'
);
}
expect(() => parse({})).toThrow(
new Error('The error you provided does not contain a stack trace.')
);
});