-
Notifications
You must be signed in to change notification settings - Fork 37
Expand file tree
/
Copy pathstripQuerystring.js
More file actions
54 lines (47 loc) · 1.65 KB
/
Copy pathstripQuerystring.js
File metadata and controls
54 lines (47 loc) · 1.65 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
48
49
50
51
52
53
54
const Lab = require('lab'),
lab = exports.lab = Lab.script(),
describe = lab.experiment,
it = lab.it,
testRunner = require('../spec-helpers').testRunner;
const themeSettings = {
logo_image: '600x300',
};
describe('stripQuerystring helper', function() {
const urlData_2_qs = 'https://cdn.example.com/path/to/{:size}/image.png?c=2&imbypass=on';
const context = {
image_with_2_qs: {
data: urlData_2_qs
},
};
const runTestCases = testRunner({context, themeSettings});
it('strips the query string from a given url', function(done) {
runTestCases([{
input: `{{stripQuerystring 'http://www.example.com?foo=1&bar=2&baz=3'}}`,
output: 'http://www.example.com',
},
], done);
});
it('should work with the getImageSrcset helper as a nested expression', function(done) {
runTestCases([{
input: `{{stripQuerystring (getImageSrcset image_with_2_qs 1x='100x100')}}`,
output: 'https://cdn.example.com/path/to/100x100/image.png',
},
], done);
});
it('should work with the getImage helper as a nested expression', function(done) {
runTestCases([
{
input: '{{stripQuerystring (getImage image_with_2_qs "logo_image")}}',
output: 'https://cdn.example.com/path/to/600x300/image.png',
},
], done);
});
it('should return nothing when url is not a string', function(done) {
runTestCases([
{
input: '{{stripQuerystring 123}}',
output: '',
},
], done);
});
});