Skip to content
This repository was archived by the owner on Mar 30, 2021. It is now read-only.

Commit 4c82645

Browse files
Nikhil-Vatssarthak-sehgal
authored andcommitted
Added unit tests (#15)
This adds two unit tests, for checking - if the project is created with correct user inputs if user inputs something - if the project is created with default prompts if user inputs nothing.
1 parent b6ef821 commit 4c82645

File tree

1 file changed

+35
-1
lines changed

1 file changed

+35
-1
lines changed

__tests__/app.js

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ const helpers = require("yeoman-test");
66
describe("generator-biojs-webcomponents:app", () => {
77
beforeAll(() => {
88
return helpers.run(path.join(__dirname, "../generators/app")).withPrompts({
9-
someAnswer: true
9+
toolNameComputer: "test-component-tool",
10+
toolNameHuman: "Biojs test component"
1011
});
1112
});
1213

@@ -26,4 +27,37 @@ describe("generator-biojs-webcomponents:app", () => {
2627
it("initialises server script", () => {
2728
assert.file(["dev/serve.js"]);
2829
});
30+
it("initialises the component with correct user inputs", () => {
31+
assert.fileContent([
32+
[
33+
"examples/index.html",
34+
'<test-component-tool geneId="BRCA1"></test-component-tool>'
35+
],
36+
["examples/index.html", "<h1>Biojs test component demo</h1>"],
37+
["src/index.js", "define('test-component-tool', BiojsTestComponent);"],
38+
["src/style.less", ".BiojsTestComponent"]
39+
]);
40+
});
41+
it("initialises the component with default names if user inputs nothing", () => {
42+
return helpers
43+
.run(path.join(__dirname, "../generators/app"))
44+
.withPrompts({
45+
toolNameComputer: "",
46+
toolNameHuman: ""
47+
})
48+
.then(() => {
49+
assert.fileContent([
50+
[
51+
"examples/index.html",
52+
'<biojs-webcomponent-tool-name-here geneId="BRCA1"></biojs-webcomponent-tool-name-here>'
53+
],
54+
["examples/index.html", "<h1>BioJS component demo</h1>"],
55+
[
56+
"src/index.js",
57+
"define('biojs-webcomponent-tool-name-here', BioJSComponent);"
58+
],
59+
["src/style.less", ".BioJSComponent"]
60+
]);
61+
});
62+
});
2963
});

0 commit comments

Comments
 (0)