Skip to content

Commit 8947eba

Browse files
Added tests for newly-added properties
1 parent f22043d commit 8947eba

File tree

3 files changed

+38
-3
lines changed

3 files changed

+38
-3
lines changed

karma.conf.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ module.exports = karmaConfig({
1212
browsers: {
1313
chrome: host.ci ? host.os.linux : true,
1414
firefox: host.ci ? host.os.linux : true,
15-
safari: host.ci ? host.os.linux : host.os.mac, // SauceLabs in CI
16-
edge: host.ci ? host.os.linux : host.os.windows, // SauceLabs in CI
17-
ie: host.ci ? host.os.windows : false, // IE needs to run by itself, due to Babel transforms
15+
safari: host.ci ? host.os.linux : host.os.mac,
16+
edge: host.ci ? host.os.linux : host.os.windows,
17+
ie: host.os.windows,
1818
},
1919
config: {
2020
// Prevent Karma-Config from using the "karma-host-environment" framework,

test/specs/browser.spec.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,23 @@ describe("Browser environment", () => {
2424

2525
}
2626
else {
27+
/* eslint-env browser */
28+
29+
it("host.path should be the current page", () => {
30+
expect(host.path).to.equal(window.location.href);
31+
});
32+
33+
it("host.url should be the current page", () => {
34+
expect(host.url.href).to.deep.equal(window.location.href);
35+
});
36+
37+
it("host.cwd should be the parent directory of the current page", () => {
38+
expect(window.location.href).to.contain(host.cwd);
39+
});
40+
41+
it("host.cwdURL should be the parent directory of the current page", () => {
42+
expect(window.location.href).to.contain(host.cwdURL.href);
43+
});
2744

2845
it("host.browser should be an object", () => {
2946
expect(host.browser).to.be.an("object");

test/specs/node.spec.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,24 @@ describe("Node.js environment", () => {
1313

1414
}
1515
else {
16+
/* eslint-env node */
17+
18+
it("host.path should be the execPath", () => {
19+
expect(host.path).to.equal(process.execPath);
20+
});
21+
22+
it("host.url should be a file:// URL", () => {
23+
expect(host.url.href).to.match(/^file:\/\//);
24+
});
25+
26+
it("host.cwd should be the current working directory", () => {
27+
expect(host.cwd).to.equal(process.cwd());
28+
});
29+
30+
it("host.cwdURL should be a file:// URL", () => {
31+
expect(host.cwdURL.href).to.match(/^file:\/\//);
32+
});
33+
1634

1735
it("host.node should be an object", () => {
1836
expect(host.node).to.be.an("object");

0 commit comments

Comments
 (0)