Skip to content

Commit eeacc92

Browse files
committed
test: convert to jest expect
1 parent 41da9b1 commit eeacc92

18 files changed

+969
-1234
lines changed

package.json

-11
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,6 @@
7979
"babel-jest": "^27.2.5",
8080
"babel-plugin-transform-rename-import": "^2.3.0",
8181
"babel-preset-jason": "^6.3.0",
82-
"benchmark": "^2.1.4",
83-
"chai": "^4.3.4",
84-
"chai-as-promised": "^7.1.1",
85-
"dirty-chai": "^2.0.1",
8682
"doctoc": "^2.0.1",
8783
"eslint": "^7.12.0",
8884
"eslint-config-jason": "^8.1.1",
@@ -102,20 +98,13 @@
10298
"rollup-plugin-filesize": "^9.1.1",
10399
"rollup-plugin-node-resolve": "^5.2.0",
104100
"rollup-plugin-size-snapshot": "^0.12.0",
105-
"sinon": "^11.1.2",
106-
"sinon-chai": "^3.7.0",
107101
"synchronous-promise": "^2.0.15",
108102
"typescript": "^4.4.3"
109103
},
110104
"dependencies": {
111-
"@babel/runtime": "^7.15.4",
112-
"@types/lodash": "^4.14.175",
113105
"nanoclone": "^0.2.1",
114106
"property-expr": "^2.0.4",
115107
"tiny-case": "^1.0.2",
116108
"toposort": "^2.0.2"
117-
},
118-
"engines": {
119-
"node": ">=10"
120109
}
121110
}

test-setup.js

+11-11
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
const { SynchronousPromise } = require('synchronous-promise');
22

3-
global.chai = require('chai');
3+
// global.chai = require('chai');
44
global.sinon = require('sinon');
55

6-
global.chai.use(require('sinon-chai'));
7-
global.chai.use(require('chai-as-promised'));
8-
global.chai.use(require('dirty-chai'));
6+
// global.chai.use(require('sinon-chai'));
7+
// global.chai.use(require('chai-as-promised'));
8+
// global.chai.use(require('dirty-chai'));
99

10-
global.expect = global.chai.expect;
11-
global.chai.should();
10+
// global.expect = global.chai.expect;
11+
// global.chai.should();
1212

1313
// WTF???
14-
Object.defineProperty(
15-
Promise.prototype,
16-
'should',
17-
Object.getOwnPropertyDescriptor(Object.prototype, 'should'),
18-
);
14+
// Object.defineProperty(
15+
// Promise.prototype,
16+
// 'should',
17+
// Object.getOwnPropertyDescriptor(Object.prototype, 'should'),
18+
// );
1919

2020
global.TestHelpers = require('./test/helpers');
2121

test/ValidationError.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -6,47 +6,47 @@ describe('ValidationError', function () {
66
const str = ValidationError.formatError('Some message ${param}', {
77
param: 'here',
88
});
9-
str.should.contain('here');
9+
expect(str).toContain('here');
1010
});
1111

1212
it(`should auto include any param named 'label' or 'path' as the 'path' param`, function () {
1313
const str = ValidationError.formatError('${path} goes here', {
1414
label: 'label',
1515
});
16-
str.should.contain('label');
16+
expect(str).toContain('label');
1717
});
1818

1919
it(`should use 'this' if a 'label' or 'path' param is not provided`, function () {
2020
const str = ValidationError.formatError('${path} goes here', {});
21-
str.should.contain('this');
21+
expect(str).toContain('this');
2222
});
2323

2424
it(`should include "undefined" in the message if undefined is provided as a param`, function () {
2525
const str = ValidationError.formatError('${path} value is ${min}', {
2626
min: undefined,
2727
});
28-
str.should.contain('undefined');
28+
expect(str).toContain('undefined');
2929
});
3030

3131
it(`should include "null" in the message if null is provided as a param`, function () {
3232
const str = ValidationError.formatError('${path} value is ${min}', {
3333
min: null,
3434
});
35-
str.should.contain('null');
35+
expect(str).toContain('null');
3636
});
3737

3838
it(`should include "NaN" in the message if null is provided as a param`, function () {
3939
const str = ValidationError.formatError('${path} value is ${min}', {
4040
min: NaN,
4141
});
42-
str.should.contain('NaN');
42+
expect(str).toContain('NaN');
4343
});
4444

4545
it(`should include 0 in the message if 0 is provided as a param`, function () {
4646
const str = ValidationError.formatError('${path} value is ${min}', {
4747
min: 0,
4848
});
49-
str.should.contain('0');
49+
expect(str).toContain('0');
5050
});
5151
});
5252
});

0 commit comments

Comments
 (0)