Skip to content

Commit f8cb91c

Browse files
authored
Merge pull request #406 from ccheraa/tests-rewrite
added mocha for unit tests
2 parents 71e6a96 + ac20429 commit f8cb91c

File tree

5 files changed

+333
-51
lines changed

5 files changed

+333
-51
lines changed

.mocharc.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
require: 'ts-node/register'
2+
spec: 'tests'
3+
extension: 'ts'

package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,13 @@
1818
},
1919
"devDependencies": {
2020
"@4tw/cypress-drag-drop": "https://github.com/ccheraa/cypress-drag-drop",
21+
"chai": "^4.3.4",
2122
"cypress": "7.3.0",
2223
"lerna": "4.0.0",
23-
"node-sass": "5.0.0"
24+
"mocha": "^8.4.0",
25+
"node-sass": "5.0.0",
26+
"sinon": "^10.0.0",
27+
"ts-node": "^9.1.1"
2428
},
2529
"resolutions": {
2630
"node-gyp": "^7.0.0"

tests/obj.spec.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { expect } from "chai";
2+
import { ObjectClass } from "./obj";
3+
4+
describe('test Object test', () => {
5+
let obj: ObjectClass;
6+
before(() => {
7+
obj = new ObjectClass(5);
8+
});
9+
it('Should exist', () => {
10+
expect(obj).exist;
11+
});
12+
it('Should multiplay correctly', () => {
13+
const result = obj.multiply(4);
14+
expect(result).to.equals(20);
15+
});
16+
});

tests/obj.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
export class ObjectClass {
2+
constructor(private multiplier = 1) {}
3+
multiply(value: number): number {
4+
return value * this.multiplier;
5+
}
6+
}

0 commit comments

Comments
 (0)