@sequencemedia/sinon-chai 0.0.5 → 0.0.6
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/lib/sinon-chai.cjs +9 -9
- package/lib/sinon-chai.d.cts +2 -0
- package/lib/sinon-chai.d.cts.map +1 -0
- package/package.json +12 -4
- package/tsconfig.json +17 -0
package/lib/sinon-chai.cjs
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
module.exports = sinonChai
|
|
11
11
|
} else if (typeof define === 'function' && define.amd) {
|
|
12
12
|
// AMD
|
|
13
|
-
define(
|
|
13
|
+
define(() => {
|
|
14
14
|
return sinonChai
|
|
15
15
|
})
|
|
16
16
|
} else {
|
|
@@ -66,17 +66,17 @@
|
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
return {
|
|
69
|
-
affirmative
|
|
69
|
+
affirmative () {
|
|
70
70
|
return printfArray([`expected %n to ${verbPhrase}${action}${nonNegatedSuffix}`].concat(args))
|
|
71
71
|
},
|
|
72
|
-
negative
|
|
72
|
+
negative () {
|
|
73
73
|
return printfArray([`expected %n to not ${verbPhrase}${action}`].concat(args))
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
77
|
|
|
78
78
|
function sinonProperty (name, action, nonNegatedSuffix) {
|
|
79
|
-
utils.addProperty(chai.Assertion.prototype, name, function () {
|
|
79
|
+
utils.addProperty(chai.Assertion.prototype, name, function handler () {
|
|
80
80
|
assertCanWorkWith(this)
|
|
81
81
|
|
|
82
82
|
const messages = getMessages(this._obj, action, nonNegatedSuffix, false)
|
|
@@ -85,7 +85,7 @@
|
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
function sinonPropertyAsBooleanMethod (name, action, nonNegatedSuffix) {
|
|
88
|
-
utils.addMethod(chai.Assertion.prototype, name, function (arg) {
|
|
88
|
+
utils.addMethod(chai.Assertion.prototype, name, function handler (arg) {
|
|
89
89
|
assertCanWorkWith(this)
|
|
90
90
|
|
|
91
91
|
const messages = getMessages(this._obj, action, nonNegatedSuffix, false, [timesInWords(arg)])
|
|
@@ -94,16 +94,16 @@
|
|
|
94
94
|
}
|
|
95
95
|
|
|
96
96
|
function createSinonMethodHandler (sinonName, action, nonNegatedSuffix) {
|
|
97
|
-
return function () {
|
|
97
|
+
return function sinonMethodHandler (...args) {
|
|
98
98
|
assertCanWorkWith(this)
|
|
99
99
|
|
|
100
100
|
const alwaysSinonMethod = 'always' + sinonName[0].toUpperCase() + sinonName.substring(1)
|
|
101
101
|
const shouldBeAlways = utils.flag(this, 'always') && typeof this._obj[alwaysSinonMethod] === 'function'
|
|
102
102
|
const sinonMethodName = shouldBeAlways ? alwaysSinonMethod : sinonName
|
|
103
103
|
|
|
104
|
-
const messages = getMessages(this._obj, action, nonNegatedSuffix, shouldBeAlways, slice.call(
|
|
104
|
+
const messages = getMessages(this._obj, action, nonNegatedSuffix, shouldBeAlways, slice.call(args))
|
|
105
105
|
this.assert(
|
|
106
|
-
this._obj[sinonMethodName].apply(this._obj,
|
|
106
|
+
this._obj[sinonMethodName].apply(this._obj, args),
|
|
107
107
|
messages.affirmative,
|
|
108
108
|
messages.negative
|
|
109
109
|
)
|
|
@@ -124,7 +124,7 @@
|
|
|
124
124
|
exceptionalSinonMethod(name, name, action, nonNegatedSuffix)
|
|
125
125
|
}
|
|
126
126
|
|
|
127
|
-
utils.addProperty(chai.Assertion.prototype, 'always', function () {
|
|
127
|
+
utils.addProperty(chai.Assertion.prototype, 'always', function always () {
|
|
128
128
|
utils.flag(this, 'always', true)
|
|
129
129
|
})
|
|
130
130
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sinon-chai.d.cts","sourceRoot":"","sources":["sinon-chai.cjs"],"names":[],"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sequencemedia/sinon-chai",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.6",
|
|
4
4
|
"description": "Extends Chai with assertions for the Sinon.JS mocking framework.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"chai",
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
],
|
|
17
17
|
"main": "./lib/sinon-chai.cjs",
|
|
18
18
|
"type": "module",
|
|
19
|
+
"types": "./lib/sinon-chai.d.cts",
|
|
19
20
|
"author": {
|
|
20
21
|
"name": "Jonathan Perry for Sequence Media Limited",
|
|
21
22
|
"email": "sequencemedia@sequencemedia.net",
|
|
@@ -28,6 +29,7 @@
|
|
|
28
29
|
"license": "(BSD-2-Clause OR WTFPL)",
|
|
29
30
|
"repository": "sequencemedia/sinon-chai",
|
|
30
31
|
"scripts": {
|
|
32
|
+
"types": "tsc",
|
|
31
33
|
"test": "mocha",
|
|
32
34
|
"lint": "eslint . --ext .mjs,.cjs",
|
|
33
35
|
"lint:fix": "npm run lint -- --fix",
|
|
@@ -37,12 +39,18 @@
|
|
|
37
39
|
"@babel/core": "^7.23.7",
|
|
38
40
|
"@babel/eslint-parser": "^7.23.3",
|
|
39
41
|
"@babel/preset-env": "^7.23.7",
|
|
42
|
+
"c8": "^9.0.0",
|
|
43
|
+
"chai": "^5.0.0",
|
|
40
44
|
"core-js": "^3.35.0",
|
|
41
45
|
"eslint": "^8.56.0",
|
|
42
46
|
"eslint-config-standard": "^17.1.0",
|
|
43
|
-
"c8": "^9.0.0",
|
|
44
|
-
"chai": "^5.0.0",
|
|
45
47
|
"mocha": "^10.2.0",
|
|
46
|
-
"sinon": "^17.0.1"
|
|
48
|
+
"sinon": "^17.0.1",
|
|
49
|
+
"typescript": "^5.3.3"
|
|
50
|
+
},
|
|
51
|
+
"peerDependencies": {
|
|
52
|
+
"chai": ">=5.0.0",
|
|
53
|
+
"mocha": ">=10.2.0",
|
|
54
|
+
"sinon": ">=17.0.0"
|
|
47
55
|
}
|
|
48
56
|
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
// Change this to match your project
|
|
3
|
+
"include": ["lib"],
|
|
4
|
+
"compilerOptions": {
|
|
5
|
+
// Tells TypeScript to read JS files, as
|
|
6
|
+
// normally they are ignored as source files
|
|
7
|
+
"allowJs": true,
|
|
8
|
+
// Generate d.ts files
|
|
9
|
+
"declaration": true,
|
|
10
|
+
// This compiler run should
|
|
11
|
+
// only output d.ts files
|
|
12
|
+
"emitDeclarationOnly": true,
|
|
13
|
+
// go to js file when using IDE functions like
|
|
14
|
+
// "Go to Definition" in VSCode
|
|
15
|
+
"declarationMap": true
|
|
16
|
+
}
|
|
17
|
+
}
|