Skip to content

Commit

Permalink
test(cli): optimized cli tests
Browse files Browse the repository at this point in the history
  • Loading branch information
onderceylan committed Nov 1, 2019
1 parent 3027d07 commit e3a2ed7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/cli.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ test('throws error when input is not provided', async () => {
try {
await execa.sync('./bin/cli', []);
} catch (e) {
expect(e.stderr).toContain('Please specify a URL or file path as a source');
expect(e).not.toBeUndefined();
}
});

Expand Down
12 changes: 12 additions & 0 deletions src/helpers/url.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,18 @@ const exampleUrl =
'https://raw.githubusercontent.com/onderceylan/pwa-asset-generator/HEAD/static/logo.png';

describe('URL helper', () => {
describe('with isUrlExist should check url existence', () => {
it('when URL is reachable', async () => {
expect(await url.isUrlExists(exampleUrl)).toBeTruthy();
});

it('when URL is not reachable', async () => {
expect(
await url.isUrlExists('https://your-cdn-server.com/assets/logo.png'),
).toBeFalsy();
});
});

describe('with isUrl should check url', () => {
it('when URL is legitimate', async () => {
expect(await url.isUrl(exampleUrl)).toBeTruthy();
Expand Down

0 comments on commit e3a2ed7

Please sign in to comment.