1
|
|
|
const { |
2
|
|
|
utils: { string }, |
3
|
|
|
} = require('../dist/jaxon.module'); |
4
|
|
|
|
5
|
|
|
test('Replace single quotes with double quotes.', () => { |
6
|
|
|
expect(string.doubleQuotes("'Quoted'")).toBe('"Quoted"'); |
|
|
|
|
7
|
|
|
}); |
8
|
|
|
|
9
|
|
|
test('Replace double quotes with single quotes.', () => { |
10
|
|
|
expect(string.singleQuotes('"Quoted"')).toBe("'Quoted'"); |
|
|
|
|
11
|
|
|
}); |
12
|
|
|
|
13
|
|
|
test('Strip on prefix.', () => { |
14
|
|
|
expect(string.stripOnPrefix('onclick')).toBe('click'); |
|
|
|
|
15
|
|
|
}); |
16
|
|
|
|
17
|
|
|
test('Strip on prefix with capital letter.', () => { |
18
|
|
|
expect(string.stripOnPrefix('onClick')).toBe('click'); |
|
|
|
|
19
|
|
|
}); |
20
|
|
|
|
21
|
|
|
test('Strip on prefix with no prefix.', () => { |
22
|
|
|
expect(string.stripOnPrefix('click')).toBe('click'); |
|
|
|
|
23
|
|
|
}); |
24
|
|
|
|
25
|
|
|
test('Add on prefix.', () => { |
26
|
|
|
expect(string.addOnPrefix('click')).toBe('onclick'); |
|
|
|
|
27
|
|
|
}); |
28
|
|
|
|
29
|
|
|
test('Add on prefix with prefix.', () => { |
30
|
|
|
expect(string.addOnPrefix('onclick')).toBe('onclick'); |
|
|
|
|
31
|
|
|
}); |
32
|
|
|
|
33
|
|
|
test('Add on prefix with capital letter.', () => { |
34
|
|
|
expect(string.addOnPrefix('Click')).toBe('onclick'); |
|
|
|
|
35
|
|
|
}); |
36
|
|
|
|
37
|
|
|
test('Add on prefix with capital letter and prefix.', () => { |
38
|
|
|
expect(string.addOnPrefix('onClick')).toBe('onclick'); |
|
|
|
|
39
|
|
|
}); |
40
|
|
|
|
41
|
|
|
test('Replace placeholder in a string.', () => { |
42
|
|
|
expect('Really Mr. {name}?'.supplant({'name': 'Johnson'})).toBe('Really Mr. Johnson?'); |
43
|
|
|
}); |
44
|
|
|
|
45
|
|
|
test('Replace placeholders in a string.', () => { |
46
|
|
|
expect('{name} Mr. {word}!'.supplant({'name': 'Goodbye', 'word': 'Johnson'})).toBe('Goodbye Mr. Johnson!'); |
47
|
|
|
}); |
48
|
|
|
|
49
|
|
|
test('Replace inversed placeholders in a string.', () => { |
50
|
|
|
expect('Mr. {word}, {name}!'.supplant({'name': 'Goodbye', 'word': 'Johnson'})).toBe('Mr. Johnson, Goodbye!'); |
51
|
|
|
}); |
52
|
|
|
|
This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.
To learn more about declaring variables in Javascript, see the MDN.