Skip to content

Commit d74f72f

Browse files
committed
test(external-value): test ExternalValueError
1 parent 174802e commit d74f72f

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

test/specmap/external-value.js

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import xmock from 'xmock';
2+
3+
import mapSpec, { plugins } from '../../src/specmap';
4+
5+
const { externalValue } = plugins;
6+
7+
describe('externalValue', () => {
8+
let xapp;
9+
10+
beforeAll(() => {
11+
xapp = xmock();
12+
});
13+
14+
afterAll(() => {
15+
xapp.restore();
16+
});
17+
18+
beforeEach(() => {
19+
externalValue.clearCache()
20+
});
21+
22+
describe('ExternalValueError', () => {
23+
test('should contain the externalValue error details', () => {
24+
try {
25+
throw new externalValue.ExternalValueError('Probe', {
26+
externalValue: 'http://test.com/probe',
27+
fullPath: "probe",
28+
});
29+
} catch (e) {
30+
expect(e.toString()).toEqual('ExternalValueError: Probe');
31+
expect(e.externalValue).toEqual('http://test.com/probe');
32+
expect(e.fullPath).toEqual("probe");
33+
}
34+
});
35+
test('.wrapError should wrap an error in ExternalValueError', () => {
36+
try {
37+
throw externalValue.wrapError(new Error('hi'), {
38+
externalValue: 'http://test.com/probe',
39+
fullPath: "probe",
40+
});
41+
} catch (e) {
42+
expect(e.message).toMatch(/externalValue/);
43+
expect(e.message).toMatch(/hi/);
44+
expect(e.externalValue).toEqual('http://test.com/probe');
45+
expect(e.fullPath).toEqual("probe");
46+
}
47+
});
48+
});
49+
50+
});

0 commit comments

Comments
 (0)