@supertape/operator-stub 3.0.0 → 4.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/README.md CHANGED
@@ -22,9 +22,7 @@ Adds next operators to work with:
22
22
  ### t.calledWith(fn, args [, message])
23
23
 
24
24
  ```js
25
- import test, {
26
- stub,
27
- } from 'supertape';
25
+ import test, {stub} from 'supertape';
28
26
 
29
27
  test('function call', (t) => {
30
28
  const fn = stub();
@@ -39,9 +37,7 @@ test('function call', (t) => {
39
37
  ### t.calledWithNoArgs(fn[, message])
40
38
 
41
39
  ```js
42
- import test, {
43
- stub,
44
- } from 'supertape';
40
+ import test, {stub} from 'supertape';
45
41
 
46
42
  test('function called with no args', (t) => {
47
43
  const fn = stub();
@@ -56,9 +52,7 @@ test('function called with no args', (t) => {
56
52
  ### t.calledCount(fn, count[, message])
57
53
 
58
54
  ```js
59
- import test, {
60
- stub,
61
- } from 'supertape';
55
+ import test, {stub} from 'supertape';
62
56
 
63
57
  test('function called count', (t) => {
64
58
  const fn = stub();
@@ -74,9 +68,7 @@ test('function called count', (t) => {
74
68
  ### t.calledOnce(fn [, message])
75
69
 
76
70
  ```js
77
- import test, {
78
- stub,
79
- } from 'supertape';
71
+ import test, {stub} from 'supertape';
80
72
 
81
73
  test('function called once', (t) => {
82
74
  const fn = stub();
@@ -91,9 +83,7 @@ test('function called once', (t) => {
91
83
  ### t.calledTwice(fn, count[, message])
92
84
 
93
85
  ```js
94
- import test, {
95
- stub,
96
- } from 'supertape';
86
+ import test, {stub} from 'supertape';
97
87
 
98
88
  test('function called twice', (t) => {
99
89
  const fn = stub();
@@ -109,9 +99,7 @@ test('function called twice', (t) => {
109
99
  ### t.calledWithNew(fn, count[, message])
110
100
 
111
101
  ```js
112
- import test, {
113
- stub,
114
- } from 'supertape';
102
+ import test, {stub} from 'supertape';
115
103
 
116
104
  test('function called with new', (t) => {
117
105
  const fn = stub();
@@ -129,9 +117,7 @@ Check that `fn1` called before `fn2`.
129
117
  Do not forget to set names of stubs.
130
118
 
131
119
  ```js
132
- import test, {
133
- stub,
134
- } from 'supertape';
120
+ import test, {stub} from 'supertape';
135
121
 
136
122
  test('function called with new', (t) => {
137
123
  const init = stub().withName('init');
@@ -151,9 +137,7 @@ Check that `fn1` called after `fn2`.
151
137
  Do not forget to set names of stubs.
152
138
 
153
139
  ```js
154
- import test, {
155
- stub,
156
- } from 'supertape';
140
+ import test, {stub} from 'supertape';
157
141
 
158
142
  test('function called with new', (t) => {
159
143
  const init = stub().withName('init');
@@ -173,9 +157,7 @@ Check that array of stubs `fns` called in order;
173
157
  Do not forget to set names of stubs.
174
158
 
175
159
  ```js
176
- import test, {
177
- stub,
178
- } from 'supertape';
160
+ import test, {stub} from 'supertape';
179
161
 
180
162
  test('function called with new', (t) => {
181
163
  const init = stub().withName('init');
package/lib/stub.d.ts CHANGED
@@ -1,16 +1,16 @@
1
1
  import {Stub} from '@cloudcmd/stub';
2
2
 
3
3
  type OperationResult = {
4
- is: boolean,
5
- expected: unknown,
6
- actual: unknown,
7
- message: string,
4
+ is: boolean;
5
+ expected: unknown;
6
+ actual: unknown;
7
+ message: string;
8
8
  };
9
- export function stub(arg?: unknown): Stub;
10
9
 
10
+ export function stub(arg?: unknown): Stub;
11
11
  export interface OperatorStub {
12
- called: (fn: Stub, message?: string) => OperationResult
13
- notCalled: (fn: Stub, message?: string) => OperationResult
12
+ called: (fn: Stub, message?: string) => OperationResult;
13
+ notCalled: (fn: Stub, message?: string) => OperationResult;
14
14
  calledWith: (fn: Stub, args: unknown[], message?: string) => OperationResult;
15
15
  calledWithNoArgs: (fn: Stub, message?: string) => OperationResult;
16
16
  calledCount: (fn: Stub, count: number, message?: string) => OperationResult;
@@ -21,4 +21,3 @@ export interface OperatorStub {
21
21
  calledAfter: (fn1: Stub, fn2: Stub, message?: string) => OperationResult;
22
22
  calledInOrder: (fns: Stub[], message?: string) => OperationResult;
23
23
  }
24
-
package/lib/stub.js CHANGED
@@ -36,8 +36,7 @@ export const calledWith = (operator) => (fn, args, message = `should be called w
36
36
  if (!isArray(args))
37
37
  return operator.fail(`Expected 'args' to be 'array' but received: ${stringify(args)}`);
38
38
 
39
- const {length} = fn.args;
40
- const calledArgs = fn.args[length - 1];
39
+ const calledArgs = fn.args.at(-1);
41
40
 
42
41
  return operator.deepEqual(calledArgs, args, message);
43
42
  };
@@ -52,8 +51,7 @@ export const calledWithNoArgs = (operator) => (fn, message = 'should be called w
52
51
  if (!isString(message))
53
52
  return operator.fail(`'t.calledWithNoArgs' expects message to be string, but received: '${stringify(message)}', looks like you need 't.calledWith'`);
54
53
 
55
- const {length} = fn.args;
56
- const calledArgs = fn.args[length - 1];
54
+ const calledArgs = fn.args.at(-1);
57
55
 
58
56
  return operator.deepEqual(calledArgs, [], message);
59
57
  };
@@ -126,6 +124,7 @@ export const calledInOrder = (operator) => (fns, message = 'should call in order
126
124
 
127
125
  let failMessage = '';
128
126
  const fail = (message) => failMessage = message;
127
+
129
128
  const ok = (result, message) => {
130
129
  if (!result)
131
130
  failMessage = message;
@@ -148,4 +147,3 @@ export const calledInOrder = (operator) => (fns, message = 'should call in order
148
147
 
149
148
  return operator.pass(message);
150
149
  };
151
-
package/package.json CHANGED
@@ -1,18 +1,17 @@
1
1
  {
2
2
  "name": "@supertape/operator-stub",
3
- "version": "3.0.0",
3
+ "version": "4.0.0",
4
4
  "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
5
5
  "description": "supertape stub operator",
6
6
  "homepage": "http://github.com/coderaiser/supertape",
7
7
  "main": "./lib/stub.js",
8
- "commitType": "colon",
9
8
  "release": false,
10
9
  "tag": false,
11
10
  "changelog": false,
12
11
  "type": "module",
13
12
  "repository": {
14
13
  "type": "git",
15
- "url": "git://github.com/coderaiser/supertape.git"
14
+ "url": "git+https://github.com/coderaiser/supertape.git"
16
15
  },
17
16
  "scripts": {
18
17
  "test": "madrun test",
@@ -27,7 +26,7 @@
27
26
  "wisdom": "madrun wisdom"
28
27
  },
29
28
  "dependencies": {
30
- "@cloudcmd/stub": "^4.0.0"
29
+ "@cloudcmd/stub": "^5.0.0"
31
30
  },
32
31
  "keywords": [
33
32
  "operator",
@@ -38,22 +37,20 @@
38
37
  "testing"
39
38
  ],
40
39
  "devDependencies": {
41
- "@babel/core": "^7.12.9",
42
- "c8": "^7.3.5",
43
- "check-dts": "^0.6.5",
44
- "eslint": "^8.0.0-beta.0",
45
- "eslint-plugin-n": "^15.2.5",
46
- "eslint-plugin-putout": "^16.0.1",
47
- "madrun": "^9.0.0",
40
+ "c8": "^10.1.2",
41
+ "check-dts": "^0.9.0",
42
+ "eslint": "^9.1.1",
43
+ "eslint-plugin-putout": "^29.0.2",
44
+ "madrun": "^12.1.0",
48
45
  "mock-require": "^3.0.2",
49
- "nodemon": "^2.0.2",
50
- "putout": "^27.2.0",
51
- "supertape": "^8.0.0",
52
- "typescript": "^4.4.4"
46
+ "nodemon": "^3.0.1",
47
+ "putout": "^41.0.2",
48
+ "supertape": "^12.0.0",
49
+ "typescript": "^5.1.6"
53
50
  },
54
51
  "license": "MIT",
55
52
  "engines": {
56
- "node": ">=16"
53
+ "node": ">=22"
57
54
  },
58
55
  "publishConfig": {
59
56
  "access": "public"