Skip to content

Commit

Permalink
Merge pull request #11 from jaredwray/adding-in-unit-tests-for-url-en…
Browse files Browse the repository at this point in the history
…code,-decode,-and-escape

adding in unit tests for url encode, decode, and escape
  • Loading branch information
jaredwray committed Sep 15, 2023
2 parents dd67570 + e3ca608 commit 7fe6a96
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 5 deletions.
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ Handlebars + Helpers Together
## Usage Nodejs

```bash
npm install @jaredwray/fumanchu
npm install @jaredwray/fumanchu --save
// or
yarn add @jaredwray/fumanchu
```

```javascript
Expand Down Expand Up @@ -343,14 +345,14 @@ Visit the: [code](lib/string.js) | [unit tests](test/string.js) | [issues](https
Visit the: [code](lib/url.js) | [unit tests](test/url.js) | [issues](https://github.com/jonathas/handlebars-helpers/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+url+helpers))

* **[encodeURI](#encodeURI)** ([code](lib/url.js#L19) | [tests](test/url.js#L31))
* **[escape](#escape)** ([code](lib/url.js#L34) | [no tests])
* **[escape](#escape)** ([code](lib/url.js#L34) | [tests](test/url.js#L81))
* **[decodeURI](#decodeURI)** ([code](lib/url.js#L48) | [tests](test/url.js#L38))
* **[url_encode](#url_encode)** ([code](lib/url.js#L59) | [no tests])
* **[url_decode](#url_decode)** ([code](lib/url.js#L68) | [no tests])
* **[url_encode](#url_encode)** ([code](lib/url.js#L59) | [tests](test/url.js#L89))
* **[url_decode](#url_decode)** ([code](lib/url.js#L68) | [tests](test/url.js#L93))
* **[urlResolve](#urlResolve)** ([code](lib/url.js#L82) | [tests](test/url.js#L11))
* **[urlParse](#urlParse)** ([code](lib/url.js#L94) | [tests](test/url.js#L45))
* **[stripQuerystring](#stripQuerystring)** ([code](lib/url.js#L106) | [tests](test/url.js#L24))
* **[stripProtocol](#stripProtocol)** ([code](lib/url.js#L126) | [no tests])
* **[stripProtocol](#stripProtocol)** ([code](lib/url.js#L126) | [tests](test/url.js#L53))

***

Expand Down
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 7fe6a96

Please sign in to comment.