-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathgetComponentPath.spec.ts
More file actions
47 lines (42 loc) · 1.51 KB
/
getComponentPath.spec.ts
File metadata and controls
47 lines (42 loc) · 1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
import { getComponentPath } from '../../helpers/getComponentPath';
describe('getComponentPath()', () => {
describe('when $ref has no schema', () => {
it('should return url with schema', () => {
expect(
getComponentPath(
'"$ref":"//localhost/kafka-config/components.yml#/components/schema2"',
'http://localhost/kafka.yaml'
)
).toBe('http://localhost/kafka-config/components.yml');
});
});
describe('when $ref has different schema', () => {
it('should return url with schema', () => {
expect(
getComponentPath(
'"$ref":"https://localhost/kafka-config/components.yml#/components/schema2"',
'http://localhost/kafka.yaml'
)
).toBe('https://localhost/kafka-config/components.yml');
});
});
describe('when input document & $ref are relative', () => {
it('should return relative path', () => {
expect(getComponentPath('"$ref":"kafka-config/components.yml#/components/schema"', 'input/kafka.yaml')).toBe(
'input/kafka-config/components.yml'
);
});
});
describe('when input document is remote & $ref is relative', () => {
it('should return relative path', () => {
expect(
getComponentPath('"$ref":"kafka-config/components.yml#/components/schema"', 'http://localhost/kafka.yaml')
).toBe('http://localhost/kafka-config/components.yml');
});
});
});