Skip to content

Commit f078caa

Browse files
committed
fix: runner tests
1 parent 4d84e8f commit f078caa

File tree

4 files changed

+36
-26
lines changed

4 files changed

+36
-26
lines changed

lib/command/generate.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import colors from 'chalk'
22
import fs from 'fs'
33
import inquirer from 'inquirer'
4-
import mkdirp from 'mkdirp'
4+
import { mkdirp } from 'mkdirp'
55
import path from 'path'
66
import { fileExists, ucfirst, lcfirst, beautify } from '../utils.js'
77
import output from '../output.js'

lib/command/init.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import colors from 'chalk'
22
import fs from 'fs'
33
import inquirer from 'inquirer'
4-
import mkdirp from 'mkdirp'
4+
import { mkdirp } from 'mkdirp'
55
import path from 'path'
66
import { inspect } from 'util'
77
import spawn from 'cross-spawn'
Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,28 @@
1+
import HelperModule from '../../../../../lib/helper.js'
2+
const Helper = HelperModule.default || HelperModule
3+
14
class CustomHelper extends Helper {
25
_beforeSuite() {
3-
this.i = 0;
6+
this.i = 0
47
}
58

69
_before() {
7-
this.i = 0;
10+
this.i = 0
811
}
912

1013
async failIfNotWorks() {
1114
return new Promise((resolve, reject) => {
12-
this.i++;
13-
console.log('check if i <3', this.i);
15+
if (typeof this.i !== 'number') {
16+
this.i = 0
17+
}
18+
this.i++
19+
console.log('check if i <3', this.i)
1420
setTimeout(() => {
15-
if (this.i >= 3) resolve();
16-
reject(new Error('not works'));
17-
}, 0);
18-
});
21+
if (this.i >= 3) resolve()
22+
reject(new Error('not works'))
23+
}, 0)
24+
})
1925
}
2026
}
2127

22-
module.exports = CustomHelper;
28+
export default CustomHelper
Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,50 @@
1-
import assert from 'assert';
2-
import helperModule from '../../../../lib/helper.js';
3-
const Helper = helperModule.default || helperModule;
1+
import assert from 'assert'
2+
import helperModule from '../../../../lib/helper.js'
3+
const Helper = helperModule.default || helperModule
44

55
class CheckoutHelper extends Helper {
66
_before() {
7-
this.num = 0;
8-
this.sum = 0;
9-
this.discountCalc = null;
7+
this.num = 0
8+
this.sum = 0
9+
this.discountCalc = null
1010
}
1111

1212
addItem(price) {
13-
this.num++;
14-
this.sum += price;
13+
if (typeof this.num !== 'number') this.num = 0
14+
if (typeof this.sum !== 'number') this.sum = 0
15+
this.num++
16+
this.sum += price
1517
}
1618

1719
seeNum(num) {
18-
assert.equal(num, this.num);
20+
if (typeof this.num !== 'number') this.num = 0
21+
assert.equal(num, this.num)
1922
}
2023

2124
seeSum(sum) {
22-
assert.equal(sum, this.sum);
25+
if (typeof this.sum !== 'number') this.sum = 0
26+
assert.equal(sum, this.sum)
2327
}
2428

2529
haveDiscountForPrice(price, discount) {
2630
this.discountCalc = () => {
2731
if (this.sum > price) {
28-
this.sum -= this.sum * discount / 100;
32+
this.sum -= (this.sum * discount) / 100
2933
}
30-
};
34+
}
3135
}
3236

3337
addProduct(name, price) {
34-
this.sum += price;
38+
this.sum += price
3539
}
3640

3741
checkout() {
3842
if (this.discountCalc) {
39-
this.discountCalc();
43+
this.discountCalc()
4044
}
4145
}
4246

4347
login() {}
4448
}
4549

46-
export default CheckoutHelper;
50+
export default CheckoutHelper

0 commit comments

Comments
 (0)