@g_package/jest-cucumber-fusion 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.prettierignore +16 -0
- package/.prettierrc.json +0 -0
- package/LICENSE +201 -0
- package/README.md +165 -0
- package/codecov +0 -0
- package/codecov.SHA256SUM +1 -0
- package/codecov.SHA256SUM.sig +16 -0
- package/docs/AdditionalConfiguration.md +155 -0
- package/docs/GherkinTables.md +61 -0
- package/docs/Language.md +76 -0
- package/docs/ReusingStepDefinitions.md +110 -0
- package/docs/RunningTheExamples.md +16 -0
- package/docs/ScenarioOutlines.md +43 -0
- package/docs/StepDefinitionArguments.md +37 -0
- package/package.json +82 -0
- package/src/index.d.ts +25 -0
- package/src/index.js +404 -0
- package/test/specs/features/basic-scenarios.feature +28 -0
- package/test/specs/features/language.feature +41 -0
- package/test/specs/features/reuse-definition.feature +13 -0
- package/test/specs/features/scenario-outline2.feature +71 -0
- package/test/specs/features/scenario-outlines.feature +88 -0
- package/test/specs/features/step-definitions/basic-scenarios.steps.js +45 -0
- package/test/specs/features/step-definitions/language.steps.js +86 -0
- package/test/specs/features/step-definitions/reuse-code.js +17 -0
- package/test/specs/features/step-definitions/reuse-definition.steps.js +22 -0
- package/test/specs/features/step-definitions/scenario-outline2.steps.js +46 -0
- package/test/specs/features/step-definitions/scenario-outlines.steps.js +110 -0
- package/test/specs/features/step-definitions/using-dynamic-values.steps.js +70 -0
- package/test/specs/features/step-definitions/using-gherkin-tables.steps.js +42 -0
- package/test/specs/features/using-dynamic-values.feature +34 -0
- package/test/specs/features/using-gherkin-tables.feature +16 -0
- package/test/src/bank-account.js +17 -0
- package/test/src/online-sales.js +33 -0
- package/test/src/rocket.js +13 -0
- package/test/src/todo-list.js +20 -0
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
const {
|
|
2
|
+
Before,
|
|
3
|
+
Given,
|
|
4
|
+
When,
|
|
5
|
+
Then,
|
|
6
|
+
Fusion,
|
|
7
|
+
And,
|
|
8
|
+
But,
|
|
9
|
+
} = require("../../../../src");
|
|
10
|
+
|
|
11
|
+
const { OnlineSales } = require("../../../src/online-sales");
|
|
12
|
+
|
|
13
|
+
let onlineSales;
|
|
14
|
+
let salesPrice;
|
|
15
|
+
|
|
16
|
+
Before(() => {
|
|
17
|
+
onlineSales = new OnlineSales();
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
Given(/^ik heb een t-shirt$/, (item) => {
|
|
21
|
+
onlineSales.listItem("Rick Astley t-shirt");
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
When(/^ik een t-shirt wil verkopen$/, (item) => {
|
|
25
|
+
salesPrice = onlineSales.sellItem("Rick Astley t-shirt");
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
Then(/^ontvang ik €22$/, (item) => {
|
|
29
|
+
expect(salesPrice).toEqual(22);
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
And(/^ben ik blij$/, (item) => {
|
|
33
|
+
expect("ik").not.toEqual("boos");
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
But(/^heb ik geen t-shirts over$/, (item) => {
|
|
37
|
+
expect(onlineSales.listedItems).not.toContain("Rick Astley t-shirt");
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
Given(/^ik heb een: (.*)$/, (item) => {
|
|
41
|
+
onlineSales.listItem(item);
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
When(/^ik (.*) verkoop$/, (item) => {
|
|
45
|
+
salesPrice = onlineSales.sellItem(item);
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
Then(/^zou ik er €(\d+) voor moeten krijgen$/, (expectedSalesPrice) => {
|
|
49
|
+
expect(salesPrice).toBe(parseInt(expectedSalesPrice));
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
Given(/^'(.*)' is te koop$/, (object) => {
|
|
53
|
+
onlineSales.listItem(object);
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
When(/^ik '(.*)' koop$/, (object) => {
|
|
57
|
+
salesPrice = onlineSales.sellItem(object);
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
Then(/^heb ik €(\d+) uitgegeven$/, (amount) => {
|
|
61
|
+
expect(salesPrice).toEqual(100);
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
Given("mijn voorraad bevat:", (table) => {
|
|
65
|
+
table.forEach((row) => {
|
|
66
|
+
onlineSales.listItem(row.Object);
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
When("ik de volgende producten toevoeg:", (table) => {
|
|
71
|
+
onlineSales.listItem(table[0].Object);
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
Then(
|
|
75
|
+
/^zitten er (\d) objecten in mijn voorraad, bestaant uit:$/,
|
|
76
|
+
(nbre, table) => {
|
|
77
|
+
expect(onlineSales.listedItems.length).toBe(parseInt(nbre));
|
|
78
|
+
expect(onlineSales.listedItems.length).toBe(table.length);
|
|
79
|
+
|
|
80
|
+
table.forEach((row, index) => {
|
|
81
|
+
expect(onlineSales.listedItems).toContain(table[index].Object);
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
);
|
|
85
|
+
|
|
86
|
+
Fusion("../language.feature");
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
const { When, Then, And } = require("../../../../src");
|
|
2
|
+
|
|
3
|
+
And("I drop my mic", () => {
|
|
4
|
+
const micDropped = true;
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
module.exports = exports = (fnRocket) => {
|
|
8
|
+
When("I relaunch the rocket", () => {
|
|
9
|
+
const rocketUsed = fnRocket();
|
|
10
|
+
rocketUsed.launch();
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
Then("the rocket end up in space again", () => {
|
|
14
|
+
const rocketUsed = fnRocket();
|
|
15
|
+
expect(rocketUsed.isInSpace).toBe(true);
|
|
16
|
+
});
|
|
17
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
const { Given, Then, And, Fusion } = require("../../../../src");
|
|
2
|
+
|
|
3
|
+
const { Rocket } = require("../../../src/rocket");
|
|
4
|
+
|
|
5
|
+
let rocket;
|
|
6
|
+
function getCurrentRocket() {
|
|
7
|
+
return rocket;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
Given(/^I am Elon Musk and I launched a rocket in space already$/, () => {
|
|
11
|
+
rocket = new Rocket();
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
require("./reuse-code")(getCurrentRocket);
|
|
15
|
+
|
|
16
|
+
Then(
|
|
17
|
+
And(/^the mission was said to be '(.*)'$/, (sayingForTheMission) => {
|
|
18
|
+
expect(sayingForTheMission).toBeDefined();
|
|
19
|
+
})
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
Fusion("../reuse-definition.feature");
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
const { Given, When, Then, Fusion, Before } = require("../../../../src");
|
|
2
|
+
|
|
3
|
+
const { OnlineSales } = require("../../../src/online-sales");
|
|
4
|
+
|
|
5
|
+
const onlineSales = new OnlineSales();
|
|
6
|
+
|
|
7
|
+
Before(()=>{
|
|
8
|
+
if (onlineSales.nItems() >= 2) {
|
|
9
|
+
onlineSales.listedItems = [];
|
|
10
|
+
}
|
|
11
|
+
})
|
|
12
|
+
|
|
13
|
+
Given(/^I have (\d+) items for sale$/, (nItems) => {
|
|
14
|
+
expect(Number(nItems)).toBe(onlineSales.nItems());
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
When(/^I bought "(.+)"/, (item) => {
|
|
18
|
+
onlineSales.buyItem(item);
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
When(/^I bought the following items:$/, (table) => {
|
|
22
|
+
if (typeof table === "string") return;
|
|
23
|
+
|
|
24
|
+
table.forEach((row) => {
|
|
25
|
+
onlineSales.buyItem(row.Item)
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
Then(/^I have (\d+) items for sale$/, (nItems) => {
|
|
30
|
+
expect(Number(nItems)).toBe(onlineSales.nItems());
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
Then(/^I want to sell (\d+) items if they in list$/, (nItems, table) => {
|
|
34
|
+
if (typeof nItems !== "string") return;
|
|
35
|
+
if (typeof table === "string") return;
|
|
36
|
+
let iNumber = Number(nItems);
|
|
37
|
+
|
|
38
|
+
table.forEach((row) => {
|
|
39
|
+
if (iNumber > 0 && onlineSales.listedItems.includes(row.Item)) {
|
|
40
|
+
onlineSales.sellItem(row.Item);
|
|
41
|
+
iNumber--;
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
Fusion("../scenario-outline2.feature");
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
const { Before, Given, When, Then, Fusion } = require("../../../../src");
|
|
2
|
+
|
|
3
|
+
const { OnlineSales } = require("../../../src/online-sales");
|
|
4
|
+
|
|
5
|
+
let onlineSales;
|
|
6
|
+
let salesPrice;
|
|
7
|
+
|
|
8
|
+
Before(() => {
|
|
9
|
+
onlineSales = new OnlineSales();
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
Given(/^I have a\(n\) (.*)$/, (item) => {
|
|
13
|
+
onlineSales.listItem(item);
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
Given(
|
|
17
|
+
/^I have an Item named '<ThatCouldLookLikeAnOutlineVariable>'$/,
|
|
18
|
+
(item) => {
|
|
19
|
+
onlineSales.listItem("Autographed Neil deGrasse Tyson book");
|
|
20
|
+
}
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
When(/^I sell the (.*)$/, (item) => {
|
|
24
|
+
salesPrice = onlineSales.sellItem(item);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
When(/^I sell <ThatCouldLookLikeAnOutlineVariable With Spaces in it>$/, () => {
|
|
28
|
+
salesPrice = onlineSales.sellItem("Autographed Neil deGrasse Tyson book");
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
Then(/^I should get \$(\d+)$/, (expectedSalesPrice) => {
|
|
32
|
+
expect(salesPrice).toBe(parseInt(expectedSalesPrice));
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
Then(/^I get \$<Amount>$/, (expectedSalesPrice) => {
|
|
36
|
+
expect(salesPrice).toBe(parseInt(100));
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
Given(/^I want to sell all my (.*)$/, (item) => {
|
|
40
|
+
onlineSales.listItem(item);
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
When(
|
|
44
|
+
/^I sell all my (.*) at the price of \$(\d+) CAD$/,
|
|
45
|
+
(item, expectedSalesPrice) => {
|
|
46
|
+
salesPrice = onlineSales.sellItem(item);
|
|
47
|
+
if (salesPrice) salesPrice = parseInt(expectedSalesPrice);
|
|
48
|
+
}
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
When(
|
|
52
|
+
/^I sell all my (.*) with a starting price of \$(\d+) at the rebate price of \$(\d+)$/,
|
|
53
|
+
(item, startingPrice, expectedSalesPrice) => {
|
|
54
|
+
salesPrice = onlineSales.sellItem(item);
|
|
55
|
+
if (salesPrice) {
|
|
56
|
+
salesPrice = parseInt(expectedSalesPrice);
|
|
57
|
+
} else {
|
|
58
|
+
salesPrice = null;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
When(
|
|
64
|
+
/^I sell all my (.*) with a starting price of \$(\d+) at the fantastic price of (\d+)\$ USD which is nice$/,
|
|
65
|
+
(item, startingPrice, expectedSalesPrice) => {
|
|
66
|
+
salesPrice = onlineSales.sellItem(item);
|
|
67
|
+
if (salesPrice) {
|
|
68
|
+
salesPrice = parseInt(expectedSalesPrice);
|
|
69
|
+
} else {
|
|
70
|
+
salesPrice = null;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
When(
|
|
76
|
+
/^I sell all my (.*) with a starting price of \$(\d+) at the fantastic price of (\d+)\$ CAD which is nice$/,
|
|
77
|
+
(item, startingPrice, expectedSalesPrice) => {
|
|
78
|
+
salesPrice = onlineSales.sellItem(item);
|
|
79
|
+
if (salesPrice) {
|
|
80
|
+
salesPrice = parseInt(expectedSalesPrice);
|
|
81
|
+
} else {
|
|
82
|
+
salesPrice = null;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
);
|
|
86
|
+
|
|
87
|
+
When(
|
|
88
|
+
/^I sell all my (.*) with a starting price of \$(\d+) at the rebate price of (\d+)\$ CAD which is nice$/,
|
|
89
|
+
(item, startingPrice, expectedSalesPrice) => {
|
|
90
|
+
salesPrice = onlineSales.sellItem(item);
|
|
91
|
+
if (salesPrice) {
|
|
92
|
+
salesPrice = parseInt(expectedSalesPrice);
|
|
93
|
+
} else {
|
|
94
|
+
salesPrice = null;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
);
|
|
98
|
+
|
|
99
|
+
Then(/^I should still get \$(\d+)$/, (expectedSalesPrice) => {
|
|
100
|
+
expect(salesPrice).toBe(parseInt(expectedSalesPrice));
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
Then(
|
|
104
|
+
/^the (\d+)(?:th|d|nd|rd|st) item (\d+)(?:th|d|nd|rd|st) price has a price amount of (\d+) which is a '(\w*)'$/,
|
|
105
|
+
(indexItem, indexPrice, amountPrice, typePrice) => {
|
|
106
|
+
expect(salesPrice).toBe(parseInt(amountPrice));
|
|
107
|
+
}
|
|
108
|
+
);
|
|
109
|
+
|
|
110
|
+
Fusion("../scenario-outlines.feature");
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
const { Before, Given, When, Then, Fusion } = require("../../../../src");
|
|
2
|
+
|
|
3
|
+
const { BankAccount } = require("../../../src/bank-account");
|
|
4
|
+
|
|
5
|
+
let myAccounts;
|
|
6
|
+
|
|
7
|
+
Before(() => {
|
|
8
|
+
myAccounts = [];
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
Given(/^I open new account with '(.+)' name$/, (newAccountName) => {
|
|
12
|
+
myAccounts.push(new BankAccount());
|
|
13
|
+
myAccounts[myAccounts.length - 1].name = newAccountName;
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
Given(/^my account#(\d+) balance is \$(\d+)$/, (nAcc, balance) => {
|
|
17
|
+
myAccounts[nAcc - 1].deposit(parseInt(balance));
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
When(
|
|
21
|
+
/^I get paid \$(\d+) for writing some awesome code from my account#(\d+)$/,
|
|
22
|
+
(paycheck, nAcc) => {
|
|
23
|
+
myAccounts[nAcc - 1].deposit(parseInt(paycheck));
|
|
24
|
+
}
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
Then(
|
|
28
|
+
/^my account#(\d+) balance should be \$(\d+)$/,
|
|
29
|
+
(nAcc, expectedBalance) => {
|
|
30
|
+
expect(myAccounts[nAcc - 1].balance).toBe(parseInt(expectedBalance));
|
|
31
|
+
}
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
Then(/^I have (\d+) accounts$/, (nAccounts) => {
|
|
35
|
+
expect(myAccounts.length).toBe(parseInt(nAccounts));
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
Given(/^my account#(\d+) name is '(.*)'$/, (nAcc, nameAccount) => {
|
|
39
|
+
myAccounts[nAcc - 1].name = nameAccount;
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
When(
|
|
43
|
+
/^I get an new account#(\d+) name '(.*)' with a type (.*) from my old account named '(.*)'$/,
|
|
44
|
+
(nAcc, nameNewAccount, typeAccount, nameOldAccount) => {
|
|
45
|
+
myAccounts[nAcc - 1].name = nameNewAccount;
|
|
46
|
+
myAccounts[nAcc - 1].type = typeAccount;
|
|
47
|
+
}
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
Then(
|
|
51
|
+
/^my account#(\d+) name should be "(.*)" and have a type (.*)$/,
|
|
52
|
+
(nAcc, nameAccount, typeAccount) => {
|
|
53
|
+
expect(myAccounts[nAcc - 1].name).toBe(nameAccount);
|
|
54
|
+
expect(myAccounts[nAcc - 1].type).toBe(typeAccount);
|
|
55
|
+
}
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
Then(/^my account#(\d+) should be:$/, (nAcc, table) => {
|
|
59
|
+
if (typeof table === "string") return;
|
|
60
|
+
|
|
61
|
+
for (const [key, value] of Object.entries(myAccounts[nAcc - 1])) {
|
|
62
|
+
table.forEach((row) => {
|
|
63
|
+
if (row.field === key) {
|
|
64
|
+
expect(value.toString()).toBe(row.value);
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
Fusion("../using-dynamic-values.feature");
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
const { Before, After, Given, When, Then, Fusion } = require("../../../../src");
|
|
2
|
+
|
|
3
|
+
const { TodoList } = require("../../../src/todo-list");
|
|
4
|
+
|
|
5
|
+
let todoList;
|
|
6
|
+
|
|
7
|
+
Before(() => {
|
|
8
|
+
todoList = new TodoList();
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
Given("my todo list currently looks as follows:", (table) => {
|
|
12
|
+
table.forEach((row) => {
|
|
13
|
+
todoList.add({
|
|
14
|
+
name: row.TaskName,
|
|
15
|
+
priority: row.Priority,
|
|
16
|
+
});
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
When("I add the following task:", (table) => {
|
|
21
|
+
todoList.add({
|
|
22
|
+
name: table[0].TaskName,
|
|
23
|
+
priority: table[0].Priority,
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
Then(/^I should see the following (\d) todos in my list:$/, (nbre, table) => {
|
|
28
|
+
expect(todoList.items.length).toBe(parseInt(nbre));
|
|
29
|
+
expect(todoList.items.length).toBe(table.length);
|
|
30
|
+
|
|
31
|
+
table.forEach((row, index) => {
|
|
32
|
+
expect(todoList.items[index].name).toBe(table[index].TaskName);
|
|
33
|
+
expect(todoList.items[index].priority).toBe(table[index].Priority);
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
After(() => {
|
|
38
|
+
const emptyTodo = new TodoList();
|
|
39
|
+
emptyTodo.add({ name: "Empty on purpose", priority: "so low" });
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
Fusion("../using-gherkin-tables.feature");
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
Feature: Getting rich writing software
|
|
2
|
+
|
|
3
|
+
Scenario: Depositing a paycheck
|
|
4
|
+
Given I open new account with 'Cash' name
|
|
5
|
+
Given my account#1 balance is $10
|
|
6
|
+
When I get paid $1000000 for writing some awesome code from my account#1
|
|
7
|
+
Then my account#1 balance should be $1000010
|
|
8
|
+
|
|
9
|
+
Scenario: Testing simple inception
|
|
10
|
+
Given I open new account with 'Cash' name
|
|
11
|
+
Given my account#1 name is 'a'
|
|
12
|
+
When I get an new account#1 name 'name' with a type Test from my old account named 'a'
|
|
13
|
+
Then my account#1 name should be "name" and have a type Test
|
|
14
|
+
|
|
15
|
+
Scenario Outline: Using examples in step RegExp and step Table at the same time. <Description>
|
|
16
|
+
Given I open new account with 'Cash' name
|
|
17
|
+
Given I open new account with 'Deposit' name
|
|
18
|
+
|
|
19
|
+
Given my account#1 balance is $10000
|
|
20
|
+
Given my account#2 balance is $1234
|
|
21
|
+
|
|
22
|
+
Then I have <NAccounts> accounts
|
|
23
|
+
|
|
24
|
+
# Use test step with parameter in step RegExp and paramter in step Table
|
|
25
|
+
Then my account#<accN> should be:
|
|
26
|
+
| field | value |
|
|
27
|
+
| name | <Type> |
|
|
28
|
+
| balance | <balance> |
|
|
29
|
+
| type | Account |
|
|
30
|
+
|
|
31
|
+
Examples:
|
|
32
|
+
| NAccounts | accN | Type | balance | Description |
|
|
33
|
+
| 2 | 1 | Cash | 10000 | First Scenario |
|
|
34
|
+
| 2 | 2 | Deposit | 1234 | Second Scenario |
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
Feature: Todo List
|
|
2
|
+
|
|
3
|
+
Scenario: Adding an item to my todo list
|
|
4
|
+
Given my todo list currently looks as follows:
|
|
5
|
+
| TaskName | Priority |
|
|
6
|
+
| Fix bugs in my code | medium |
|
|
7
|
+
| Document my hours | medium |
|
|
8
|
+
When I add the following task:
|
|
9
|
+
| TaskName | Priority |
|
|
10
|
+
| Watch cat videos on YouTube all day | high |
|
|
11
|
+
| Document my hours | medium |
|
|
12
|
+
Then I should see the following 2 todos in my list:
|
|
13
|
+
| TaskName | Priority |
|
|
14
|
+
| Watch cat videos on YouTube all day | high |
|
|
15
|
+
| Sign up for unemployment | high |
|
|
16
|
+
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
class BankAccount {
|
|
2
|
+
constructor() {
|
|
3
|
+
this.balance = 0;
|
|
4
|
+
this.name = "";
|
|
5
|
+
this.type = "Account";
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
deposit(amount) {
|
|
9
|
+
this.balance += amount;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
withdraw(amount) {
|
|
13
|
+
this.balance -= amount;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
module.exports.BankAccount = BankAccount;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
const itemPrices = {
|
|
2
|
+
"Autographed Neil deGrasse Tyson book": 100,
|
|
3
|
+
"Rick Astley t-shirt": 22,
|
|
4
|
+
"An idea to replace EVERYTHING with blockchains": 0,
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
class OnlineSales {
|
|
8
|
+
constructor() {
|
|
9
|
+
this.listedItems = [];
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
nItems = () => this.listedItems.length;
|
|
13
|
+
|
|
14
|
+
listItem(name) {
|
|
15
|
+
this.listedItems.push(name);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
buyItem = (name) => this.listedItems.push(name);
|
|
19
|
+
|
|
20
|
+
sellItem(name) {
|
|
21
|
+
const itemIndex = this.listedItems.indexOf(name);
|
|
22
|
+
|
|
23
|
+
if (itemIndex !== -1) {
|
|
24
|
+
this.listedItems.splice(itemIndex, 1);
|
|
25
|
+
|
|
26
|
+
return itemPrices[name];
|
|
27
|
+
} else {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
module.exports.OnlineSales = OnlineSales;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
class TodoList {
|
|
2
|
+
constructor() {
|
|
3
|
+
this.items = [];
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
add(todo) {
|
|
7
|
+
if (todo.name.toLocaleLowerCase().indexOf("youtube")) {
|
|
8
|
+
this.items = [];
|
|
9
|
+
this.items.push(todo);
|
|
10
|
+
this.items.push({
|
|
11
|
+
name: "Sign up for unemployment",
|
|
12
|
+
priority: "high",
|
|
13
|
+
});
|
|
14
|
+
} else {
|
|
15
|
+
this.items.push(todo);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
module.exports.TodoList = TodoList;
|