change tests to use url-parse

This commit is contained in:
erezrokah 2017-10-08 18:05:48 +03:00
parent 64ba939361
commit 98ade4d161
1 changed files with 6 additions and 7 deletions

View File

@ -73,7 +73,7 @@ function linksTests({ describe, it, firebase, tryCatch }) {
Object.keys(expectedParameters).forEach((key) => { Object.keys(expectedParameters).forEach((key) => {
const val = expectedParameters[key]; const val = expectedParameters[key];
val.should.eql(params[key]); params[key].should.eql(val);
}); });
}); });
@ -87,12 +87,11 @@ function linksTests({ describe, it, firebase, tryCatch }) {
const result = await links.createDynamicLink(data); const result = await links.createDynamicLink(data);
result.should.startWith(`https://${dynamicLinkDomain}`); const url = new URL(result);
url.protocol.should.eql('https:');
const encodedLink = encodeURIComponent(link); url.hostname.should.eql(dynamicLinkDomain);
const encodedLinkWithEncodedPeriod = encodeURIComponent(link).replace(/\./g, '%2E'); const params = queryString.parse(url.query);
(result.includes(`link=${encodedLink}`) || params.link.should.eql(link);
result.includes(`link=${encodedLinkWithEncodedPeriod}`)).should.be.true();
}); });
it('fail to create long dynamic link with empty data object', () => { it('fail to create long dynamic link with empty data object', () => {