Skip to content

Commit

Permalink
test(external-value): value should skip resolution
Browse files Browse the repository at this point in the history
  • Loading branch information
mathis-m committed Sep 23, 2021
1 parent d74f72f commit 421a481
Showing 1 changed file with 37 additions and 6 deletions.
43 changes: 37 additions & 6 deletions test/specmap/external-value.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,35 +16,66 @@ describe('externalValue', () => {
});

beforeEach(() => {
externalValue.clearCache()
externalValue.clearCache();
});

describe('ExternalValueError', () => {
test('should contain the externalValue error details', () => {
try {
throw new externalValue.ExternalValueError('Probe', {
externalValue: 'http://test.com/probe',
fullPath: "probe",
fullPath: 'probe',
});
} catch (e) {
expect(e.toString()).toEqual('ExternalValueError: Probe');
expect(e.externalValue).toEqual('http://test.com/probe');
expect(e.fullPath).toEqual("probe");
expect(e.fullPath).toEqual('probe');
}
});
test('.wrapError should wrap an error in ExternalValueError', () => {
try {
throw externalValue.wrapError(new Error('hi'), {
externalValue: 'http://test.com/probe',
fullPath: "probe",
fullPath: 'probe',
});
} catch (e) {
expect(e.message).toMatch(/externalValue/);
expect(e.message).toMatch(/hi/);
expect(e.externalValue).toEqual('http://test.com/probe');
expect(e.fullPath).toEqual("probe");
expect(e.fullPath).toEqual('probe');
}
});
});

});
describe('externalValue Plugin value collision', () => {
const spec = {
paths: {
'/probe': {
get: {
responses: {
200: {
content: {
'*/*': {
examples: {
probe: {
externalValue: 'http://test.com/probe',
value: 'test',
},
},
},
},
},
},
},
},
},
};
test('should skip resolution of externalValue if value is defined', () =>
mapSpec({
spec,
plugins: [externalValue],
}).then((res) => {
expect(res.spec).toEqual(spec);
}));
});
});

0 comments on commit 421a481

Please sign in to comment.