tutuca 0.9.73 → 0.9.75
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/dist/tutuca-dev.ext.js +83 -1
- package/dist/tutuca-dev.js +82 -0
- package/dist/tutuca-dev.min.js +2 -2
- package/package.json +1 -1
package/dist/tutuca-dev.ext.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// dev.js
|
|
2
|
-
import { expect } from "chai";
|
|
2
|
+
import { expect, use } from "chai";
|
|
3
3
|
|
|
4
4
|
// src/value.js
|
|
5
5
|
import { is } from "immutable";
|
|
@@ -2301,6 +2301,87 @@ function compileModifiers(eventName, names) {
|
|
|
2301
2301
|
};
|
|
2302
2302
|
}
|
|
2303
2303
|
|
|
2304
|
+
// src/chai-jest.js
|
|
2305
|
+
function jestMatchers(chai, utils) {
|
|
2306
|
+
const A = chai.Assertion;
|
|
2307
|
+
const m = (name, fn) => A.addMethod(name, fn);
|
|
2308
|
+
m("toBe", function(expected) {
|
|
2309
|
+
this.assert(Object.is(this._obj, expected), "expected #{this} to be #{exp}", "expected #{this} not to be #{exp}", expected, this._obj);
|
|
2310
|
+
});
|
|
2311
|
+
m("toEqual", function(expected) {
|
|
2312
|
+
this.assert(utils.eql(this._obj, expected), "expected #{this} to deeply equal #{exp}", "expected #{this} not to deeply equal #{exp}", expected, this._obj, true);
|
|
2313
|
+
});
|
|
2314
|
+
m("toBeTruthy", function() {
|
|
2315
|
+
this.assert(Boolean(this._obj), "expected #{this} to be truthy", "expected #{this} not to be truthy");
|
|
2316
|
+
});
|
|
2317
|
+
m("toBeFalsy", function() {
|
|
2318
|
+
this.assert(!this._obj, "expected #{this} to be falsy", "expected #{this} not to be falsy");
|
|
2319
|
+
});
|
|
2320
|
+
m("toBeNull", function() {
|
|
2321
|
+
this.assert(this._obj === null, "expected #{this} to be null", "expected #{this} not to be null");
|
|
2322
|
+
});
|
|
2323
|
+
m("toBeUndefined", function() {
|
|
2324
|
+
this.assert(this._obj === undefined, "expected #{this} to be undefined", "expected #{this} not to be undefined");
|
|
2325
|
+
});
|
|
2326
|
+
m("toBeDefined", function() {
|
|
2327
|
+
this.assert(this._obj !== undefined, "expected #{this} to be defined", "expected #{this} to be undefined");
|
|
2328
|
+
});
|
|
2329
|
+
m("toBeNaN", function() {
|
|
2330
|
+
this.assert(Number.isNaN(this._obj), "expected #{this} to be NaN", "expected #{this} not to be NaN");
|
|
2331
|
+
});
|
|
2332
|
+
const compare = (name, op, word) => m(name, function(expected) {
|
|
2333
|
+
this.assert(op(this._obj, expected), `expected #{this} to be ${word} #{exp}`, `expected #{this} not to be ${word} #{exp}`, expected);
|
|
2334
|
+
});
|
|
2335
|
+
compare("toBeGreaterThan", (a, b) => a > b, "greater than");
|
|
2336
|
+
compare("toBeGreaterThanOrEqual", (a, b) => a >= b, "greater than or equal to");
|
|
2337
|
+
compare("toBeLessThan", (a, b) => a < b, "less than");
|
|
2338
|
+
compare("toBeLessThanOrEqual", (a, b) => a <= b, "less than or equal to");
|
|
2339
|
+
m("toBeCloseTo", function(expected, numDigits = 2) {
|
|
2340
|
+
const pass = Math.abs(expected - this._obj) < 10 ** -numDigits / 2;
|
|
2341
|
+
this.assert(pass, `expected #{this} to be close to #{exp} (${numDigits} digits)`, `expected #{this} not to be close to #{exp} (${numDigits} digits)`, expected);
|
|
2342
|
+
});
|
|
2343
|
+
m("toContain", function(item) {
|
|
2344
|
+
const obj = this._obj;
|
|
2345
|
+
const ok = typeof obj === "string" ? obj.includes(item) : Array.from(obj).includes(item);
|
|
2346
|
+
this.assert(ok, "expected #{this} to contain #{exp}", "expected #{this} not to contain #{exp}", item);
|
|
2347
|
+
});
|
|
2348
|
+
m("toHaveLength", function(length) {
|
|
2349
|
+
const actual = this._obj == null ? undefined : this._obj.length;
|
|
2350
|
+
this.assert(actual === length, "expected #{this} to have length #{exp}", "expected #{this} not to have length #{exp}", length, actual);
|
|
2351
|
+
});
|
|
2352
|
+
m("toMatch", function(expected) {
|
|
2353
|
+
const obj = this._obj;
|
|
2354
|
+
const ok = expected instanceof RegExp ? expected.test(obj) : String(obj).includes(expected);
|
|
2355
|
+
this.assert(ok, "expected #{this} to match #{exp}", "expected #{this} not to match #{exp}", expected);
|
|
2356
|
+
});
|
|
2357
|
+
m("toHaveProperty", function(path, ...rest) {
|
|
2358
|
+
const keys = Array.isArray(path) ? path : String(path).split(".");
|
|
2359
|
+
let cur = this._obj;
|
|
2360
|
+
let found = true;
|
|
2361
|
+
for (const k of keys) {
|
|
2362
|
+
if (cur != null && k in Object(cur))
|
|
2363
|
+
cur = cur[k];
|
|
2364
|
+
else {
|
|
2365
|
+
found = false;
|
|
2366
|
+
break;
|
|
2367
|
+
}
|
|
2368
|
+
}
|
|
2369
|
+
const pass = found && (rest.length === 0 || utils.eql(cur, rest[0]));
|
|
2370
|
+
this.assert(pass, "expected #{this} to have property #{exp}", "expected #{this} not to have property #{exp}", path);
|
|
2371
|
+
});
|
|
2372
|
+
m("toBeInstanceOf", function(ctor) {
|
|
2373
|
+
this.assert(this._obj instanceof ctor, "expected #{this} to be an instance of #{exp}", "expected #{this} not to be an instance of #{exp}", ctor.name ?? ctor);
|
|
2374
|
+
});
|
|
2375
|
+
m("toThrow", function(expected) {
|
|
2376
|
+
const a = new chai.Assertion(this._obj);
|
|
2377
|
+
if (utils.flag(this, "negate")) {
|
|
2378
|
+
expected === undefined ? a.to.not.throw() : a.to.not.throw(expected);
|
|
2379
|
+
} else {
|
|
2380
|
+
expected === undefined ? a.to.throw() : a.to.throw(expected);
|
|
2381
|
+
}
|
|
2382
|
+
});
|
|
2383
|
+
}
|
|
2384
|
+
|
|
2304
2385
|
// src/util/parsectx.js
|
|
2305
2386
|
class ParseCtxClassSetCollector extends ParseContext {
|
|
2306
2387
|
constructor(...args) {
|
|
@@ -7905,6 +7986,7 @@ function collectIterBindings(Comp, compInstance, seq, opts = {}) {
|
|
|
7905
7986
|
}
|
|
7906
7987
|
|
|
7907
7988
|
// dev.js
|
|
7989
|
+
use(jestMatchers);
|
|
7908
7990
|
async function test2(opts = {}) {
|
|
7909
7991
|
const report = await runTests({ expect, ...opts });
|
|
7910
7992
|
reportTestReportToConsole(report);
|
package/dist/tutuca-dev.js
CHANGED
|
@@ -9966,6 +9966,87 @@ function compileModifiers(eventName, names) {
|
|
|
9966
9966
|
};
|
|
9967
9967
|
}
|
|
9968
9968
|
|
|
9969
|
+
// src/chai-jest.js
|
|
9970
|
+
function jestMatchers(chai, utils) {
|
|
9971
|
+
const A = chai.Assertion;
|
|
9972
|
+
const m = (name, fn) => A.addMethod(name, fn);
|
|
9973
|
+
m("toBe", function(expected) {
|
|
9974
|
+
this.assert(Object.is(this._obj, expected), "expected #{this} to be #{exp}", "expected #{this} not to be #{exp}", expected, this._obj);
|
|
9975
|
+
});
|
|
9976
|
+
m("toEqual", function(expected) {
|
|
9977
|
+
this.assert(utils.eql(this._obj, expected), "expected #{this} to deeply equal #{exp}", "expected #{this} not to deeply equal #{exp}", expected, this._obj, true);
|
|
9978
|
+
});
|
|
9979
|
+
m("toBeTruthy", function() {
|
|
9980
|
+
this.assert(Boolean(this._obj), "expected #{this} to be truthy", "expected #{this} not to be truthy");
|
|
9981
|
+
});
|
|
9982
|
+
m("toBeFalsy", function() {
|
|
9983
|
+
this.assert(!this._obj, "expected #{this} to be falsy", "expected #{this} not to be falsy");
|
|
9984
|
+
});
|
|
9985
|
+
m("toBeNull", function() {
|
|
9986
|
+
this.assert(this._obj === null, "expected #{this} to be null", "expected #{this} not to be null");
|
|
9987
|
+
});
|
|
9988
|
+
m("toBeUndefined", function() {
|
|
9989
|
+
this.assert(this._obj === undefined, "expected #{this} to be undefined", "expected #{this} not to be undefined");
|
|
9990
|
+
});
|
|
9991
|
+
m("toBeDefined", function() {
|
|
9992
|
+
this.assert(this._obj !== undefined, "expected #{this} to be defined", "expected #{this} to be undefined");
|
|
9993
|
+
});
|
|
9994
|
+
m("toBeNaN", function() {
|
|
9995
|
+
this.assert(Number.isNaN(this._obj), "expected #{this} to be NaN", "expected #{this} not to be NaN");
|
|
9996
|
+
});
|
|
9997
|
+
const compare = (name, op, word) => m(name, function(expected) {
|
|
9998
|
+
this.assert(op(this._obj, expected), `expected #{this} to be ${word} #{exp}`, `expected #{this} not to be ${word} #{exp}`, expected);
|
|
9999
|
+
});
|
|
10000
|
+
compare("toBeGreaterThan", (a, b) => a > b, "greater than");
|
|
10001
|
+
compare("toBeGreaterThanOrEqual", (a, b) => a >= b, "greater than or equal to");
|
|
10002
|
+
compare("toBeLessThan", (a, b) => a < b, "less than");
|
|
10003
|
+
compare("toBeLessThanOrEqual", (a, b) => a <= b, "less than or equal to");
|
|
10004
|
+
m("toBeCloseTo", function(expected, numDigits = 2) {
|
|
10005
|
+
const pass = Math.abs(expected - this._obj) < 10 ** -numDigits / 2;
|
|
10006
|
+
this.assert(pass, `expected #{this} to be close to #{exp} (${numDigits} digits)`, `expected #{this} not to be close to #{exp} (${numDigits} digits)`, expected);
|
|
10007
|
+
});
|
|
10008
|
+
m("toContain", function(item) {
|
|
10009
|
+
const obj = this._obj;
|
|
10010
|
+
const ok = typeof obj === "string" ? obj.includes(item) : Array.from(obj).includes(item);
|
|
10011
|
+
this.assert(ok, "expected #{this} to contain #{exp}", "expected #{this} not to contain #{exp}", item);
|
|
10012
|
+
});
|
|
10013
|
+
m("toHaveLength", function(length) {
|
|
10014
|
+
const actual = this._obj == null ? undefined : this._obj.length;
|
|
10015
|
+
this.assert(actual === length, "expected #{this} to have length #{exp}", "expected #{this} not to have length #{exp}", length, actual);
|
|
10016
|
+
});
|
|
10017
|
+
m("toMatch", function(expected) {
|
|
10018
|
+
const obj = this._obj;
|
|
10019
|
+
const ok = expected instanceof RegExp ? expected.test(obj) : String(obj).includes(expected);
|
|
10020
|
+
this.assert(ok, "expected #{this} to match #{exp}", "expected #{this} not to match #{exp}", expected);
|
|
10021
|
+
});
|
|
10022
|
+
m("toHaveProperty", function(path, ...rest) {
|
|
10023
|
+
const keys = Array.isArray(path) ? path : String(path).split(".");
|
|
10024
|
+
let cur = this._obj;
|
|
10025
|
+
let found = true;
|
|
10026
|
+
for (const k of keys) {
|
|
10027
|
+
if (cur != null && k in Object(cur))
|
|
10028
|
+
cur = cur[k];
|
|
10029
|
+
else {
|
|
10030
|
+
found = false;
|
|
10031
|
+
break;
|
|
10032
|
+
}
|
|
10033
|
+
}
|
|
10034
|
+
const pass = found && (rest.length === 0 || utils.eql(cur, rest[0]));
|
|
10035
|
+
this.assert(pass, "expected #{this} to have property #{exp}", "expected #{this} not to have property #{exp}", path);
|
|
10036
|
+
});
|
|
10037
|
+
m("toBeInstanceOf", function(ctor) {
|
|
10038
|
+
this.assert(this._obj instanceof ctor, "expected #{this} to be an instance of #{exp}", "expected #{this} not to be an instance of #{exp}", ctor.name ?? ctor);
|
|
10039
|
+
});
|
|
10040
|
+
m("toThrow", function(expected) {
|
|
10041
|
+
const a = new chai.Assertion(this._obj);
|
|
10042
|
+
if (utils.flag(this, "negate")) {
|
|
10043
|
+
expected === undefined ? a.to.not.throw() : a.to.not.throw(expected);
|
|
10044
|
+
} else {
|
|
10045
|
+
expected === undefined ? a.to.throw() : a.to.throw(expected);
|
|
10046
|
+
}
|
|
10047
|
+
});
|
|
10048
|
+
}
|
|
10049
|
+
|
|
9969
10050
|
// src/util/parsectx.js
|
|
9970
10051
|
class ParseCtxClassSetCollector extends ParseContext {
|
|
9971
10052
|
constructor(...args) {
|
|
@@ -15510,6 +15591,7 @@ function collectIterBindings(Comp, compInstance, seq, opts = {}) {
|
|
|
15510
15591
|
}
|
|
15511
15592
|
|
|
15512
15593
|
// dev.js
|
|
15594
|
+
use(jestMatchers);
|
|
15513
15595
|
async function test3(opts = {}) {
|
|
15514
15596
|
const report = await runTests({ expect, ...opts });
|
|
15515
15597
|
reportTestReportToConsole(report);
|