Skip to content

Commit

Permalink
test: add test case.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaywcjlove committed Mar 21, 2023
1 parent 9749274 commit 578358b
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ it('Path Templater test case', async () => {
expect(pathTemplater('/:name/:name', { name: 'wcj' })).toEqual('/wcj/wcj');
expect(pathTemplater('http://localhost/:name/:name', { name: 'wcj' })).toEqual('http://localhost/wcj/wcj');
expect(pathTemplater('http://github.com/:owner/:repo', { owner: 'jaywcjlove', repo: 'path-templater' })).toEqual('http://github.com/jaywcjlove/path-templater');
expect(() => pathTemplater(':apiBaseUrl/:owner/:repo', { owner: 'jaywcjlove', repo: 'path-templater' })).toThrow('Could not find url parameter apiBaseUrl in passed options object');
expect(pathTemplater(':apiBaseUrl/:owner/:repo', { owner: 'jaywcjlove', repo: 'path-templater', apiBaseUrl: 'http://github.com' })).toEqual('http://github.com/jaywcjlove/path-templater');
expect(pathTemplater('http://localhost:3001/:name/:name', { name: 'wcj' })).toEqual('http://localhost:3001/wcj/wcj');
expect(pathTemplater('http://localhost:3001/:name/:name?id=:user', { name: 'wcj', user: 'jaywcjlove' })).toEqual('http://localhost:3001/wcj/wcj?id=jaywcjlove');

expect(() => pathTemplater(':apiBaseUrl/:owner/:repo', { owner: 'jaywcjlove', repo: 'path-templater' })).toThrow('Could not find url parameter apiBaseUrl in passed options object');
expect(() => pathTemplater('/:name')).toThrow('Could not find url parameter name in passed options object');
});

0 comments on commit 578358b

Please sign in to comment.