Skip to content

Commit

Permalink
Merge pull request #57 from acifani/add-tests
Browse files Browse the repository at this point in the history
test: add tests for #54
  • Loading branch information
lifaon74 authored May 13, 2020
2 parents 83fac77 + 36fd149 commit 8b24e79
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
13 changes: 13 additions & 0 deletions tests/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,19 @@
if (url.origin !== 'https://www.example.com') throw new Error('Origin value is not correct ' + url.origin);
if (url2.origin !== 'http://www.example.com:8080') throw new Error('Origin value is not correct ' + url2.origin);
if (url3.origin !== 'https://www.example.com:80') throw new Error('Origin value is not correct ' + url3.origin);
`);
});
await tester.test('URL constructor should throw on invalid URL', () => {
return driver.executeScript(`
try {
var url = 'relative_url_without_base';
new URL(url);
throw new Error('Should have thrown for URL(' + url + ')');
} catch (e) {
if (!e instanceof TypeError) {
throw new Error("Expected TypeError but got " + e);
}
}
`);
});
});
Expand Down
14 changes: 14 additions & 0 deletions tests/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,20 @@ import { Tester } from './classes/Tester';
`);
});

await tester.test('URL constructor should throw on invalid URL', () => {
return driver.executeScript(`
try {
var url = 'relative_url_without_base';
new URL(url);
throw new Error('Should have thrown for URL(' + url + ')');
} catch (e) {
if (!e instanceof TypeError) {
throw new Error("Expected TypeError but got " + e);
}
}
`);
});

});

})().catch(_ => console.log('ERROR: ', _));

0 comments on commit 8b24e79

Please sign in to comment.