Skip to content

Commit

Permalink
Remove need to test using jsdom for the Url specs
Browse files Browse the repository at this point in the history
  • Loading branch information
negativetwelve committed Sep 23, 2017
1 parent 9bd0e01 commit 71735f4
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 23 deletions.
4 changes: 2 additions & 2 deletions packages/handy-url/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
],
"dependencies": {
"jolt-lodash": "^2.7.7",
"qs": "6.2.0",
"url-parse": "1.1.1",
"qs": "6.5.1",
"url-parse": "1.1.9",
"valid-url": "1.0.9"
},
"scripts": {
Expand Down
6 changes: 4 additions & 2 deletions packages/handy-url/src/Url.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,11 @@ class Url {
const {protocol} = this.parsed;

switch (protocol) {
// If the url doesn't have a protocol, the parse(url) method returns
// `about` for `about:blank`.
case '':
return null;
case 'about:':
// If the url doesn't have a protocol, the parse(url) method returns
// `about` for `about:blank`.
return null;
default:
// We want to remote the colon from the end of the protocol.
Expand Down
15 changes: 6 additions & 9 deletions packages/handy-url/src/__tests__/Url.spec.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
/**
* @jest-environment jsdom
*
* TODO(mark): Unsure why this is necessary but in a node environment, tests
* fail. Definitely has to do with the Url class.
*/

// Imports
import Url from '../Url';

Expand Down Expand Up @@ -127,8 +120,12 @@ describe('Url', () => {
expect(new Url('https://google.com').domain).toBe('google');
});

it('does not require a protocol', () => {
expect(new Url('www.google.com').domain).toBe('google');
it('does not require a protocol but requires slashes', () => {
expect(new Url('//www.google.com').domain).toBe('google');
});

it('returns the empty string for invalid urls', () => {
expect(new Url('www.google.com').domain).toBe('');
});
});

Expand Down
20 changes: 10 additions & 10 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3767,9 +3767,9 @@ q@^1.4.1:
version "1.5.0"
resolved "https://registry.yarnpkg.com/q/-/q-1.5.0.tgz#dd01bac9d06d30e6f219aecb8253ee9ebdc308f1"

qs@6.2.0:
version "6.2.0"
resolved "https://registry.yarnpkg.com/qs/-/qs-6.2.0.tgz#3b7848c03c2dece69a9522b0fae8c4126d745f3b"
qs@6.5.1:
version "6.5.1"
resolved "https://registry.yarnpkg.com/qs/-/qs-6.5.1.tgz#349cdf6eef89ec45c12d7d5eb3fc0c870343a6d8"

qs@~6.3.0:
version "6.3.2"
Expand All @@ -3779,9 +3779,9 @@ qs@~6.4.0:
version "6.4.0"
resolved "https://registry.yarnpkg.com/qs/-/qs-6.4.0.tgz#13e26d28ad6b0ffaa91312cd3bf708ed351e7233"

querystringify@0.0.x:
version "0.0.4"
resolved "https://registry.yarnpkg.com/querystringify/-/querystringify-0.0.4.tgz#0cf7f84f9463ff0ae51c4c4b142d95be37724d9c"
querystringify@~1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/querystringify/-/querystringify-1.0.0.tgz#6286242112c5b712fa654e526652bf6a13ff05cb"

randomatic@^1.1.3:
version "1.1.7"
Expand Down Expand Up @@ -4550,11 +4550,11 @@ universalify@^0.1.0:
version "0.1.1"
resolved "https://registry.yarnpkg.com/universalify/-/universalify-0.1.1.tgz#fa71badd4437af4c148841e3b3b165f9e9e590b7"

url-parse@1.1.1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/url-parse/-/url-parse-1.1.1.tgz#d1507970728c9a5f80f471530c57325c3fb0e868"
url-parse@1.1.9:
version "1.1.9"
resolved "https://registry.yarnpkg.com/url-parse/-/url-parse-1.1.9.tgz#c67f1d775d51f0a18911dd7b3ffad27bb9e5bd19"
dependencies:
querystringify "0.0.x"
querystringify "~1.0.0"
requires-port "1.0.x"

user-home@^1.1.1:
Expand Down

0 comments on commit 71735f4

Please sign in to comment.