Skip to content

Commit d4f0de1

Browse files
committed
test(external-value): value should skip resolution
1 parent 89e68c5 commit d4f0de1

File tree

1 file changed

+37
-6
lines changed

1 file changed

+37
-6
lines changed

test/specmap/external-value.js

+37-6
Original file line numberDiff line numberDiff line change
@@ -16,35 +16,66 @@ describe('externalValue', () => {
1616
});
1717

1818
beforeEach(() => {
19-
externalValue.clearCache()
19+
externalValue.clearCache();
2020
});
2121

2222
describe('ExternalValueError', () => {
2323
test('should contain the externalValue error details', () => {
2424
try {
2525
throw new externalValue.ExternalValueError('Probe', {
2626
externalValue: 'http://test.com/probe',
27-
fullPath: "probe",
27+
fullPath: 'probe',
2828
});
2929
} catch (e) {
3030
expect(e.toString()).toEqual('ExternalValueError: Probe');
3131
expect(e.externalValue).toEqual('http://test.com/probe');
32-
expect(e.fullPath).toEqual("probe");
32+
expect(e.fullPath).toEqual('probe');
3333
}
3434
});
3535
test('.wrapError should wrap an error in ExternalValueError', () => {
3636
try {
3737
throw externalValue.wrapError(new Error('hi'), {
3838
externalValue: 'http://test.com/probe',
39-
fullPath: "probe",
39+
fullPath: 'probe',
4040
});
4141
} catch (e) {
4242
expect(e.message).toMatch(/externalValue/);
4343
expect(e.message).toMatch(/hi/);
4444
expect(e.externalValue).toEqual('http://test.com/probe');
45-
expect(e.fullPath).toEqual("probe");
45+
expect(e.fullPath).toEqual('probe');
4646
}
4747
});
4848
});
4949

50-
});
50+
describe('externalValue Plugin value collision', () => {
51+
const spec = {
52+
paths: {
53+
'/probe': {
54+
get: {
55+
responses: {
56+
200: {
57+
content: {
58+
'*/*': {
59+
examples: {
60+
probe: {
61+
externalValue: 'http://test.com/probe',
62+
value: 'test'
63+
},
64+
},
65+
},
66+
},
67+
},
68+
},
69+
},
70+
},
71+
},
72+
};
73+
test('should skip resolution of externalValue if value is defined', () =>
74+
mapSpec({
75+
spec,
76+
plugins: [externalValue],
77+
}).then((res) => {
78+
expect(res.spec).toEqual(spec);
79+
}));
80+
});
81+
});

0 commit comments

Comments
 (0)