Skip to content

Commit 9189edb

Browse files
format fix :P
1 parent 5dcbdc9 commit 9189edb

File tree

1 file changed

+26
-35
lines changed

1 file changed

+26
-35
lines changed
Lines changed: 26 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,50 @@
1-
21
import { replaceVariables } from '@common/utils/variables';
3-
42
import { expect } from 'chai';
53

64
describe('Utils | variables', () => {
75
describe('replaceVariables', () => {
86
const variables = {
9-
'name': 'bob',
10-
'age': 32,
11-
'favFoods': [
12-
'takoyaki', 'onigiri', 'taiyaki'
13-
],
14-
'job': {
15-
'company': 'voiceflow',
16-
'position': 'software engineer',
17-
'team': 'creator'
18-
}
7+
name: 'bob',
8+
age: 32,
9+
favFoods: ['takoyaki', 'onigiri', 'taiyaki'],
10+
job: {
11+
company: 'voiceflow',
12+
position: 'software engineer',
13+
team: 'creator',
14+
},
1915
};
2016
it('correctly replaces simple variables', () => {
21-
expect(replaceVariables('hello, my name is {name}, and i am {age} years old', variables))
22-
.to.eq('hello, my name is bob, and i am 32 years old');
23-
expect(replaceVariables('{name} {name} {name}', variables))
24-
.to.eq('bob bob bob');
17+
expect(replaceVariables('hello, my name is {name}, and i am {age} years old', variables)).to.eq('hello, my name is bob, and i am 32 years old');
18+
expect(replaceVariables('{name} {name} {name}', variables)).to.eq('bob bob bob');
2519
});
2620
it('variables that are not defined do not get expanded', () => {
27-
expect(replaceVariables('hello, my name is {name} and i work at {workplace}', variables))
28-
.to.eq('hello, my name is bob and i work at {workplace}');
29-
expect(replaceVariables('hello, my name is {Name}', variables))
30-
.to.eq('hello, my name is {Name}');
21+
expect(replaceVariables('hello, my name is {name} and i work at {workplace}', variables)).to.eq(
22+
'hello, my name is bob and i work at {workplace}'
23+
);
24+
expect(replaceVariables('hello, my name is {Name}', variables)).to.eq('hello, my name is {Name}');
3125
});
3226

3327
it('array access works', () => {
34-
expect(replaceVariables('most favorite food is {favFoods[0]}, second favorite is {favFoods[1]}, and third is {favFoods[2]}', variables))
35-
.to.eq('most favorite food is takoyaki, second favorite is onigiri, and third is taiyaki');
36-
});
37-
it('index out of range', () => {
28+
expect(replaceVariables('most favorite food is {favFoods[0]}, second favorite is {favFoods[1]}, and third is {favFoods[2]}', variables)).to.eq(
29+
'most favorite food is takoyaki, second favorite is onigiri, and third is taiyaki'
30+
);
3831
});
32+
// it('index out of range', () => {});
3933

4034
it('object access works', () => {
41-
expect(replaceVariables('i work at {job.company} as a {job.position} on the {job.team} team', variables))
42-
.to.eq('i work at voiceflow as a software engineer on the creator team');
43-
});
44-
it('non-existent fields', () => {
35+
expect(replaceVariables('i work at {job.company} as a {job.position} on the {job.team} team', variables)).to.eq(
36+
'i work at voiceflow as a software engineer on the creator team'
37+
);
4538
});
39+
// it('non-existent fields', () => {});
4640

4741
it('weird cases', () => {
4842
const variables = {
4943
'': 6969,
50-
'var': '{name}',
51-
}
52-
expect(replaceVariables('this is a blank variable {}', variables))
53-
.to.eq('this is a blank variable {}');
54-
expect(replaceVariables('{var}', variables))
55-
.to.eq('{name}');
44+
var: '{name}',
45+
};
46+
expect(replaceVariables('this is a blank variable {}', variables)).to.eq('this is a blank variable {}');
47+
expect(replaceVariables('{var}', variables)).to.eq('{name}');
5648
});
57-
5849
});
5950
});

0 commit comments

Comments
 (0)