Skip to content

Commit

Permalink
adding in unit tests for url encode, decode, and escape
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredwray committed Sep 15, 2023
1 parent dd67570 commit 513a9e7
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions test/url.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,22 @@ describe('url', function() {
assert.equal(fn(data), expected);
});
});

describe('escape', function() {
it('should escape a url', function() {
var fn = hbs.compile('{{escape "http://example.com?comment=Thyme &time=again"}}');
assert.equal(fn(), 'http%3A%2F%2Fexample.com%3Fcomment%3DThyme%20%26time%3Dagain');
});
});

describe('url_encode and url_decode', function() {
it('should return an encoded uri string.', function() {
var fn = hbs.compile('{{url_encode "http://example.com?comment=Thyme &time=again"}}');
assert.equal(fn(), 'http%3A%2F%2Fexample.com%3Fcomment%3DThyme%20%26time%3Dagain');
});
it('should return an decoded uri string.', function() {
var fn = hbs.compile('{{{url_decode "http%3A%2F%2Fexample.com%3Fcomment%3DThyme%20%26time%3Dagain"}}}');
assert.equal(fn(), 'http://example.com?comment=Thyme &time=again');
});
});
});

0 comments on commit 513a9e7

Please sign in to comment.