mirror of
https://github.com/bitwarden/browser.git
synced 2024-11-22 11:45:59 +01:00
move utils tests to jslib
This commit is contained in:
parent
3d3fd28647
commit
c4fc9a2c80
2
jslib
2
jslib
@ -1 +1 @@
|
||||
Subproject commit d6474aee0e84c933c5a36aa2fa20b209be18d74c
|
||||
Subproject commit 9ac6f5db1fb6f3b5e6472e85e40a9f8d58621cbb
|
104
package-lock.json
generated
104
package-lock.json
generated
@ -1504,16 +1504,6 @@
|
||||
"rimraf": "2.6.2"
|
||||
}
|
||||
},
|
||||
"cli": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/cli/-/cli-1.0.1.tgz",
|
||||
"integrity": "sha1-IoF1NPJL+klQw01TLUjsvGIbjBQ=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"exit": "0.1.2",
|
||||
"glob": "7.1.2"
|
||||
}
|
||||
},
|
||||
"cli-width": {
|
||||
"version": "2.2.0",
|
||||
"resolved": "https://registry.npmjs.org/cli-width/-/cli-width-2.2.0.tgz",
|
||||
@ -2858,12 +2848,6 @@
|
||||
"strip-eof": "1.0.0"
|
||||
}
|
||||
},
|
||||
"exit": {
|
||||
"version": "0.1.2",
|
||||
"resolved": "https://registry.npmjs.org/exit/-/exit-0.1.2.tgz",
|
||||
"integrity": "sha1-BjJjj42HfMghB9MKD/8aF8uhzQw=",
|
||||
"dev": true
|
||||
},
|
||||
"expand-braces": {
|
||||
"version": "0.1.2",
|
||||
"resolved": "https://registry.npmjs.org/expand-braces/-/expand-braces-0.1.2.tgz",
|
||||
@ -6238,82 +6222,6 @@
|
||||
"integrity": "sha1-597mbjXW/Bb3EP6R1c9p9w8IkR0=",
|
||||
"dev": true
|
||||
},
|
||||
"jshint": {
|
||||
"version": "2.9.5",
|
||||
"resolved": "https://registry.npmjs.org/jshint/-/jshint-2.9.5.tgz",
|
||||
"integrity": "sha1-HnJSkVzmgbQIJ+4UJIxG006apiw=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"cli": "1.0.1",
|
||||
"console-browserify": "1.1.0",
|
||||
"exit": "0.1.2",
|
||||
"htmlparser2": "3.8.3",
|
||||
"lodash": "3.7.0",
|
||||
"minimatch": "3.0.4",
|
||||
"shelljs": "0.3.0",
|
||||
"strip-json-comments": "1.0.4"
|
||||
},
|
||||
"dependencies": {
|
||||
"domhandler": {
|
||||
"version": "2.3.0",
|
||||
"resolved": "https://registry.npmjs.org/domhandler/-/domhandler-2.3.0.tgz",
|
||||
"integrity": "sha1-LeWaCCLVAn+r/28DLCsloqir5zg=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"domelementtype": "1.3.0"
|
||||
}
|
||||
},
|
||||
"entities": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/entities/-/entities-1.0.0.tgz",
|
||||
"integrity": "sha1-sph6o4ITR/zeZCsk/fyeT7cSvyY=",
|
||||
"dev": true
|
||||
},
|
||||
"htmlparser2": {
|
||||
"version": "3.8.3",
|
||||
"resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-3.8.3.tgz",
|
||||
"integrity": "sha1-mWwosZFRaovoZQGn15dX5ccMEGg=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"domelementtype": "1.3.0",
|
||||
"domhandler": "2.3.0",
|
||||
"domutils": "1.5.1",
|
||||
"entities": "1.0.0",
|
||||
"readable-stream": "1.1.14"
|
||||
}
|
||||
},
|
||||
"isarray": {
|
||||
"version": "0.0.1",
|
||||
"resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz",
|
||||
"integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=",
|
||||
"dev": true
|
||||
},
|
||||
"lodash": {
|
||||
"version": "3.7.0",
|
||||
"resolved": "https://registry.npmjs.org/lodash/-/lodash-3.7.0.tgz",
|
||||
"integrity": "sha1-Nni9irmVBXwHreg27S7wh9qBHUU=",
|
||||
"dev": true
|
||||
},
|
||||
"readable-stream": {
|
||||
"version": "1.1.14",
|
||||
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz",
|
||||
"integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"core-util-is": "1.0.2",
|
||||
"inherits": "2.0.3",
|
||||
"isarray": "0.0.1",
|
||||
"string_decoder": "0.10.31"
|
||||
}
|
||||
},
|
||||
"string_decoder": {
|
||||
"version": "0.10.31",
|
||||
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz",
|
||||
"integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=",
|
||||
"dev": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"json-loader": {
|
||||
"version": "0.5.7",
|
||||
"resolved": "https://registry.npmjs.org/json-loader/-/json-loader-0.5.7.tgz",
|
||||
@ -10032,12 +9940,6 @@
|
||||
"integrity": "sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM=",
|
||||
"dev": true
|
||||
},
|
||||
"shelljs": {
|
||||
"version": "0.3.0",
|
||||
"resolved": "https://registry.npmjs.org/shelljs/-/shelljs-0.3.0.tgz",
|
||||
"integrity": "sha1-NZbmMHp4FUT1kfN9phg2DzHbV7E=",
|
||||
"dev": true
|
||||
},
|
||||
"sigmund": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/sigmund/-/sigmund-1.0.1.tgz",
|
||||
@ -10740,12 +10642,6 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"strip-json-comments": {
|
||||
"version": "1.0.4",
|
||||
"resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-1.0.4.tgz",
|
||||
"integrity": "sha1-HhX7ysl9Pumb8tc7TGVrCCu6+5E=",
|
||||
"dev": true
|
||||
},
|
||||
"style-loader": {
|
||||
"version": "0.19.1",
|
||||
"resolved": "https://registry.npmjs.org/style-loader/-/style-loader-0.19.1.tgz",
|
||||
|
@ -53,7 +53,6 @@
|
||||
"html-webpack-plugin": "^2.30.1",
|
||||
"jasmine-core": "^2.8.0",
|
||||
"jasmine-spec-reporter": "^4.2.1",
|
||||
"jshint": "2.9.5",
|
||||
"karma": "^1.7.1",
|
||||
"karma-chrome-launcher": "^2.2.0",
|
||||
"karma-cli": "^1.0.1",
|
||||
|
@ -1,33 +0,0 @@
|
||||
import { UtilsService } from 'jslib/services';
|
||||
|
||||
describe('Utils Service', () => {
|
||||
describe('getHostname', () => {
|
||||
it('should fail for invalid urls', () => {
|
||||
expect(UtilsService.getHostname(null)).toBeNull();
|
||||
expect(UtilsService.getHostname(undefined)).toBeNull();
|
||||
expect(UtilsService.getHostname(' ')).toBeNull();
|
||||
expect(UtilsService.getHostname('https://bit!:"_&ward.com')).toBeNull();
|
||||
expect(UtilsService.getHostname('bitwarden')).toBeNull();
|
||||
});
|
||||
|
||||
it('should handle valid urls', () => {
|
||||
expect(UtilsService.getHostname('bitwarden.com')).toBe('bitwarden.com');
|
||||
expect(UtilsService.getHostname('https://bitwarden.com')).toBe('bitwarden.com');
|
||||
expect(UtilsService.getHostname('http://bitwarden.com')).toBe('bitwarden.com');
|
||||
expect(UtilsService.getHostname('http://vault.bitwarden.com')).toBe('vault.bitwarden.com');
|
||||
expect(UtilsService.getHostname('https://user:password@bitwarden.com:8080/password/sites?and&query#hash')).toBe('bitwarden.com');
|
||||
});
|
||||
|
||||
it('should support localhost and IP', () => {
|
||||
expect(UtilsService.getHostname('https://localhost')).toBe('localhost');
|
||||
expect(UtilsService.getHostname('https://192.168.1.1')).toBe('192.168.1.1');
|
||||
});
|
||||
});
|
||||
|
||||
describe('newGuid', () => {
|
||||
it('should create a valid guid', () => {
|
||||
const validGuid = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
||||
expect(UtilsService.newGuid()).toMatch(validGuid);
|
||||
});
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue
Block a user