-
Notifications
You must be signed in to change notification settings - Fork 38
/
Copy pathhttpYacApi.spec.ts
71 lines (63 loc) · 1.6 KB
/
httpYacApi.spec.ts
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import { getVariables } from './httpYacApi';
import { initFileProvider, parseHttp } from './test/testUtils';
describe('httpYacApi', () => {
describe('getVariables', () => {
it('should return secret provided by environment', async () => {
initFileProvider({
'.env': 'secret=from .env',
});
const httpFile = await parseHttp(`
# @name test
`);
const variables = await getVariables({
httpFile,
});
expect(variables).toEqual(
expect.objectContaining({
secret: 'from .env',
})
);
});
it('should return secret provided by context variables', async () => {
initFileProvider({
'.env': 'secret=from.env',
});
const httpFile = await parseHttp(`
# @name test
`);
const variables = await getVariables({
httpFile,
variables: {
secret: 'cli args',
},
});
expect(variables).toEqual(
expect.objectContaining({
secret: 'cli args',
})
);
});
it('should return secret provided by intellij', async () => {
initFileProvider({
'.env': 'secret=from.env',
'http-client.env.json': JSON.stringify({
dev: {
secret: 'intellij variable',
},
}),
});
const httpFile = await parseHttp(`
# @name test
`);
const variables = await getVariables({
httpFile,
activeEnvironment: ['dev'],
});
expect(variables).toEqual(
expect.objectContaining({
secret: 'intellij variable',
})
);
});
});
});