From 98ade4d1611cd63cdccd99ab22d355fdb1ee7cd7 Mon Sep 17 00:00:00 2001 From: erezrokah Date: Sun, 8 Oct 2017 18:05:48 +0300 Subject: [PATCH] change tests to use url-parse --- tests/src/tests/links/linksTests.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/tests/src/tests/links/linksTests.js b/tests/src/tests/links/linksTests.js index 3f6e9017..9b37c16e 100644 --- a/tests/src/tests/links/linksTests.js +++ b/tests/src/tests/links/linksTests.js @@ -73,7 +73,7 @@ function linksTests({ describe, it, firebase, tryCatch }) { Object.keys(expectedParameters).forEach((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); - result.should.startWith(`https://${dynamicLinkDomain}`); - - const encodedLink = encodeURIComponent(link); - const encodedLinkWithEncodedPeriod = encodeURIComponent(link).replace(/\./g, '%2E'); - (result.includes(`link=${encodedLink}`) || - result.includes(`link=${encodedLinkWithEncodedPeriod}`)).should.be.true(); + const url = new URL(result); + url.protocol.should.eql('https:'); + url.hostname.should.eql(dynamicLinkDomain); + const params = queryString.parse(url.query); + params.link.should.eql(link); }); it('fail to create long dynamic link with empty data object', () => {