@khanacademy/wonder-blocks-testing 8.0.5 → 8.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/CHANGELOG.md +8 -0
- package/dist/es/index.js +24 -160
- package/dist/index.js +24 -160
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
package/dist/es/index.js
CHANGED
|
@@ -7,7 +7,7 @@ const fixtures = Component => {
|
|
|
7
7
|
const templateMap = new WeakMap();
|
|
8
8
|
let storyNumber = 1;
|
|
9
9
|
const getPropsOptions = {
|
|
10
|
-
log: (message, ...args) => action(message)
|
|
10
|
+
log: (message, ...args) => action(message)(...args),
|
|
11
11
|
logHandler: action
|
|
12
12
|
};
|
|
13
13
|
const makeStory = (description, props, wrapper = null) => {
|
|
@@ -56,12 +56,12 @@ const mockRequester = (operationMatcher, operationToString) => {
|
|
|
56
56
|
if (mock.onceOnly && mock.used) {
|
|
57
57
|
continue;
|
|
58
58
|
}
|
|
59
|
-
if (operationMatcher
|
|
59
|
+
if (operationMatcher(mock.operation, ...args)) {
|
|
60
60
|
mock.used = true;
|
|
61
61
|
return mock.response();
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
|
-
const operation = operationToString
|
|
64
|
+
const operation = operationToString(...args);
|
|
65
65
|
return Promise.reject(new Error(`No matching mock response found for request:
|
|
66
66
|
${operation}`));
|
|
67
67
|
};
|
|
@@ -215,177 +215,41 @@ const makeMockResponse = response => {
|
|
|
215
215
|
}
|
|
216
216
|
};
|
|
217
217
|
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
return typeof obj;
|
|
223
|
-
} : function (obj) {
|
|
224
|
-
return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
|
225
|
-
}, _typeof(obj);
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
function _toPrimitive(input, hint) {
|
|
229
|
-
if (_typeof(input) !== "object" || input === null) return input;
|
|
230
|
-
var prim = input[Symbol.toPrimitive];
|
|
231
|
-
if (prim !== undefined) {
|
|
232
|
-
var res = prim.call(input, hint || "default");
|
|
233
|
-
if (_typeof(res) !== "object") return res;
|
|
234
|
-
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
235
|
-
}
|
|
236
|
-
return (hint === "string" ? String : Number)(input);
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
function _toPropertyKey(arg) {
|
|
240
|
-
var key = _toPrimitive(arg, "string");
|
|
241
|
-
return _typeof(key) === "symbol" ? key : String(key);
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
function _defineProperties(target, props) {
|
|
245
|
-
for (var i = 0; i < props.length; i++) {
|
|
246
|
-
var descriptor = props[i];
|
|
247
|
-
descriptor.enumerable = descriptor.enumerable || false;
|
|
248
|
-
descriptor.configurable = true;
|
|
249
|
-
if ("value" in descriptor) descriptor.writable = true;
|
|
250
|
-
Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
function _createClass(Constructor, protoProps, staticProps) {
|
|
254
|
-
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
255
|
-
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
256
|
-
Object.defineProperty(Constructor, "prototype", {
|
|
257
|
-
writable: false
|
|
258
|
-
});
|
|
259
|
-
return Constructor;
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
function _setPrototypeOf(o, p) {
|
|
263
|
-
_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
|
|
264
|
-
o.__proto__ = p;
|
|
265
|
-
return o;
|
|
266
|
-
};
|
|
267
|
-
return _setPrototypeOf(o, p);
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
function _inheritsLoose(subClass, superClass) {
|
|
271
|
-
subClass.prototype = Object.create(superClass.prototype);
|
|
272
|
-
subClass.prototype.constructor = subClass;
|
|
273
|
-
_setPrototypeOf(subClass, superClass);
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
function _getPrototypeOf(o) {
|
|
277
|
-
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) {
|
|
278
|
-
return o.__proto__ || Object.getPrototypeOf(o);
|
|
279
|
-
};
|
|
280
|
-
return _getPrototypeOf(o);
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
function _isNativeFunction(fn) {
|
|
284
|
-
return Function.toString.call(fn).indexOf("[native code]") !== -1;
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
function _isNativeReflectConstruct() {
|
|
288
|
-
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
289
|
-
if (Reflect.construct.sham) return false;
|
|
290
|
-
if (typeof Proxy === "function") return true;
|
|
291
|
-
try {
|
|
292
|
-
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
|
293
|
-
return true;
|
|
294
|
-
} catch (e) {
|
|
295
|
-
return false;
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
function _construct(Parent, args, Class) {
|
|
300
|
-
if (_isNativeReflectConstruct()) {
|
|
301
|
-
_construct = Reflect.construct.bind();
|
|
302
|
-
} else {
|
|
303
|
-
_construct = function _construct(Parent, args, Class) {
|
|
304
|
-
var a = [null];
|
|
305
|
-
a.push.apply(a, args);
|
|
306
|
-
var Constructor = Function.bind.apply(Parent, a);
|
|
307
|
-
var instance = new Constructor();
|
|
308
|
-
if (Class) _setPrototypeOf(instance, Class.prototype);
|
|
309
|
-
return instance;
|
|
310
|
-
};
|
|
311
|
-
}
|
|
312
|
-
return _construct.apply(null, arguments);
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
function _wrapNativeSuper(Class) {
|
|
316
|
-
var _cache = typeof Map === "function" ? new Map() : undefined;
|
|
317
|
-
_wrapNativeSuper = function _wrapNativeSuper(Class) {
|
|
318
|
-
if (Class === null || !_isNativeFunction(Class)) return Class;
|
|
319
|
-
if (typeof Class !== "function") {
|
|
320
|
-
throw new TypeError("Super expression must either be null or a function");
|
|
321
|
-
}
|
|
322
|
-
if (typeof _cache !== "undefined") {
|
|
323
|
-
if (_cache.has(Class)) return _cache.get(Class);
|
|
324
|
-
_cache.set(Class, Wrapper);
|
|
325
|
-
}
|
|
326
|
-
function Wrapper() {
|
|
327
|
-
return _construct(Class, arguments, _getPrototypeOf(this).constructor);
|
|
328
|
-
}
|
|
329
|
-
Wrapper.prototype = Object.create(Class.prototype, {
|
|
330
|
-
constructor: {
|
|
331
|
-
value: Wrapper,
|
|
332
|
-
enumerable: false,
|
|
333
|
-
writable: true,
|
|
334
|
-
configurable: true
|
|
335
|
-
}
|
|
336
|
-
});
|
|
337
|
-
return _setPrototypeOf(Wrapper, Class);
|
|
338
|
-
};
|
|
339
|
-
return _wrapNativeSuper(Class);
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
let SettleSignal = function (_EventTarget) {
|
|
343
|
-
_inheritsLoose(SettleSignal, _EventTarget);
|
|
344
|
-
function SettleSignal(setSettleFn = null) {
|
|
345
|
-
var _this;
|
|
346
|
-
_this = _EventTarget.call(this) || this;
|
|
347
|
-
_this._settled = false;
|
|
218
|
+
class SettleSignal extends EventTarget {
|
|
219
|
+
constructor(setSettleFn = null) {
|
|
220
|
+
super();
|
|
221
|
+
this._settled = false;
|
|
348
222
|
setSettleFn == null ? void 0 : setSettleFn(() => {
|
|
349
|
-
if (
|
|
223
|
+
if (this._settled) {
|
|
350
224
|
throw new Error("SettleSignal already settled");
|
|
351
225
|
}
|
|
352
|
-
|
|
353
|
-
|
|
226
|
+
this._settled = true;
|
|
227
|
+
this.dispatchEvent(new Event("settled"));
|
|
354
228
|
});
|
|
355
|
-
return _this;
|
|
356
229
|
}
|
|
357
|
-
|
|
230
|
+
static settle() {
|
|
358
231
|
const signal = new SettleSignal();
|
|
359
232
|
signal._settled = true;
|
|
360
233
|
return signal;
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
}
|
|
367
|
-
}]);
|
|
368
|
-
return SettleSignal;
|
|
369
|
-
}(_wrapNativeSuper(EventTarget));
|
|
234
|
+
}
|
|
235
|
+
get settled() {
|
|
236
|
+
return this._settled;
|
|
237
|
+
}
|
|
238
|
+
}
|
|
370
239
|
|
|
371
|
-
|
|
372
|
-
|
|
240
|
+
class SettleController {
|
|
241
|
+
constructor() {
|
|
373
242
|
this._settleFn = void 0;
|
|
374
243
|
this._signal = void 0;
|
|
375
244
|
this._signal = new SettleSignal(settleFn => this._settleFn = settleFn);
|
|
376
245
|
}
|
|
377
|
-
|
|
378
|
-
|
|
246
|
+
get signal() {
|
|
247
|
+
return this._signal;
|
|
248
|
+
}
|
|
249
|
+
settle() {
|
|
379
250
|
this._settleFn();
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
key: "signal",
|
|
383
|
-
get: function () {
|
|
384
|
-
return this._signal;
|
|
385
|
-
}
|
|
386
|
-
}]);
|
|
387
|
-
return SettleController;
|
|
388
|
-
}();
|
|
251
|
+
}
|
|
252
|
+
}
|
|
389
253
|
|
|
390
254
|
const defaultConfig$3 = null;
|
|
391
255
|
const normalizeConfig = config => {
|
package/dist/index.js
CHANGED
|
@@ -31,7 +31,7 @@ const fixtures = Component => {
|
|
|
31
31
|
const templateMap = new WeakMap();
|
|
32
32
|
let storyNumber = 1;
|
|
33
33
|
const getPropsOptions = {
|
|
34
|
-
log: (message, ...args) => addonActions.action(message)
|
|
34
|
+
log: (message, ...args) => addonActions.action(message)(...args),
|
|
35
35
|
logHandler: addonActions.action
|
|
36
36
|
};
|
|
37
37
|
const makeStory = (description, props, wrapper = null) => {
|
|
@@ -80,12 +80,12 @@ const mockRequester = (operationMatcher, operationToString) => {
|
|
|
80
80
|
if (mock.onceOnly && mock.used) {
|
|
81
81
|
continue;
|
|
82
82
|
}
|
|
83
|
-
if (operationMatcher
|
|
83
|
+
if (operationMatcher(mock.operation, ...args)) {
|
|
84
84
|
mock.used = true;
|
|
85
85
|
return mock.response();
|
|
86
86
|
}
|
|
87
87
|
}
|
|
88
|
-
const operation = operationToString
|
|
88
|
+
const operation = operationToString(...args);
|
|
89
89
|
return Promise.reject(new Error(`No matching mock response found for request:
|
|
90
90
|
${operation}`));
|
|
91
91
|
};
|
|
@@ -239,177 +239,41 @@ const makeMockResponse = response => {
|
|
|
239
239
|
}
|
|
240
240
|
};
|
|
241
241
|
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
return typeof obj;
|
|
247
|
-
} : function (obj) {
|
|
248
|
-
return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
|
249
|
-
}, _typeof(obj);
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
function _toPrimitive(input, hint) {
|
|
253
|
-
if (_typeof(input) !== "object" || input === null) return input;
|
|
254
|
-
var prim = input[Symbol.toPrimitive];
|
|
255
|
-
if (prim !== undefined) {
|
|
256
|
-
var res = prim.call(input, hint || "default");
|
|
257
|
-
if (_typeof(res) !== "object") return res;
|
|
258
|
-
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
259
|
-
}
|
|
260
|
-
return (hint === "string" ? String : Number)(input);
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
function _toPropertyKey(arg) {
|
|
264
|
-
var key = _toPrimitive(arg, "string");
|
|
265
|
-
return _typeof(key) === "symbol" ? key : String(key);
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
function _defineProperties(target, props) {
|
|
269
|
-
for (var i = 0; i < props.length; i++) {
|
|
270
|
-
var descriptor = props[i];
|
|
271
|
-
descriptor.enumerable = descriptor.enumerable || false;
|
|
272
|
-
descriptor.configurable = true;
|
|
273
|
-
if ("value" in descriptor) descriptor.writable = true;
|
|
274
|
-
Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
function _createClass(Constructor, protoProps, staticProps) {
|
|
278
|
-
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
279
|
-
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
280
|
-
Object.defineProperty(Constructor, "prototype", {
|
|
281
|
-
writable: false
|
|
282
|
-
});
|
|
283
|
-
return Constructor;
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
function _setPrototypeOf(o, p) {
|
|
287
|
-
_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
|
|
288
|
-
o.__proto__ = p;
|
|
289
|
-
return o;
|
|
290
|
-
};
|
|
291
|
-
return _setPrototypeOf(o, p);
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
function _inheritsLoose(subClass, superClass) {
|
|
295
|
-
subClass.prototype = Object.create(superClass.prototype);
|
|
296
|
-
subClass.prototype.constructor = subClass;
|
|
297
|
-
_setPrototypeOf(subClass, superClass);
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
function _getPrototypeOf(o) {
|
|
301
|
-
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) {
|
|
302
|
-
return o.__proto__ || Object.getPrototypeOf(o);
|
|
303
|
-
};
|
|
304
|
-
return _getPrototypeOf(o);
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
function _isNativeFunction(fn) {
|
|
308
|
-
return Function.toString.call(fn).indexOf("[native code]") !== -1;
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
function _isNativeReflectConstruct() {
|
|
312
|
-
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
313
|
-
if (Reflect.construct.sham) return false;
|
|
314
|
-
if (typeof Proxy === "function") return true;
|
|
315
|
-
try {
|
|
316
|
-
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
|
317
|
-
return true;
|
|
318
|
-
} catch (e) {
|
|
319
|
-
return false;
|
|
320
|
-
}
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
function _construct(Parent, args, Class) {
|
|
324
|
-
if (_isNativeReflectConstruct()) {
|
|
325
|
-
_construct = Reflect.construct.bind();
|
|
326
|
-
} else {
|
|
327
|
-
_construct = function _construct(Parent, args, Class) {
|
|
328
|
-
var a = [null];
|
|
329
|
-
a.push.apply(a, args);
|
|
330
|
-
var Constructor = Function.bind.apply(Parent, a);
|
|
331
|
-
var instance = new Constructor();
|
|
332
|
-
if (Class) _setPrototypeOf(instance, Class.prototype);
|
|
333
|
-
return instance;
|
|
334
|
-
};
|
|
335
|
-
}
|
|
336
|
-
return _construct.apply(null, arguments);
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
function _wrapNativeSuper(Class) {
|
|
340
|
-
var _cache = typeof Map === "function" ? new Map() : undefined;
|
|
341
|
-
_wrapNativeSuper = function _wrapNativeSuper(Class) {
|
|
342
|
-
if (Class === null || !_isNativeFunction(Class)) return Class;
|
|
343
|
-
if (typeof Class !== "function") {
|
|
344
|
-
throw new TypeError("Super expression must either be null or a function");
|
|
345
|
-
}
|
|
346
|
-
if (typeof _cache !== "undefined") {
|
|
347
|
-
if (_cache.has(Class)) return _cache.get(Class);
|
|
348
|
-
_cache.set(Class, Wrapper);
|
|
349
|
-
}
|
|
350
|
-
function Wrapper() {
|
|
351
|
-
return _construct(Class, arguments, _getPrototypeOf(this).constructor);
|
|
352
|
-
}
|
|
353
|
-
Wrapper.prototype = Object.create(Class.prototype, {
|
|
354
|
-
constructor: {
|
|
355
|
-
value: Wrapper,
|
|
356
|
-
enumerable: false,
|
|
357
|
-
writable: true,
|
|
358
|
-
configurable: true
|
|
359
|
-
}
|
|
360
|
-
});
|
|
361
|
-
return _setPrototypeOf(Wrapper, Class);
|
|
362
|
-
};
|
|
363
|
-
return _wrapNativeSuper(Class);
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
let SettleSignal = function (_EventTarget) {
|
|
367
|
-
_inheritsLoose(SettleSignal, _EventTarget);
|
|
368
|
-
function SettleSignal(setSettleFn = null) {
|
|
369
|
-
var _this;
|
|
370
|
-
_this = _EventTarget.call(this) || this;
|
|
371
|
-
_this._settled = false;
|
|
242
|
+
class SettleSignal extends EventTarget {
|
|
243
|
+
constructor(setSettleFn = null) {
|
|
244
|
+
super();
|
|
245
|
+
this._settled = false;
|
|
372
246
|
setSettleFn == null ? void 0 : setSettleFn(() => {
|
|
373
|
-
if (
|
|
247
|
+
if (this._settled) {
|
|
374
248
|
throw new Error("SettleSignal already settled");
|
|
375
249
|
}
|
|
376
|
-
|
|
377
|
-
|
|
250
|
+
this._settled = true;
|
|
251
|
+
this.dispatchEvent(new Event("settled"));
|
|
378
252
|
});
|
|
379
|
-
return _this;
|
|
380
253
|
}
|
|
381
|
-
|
|
254
|
+
static settle() {
|
|
382
255
|
const signal = new SettleSignal();
|
|
383
256
|
signal._settled = true;
|
|
384
257
|
return signal;
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
}
|
|
391
|
-
}]);
|
|
392
|
-
return SettleSignal;
|
|
393
|
-
}(_wrapNativeSuper(EventTarget));
|
|
258
|
+
}
|
|
259
|
+
get settled() {
|
|
260
|
+
return this._settled;
|
|
261
|
+
}
|
|
262
|
+
}
|
|
394
263
|
|
|
395
|
-
|
|
396
|
-
|
|
264
|
+
class SettleController {
|
|
265
|
+
constructor() {
|
|
397
266
|
this._settleFn = void 0;
|
|
398
267
|
this._signal = void 0;
|
|
399
268
|
this._signal = new SettleSignal(settleFn => this._settleFn = settleFn);
|
|
400
269
|
}
|
|
401
|
-
|
|
402
|
-
|
|
270
|
+
get signal() {
|
|
271
|
+
return this._signal;
|
|
272
|
+
}
|
|
273
|
+
settle() {
|
|
403
274
|
this._settleFn();
|
|
404
|
-
}
|
|
405
|
-
|
|
406
|
-
key: "signal",
|
|
407
|
-
get: function () {
|
|
408
|
-
return this._signal;
|
|
409
|
-
}
|
|
410
|
-
}]);
|
|
411
|
-
return SettleController;
|
|
412
|
-
}();
|
|
275
|
+
}
|
|
276
|
+
}
|
|
413
277
|
|
|
414
278
|
const defaultConfig$3 = null;
|
|
415
279
|
const normalizeConfig = config => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@khanacademy/wonder-blocks-testing",
|
|
3
|
-
"version": "8.0.
|
|
3
|
+
"version": "8.0.6",
|
|
4
4
|
"design": "v1",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
16
|
"@babel/runtime": "^7.18.6",
|
|
17
|
-
"@khanacademy/wonder-blocks-data": "^11.0.
|
|
17
|
+
"@khanacademy/wonder-blocks-data": "^11.0.6"
|
|
18
18
|
},
|
|
19
19
|
"peerDependencies": {
|
|
20
20
|
"@khanacademy/wonder-stuff-core": "^1.2.2",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"react-router-dom": "5.3.0"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"wb-dev-build-settings": "^0.9.
|
|
29
|
+
"wb-dev-build-settings": "^0.9.5"
|
|
30
30
|
},
|
|
31
31
|
"author": "",
|
|
32
32
|
"license": "MIT"
|