tutuca 0.9.71 → 0.9.72
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/chai.js +3389 -0
- package/dist/immutable.js +4333 -0
- package/dist/tutuca-cli.js +111 -1
- package/dist/tutuca-dev.ext.js +86 -3392
- package/package.json +9 -1
- package/skill/tutuca/cli.md +5 -5
- package/skill/tutuca/core.md +11 -0
- package/skill/tutuca/testing.md +16 -10
package/dist/tutuca-cli.js
CHANGED
|
@@ -12831,6 +12831,111 @@ var init_chai = __esm(() => {
|
|
|
12831
12831
|
__name(use, "use");
|
|
12832
12832
|
});
|
|
12833
12833
|
|
|
12834
|
+
// src/chai-jest.js
|
|
12835
|
+
function jestMatchers(chai, utils) {
|
|
12836
|
+
const A = chai.Assertion;
|
|
12837
|
+
const m = (name, fn) => A.addMethod(name, fn);
|
|
12838
|
+
m("toBe", function(expected) {
|
|
12839
|
+
this.assert(Object.is(this._obj, expected), "expected #{this} to be #{exp}", "expected #{this} not to be #{exp}", expected, this._obj);
|
|
12840
|
+
});
|
|
12841
|
+
m("toEqual", function(expected) {
|
|
12842
|
+
this.assert(utils.eql(this._obj, expected), "expected #{this} to deeply equal #{exp}", "expected #{this} not to deeply equal #{exp}", expected, this._obj, true);
|
|
12843
|
+
});
|
|
12844
|
+
m("toBeTruthy", function() {
|
|
12845
|
+
this.assert(Boolean(this._obj), "expected #{this} to be truthy", "expected #{this} not to be truthy");
|
|
12846
|
+
});
|
|
12847
|
+
m("toBeFalsy", function() {
|
|
12848
|
+
this.assert(!this._obj, "expected #{this} to be falsy", "expected #{this} not to be falsy");
|
|
12849
|
+
});
|
|
12850
|
+
m("toBeNull", function() {
|
|
12851
|
+
this.assert(this._obj === null, "expected #{this} to be null", "expected #{this} not to be null");
|
|
12852
|
+
});
|
|
12853
|
+
m("toBeUndefined", function() {
|
|
12854
|
+
this.assert(this._obj === undefined, "expected #{this} to be undefined", "expected #{this} not to be undefined");
|
|
12855
|
+
});
|
|
12856
|
+
m("toBeDefined", function() {
|
|
12857
|
+
this.assert(this._obj !== undefined, "expected #{this} to be defined", "expected #{this} to be undefined");
|
|
12858
|
+
});
|
|
12859
|
+
m("toBeNaN", function() {
|
|
12860
|
+
this.assert(Number.isNaN(this._obj), "expected #{this} to be NaN", "expected #{this} not to be NaN");
|
|
12861
|
+
});
|
|
12862
|
+
const compare = (name, op, word) => m(name, function(expected) {
|
|
12863
|
+
this.assert(op(this._obj, expected), `expected #{this} to be ${word} #{exp}`, `expected #{this} not to be ${word} #{exp}`, expected);
|
|
12864
|
+
});
|
|
12865
|
+
compare("toBeGreaterThan", (a, b) => a > b, "greater than");
|
|
12866
|
+
compare("toBeGreaterThanOrEqual", (a, b) => a >= b, "greater than or equal to");
|
|
12867
|
+
compare("toBeLessThan", (a, b) => a < b, "less than");
|
|
12868
|
+
compare("toBeLessThanOrEqual", (a, b) => a <= b, "less than or equal to");
|
|
12869
|
+
m("toBeCloseTo", function(expected, numDigits = 2) {
|
|
12870
|
+
const pass = Math.abs(expected - this._obj) < 10 ** -numDigits / 2;
|
|
12871
|
+
this.assert(pass, `expected #{this} to be close to #{exp} (${numDigits} digits)`, `expected #{this} not to be close to #{exp} (${numDigits} digits)`, expected);
|
|
12872
|
+
});
|
|
12873
|
+
m("toContain", function(item) {
|
|
12874
|
+
const obj = this._obj;
|
|
12875
|
+
const ok = typeof obj === "string" ? obj.includes(item) : Array.from(obj).includes(item);
|
|
12876
|
+
this.assert(ok, "expected #{this} to contain #{exp}", "expected #{this} not to contain #{exp}", item);
|
|
12877
|
+
});
|
|
12878
|
+
m("toHaveLength", function(length) {
|
|
12879
|
+
const actual = this._obj == null ? undefined : this._obj.length;
|
|
12880
|
+
this.assert(actual === length, "expected #{this} to have length #{exp}", "expected #{this} not to have length #{exp}", length, actual);
|
|
12881
|
+
});
|
|
12882
|
+
m("toMatch", function(expected) {
|
|
12883
|
+
const obj = this._obj;
|
|
12884
|
+
const ok = expected instanceof RegExp ? expected.test(obj) : String(obj).includes(expected);
|
|
12885
|
+
this.assert(ok, "expected #{this} to match #{exp}", "expected #{this} not to match #{exp}", expected);
|
|
12886
|
+
});
|
|
12887
|
+
m("toHaveProperty", function(path, ...rest) {
|
|
12888
|
+
const keys = Array.isArray(path) ? path : String(path).split(".");
|
|
12889
|
+
let cur = this._obj;
|
|
12890
|
+
let found = true;
|
|
12891
|
+
for (const k of keys) {
|
|
12892
|
+
if (cur != null && k in Object(cur))
|
|
12893
|
+
cur = cur[k];
|
|
12894
|
+
else {
|
|
12895
|
+
found = false;
|
|
12896
|
+
break;
|
|
12897
|
+
}
|
|
12898
|
+
}
|
|
12899
|
+
const pass = found && (rest.length === 0 || utils.eql(cur, rest[0]));
|
|
12900
|
+
this.assert(pass, "expected #{this} to have property #{exp}", "expected #{this} not to have property #{exp}", path);
|
|
12901
|
+
});
|
|
12902
|
+
m("toBeInstanceOf", function(ctor) {
|
|
12903
|
+
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);
|
|
12904
|
+
});
|
|
12905
|
+
m("toThrow", function(expected) {
|
|
12906
|
+
const a = new chai.Assertion(this._obj);
|
|
12907
|
+
if (utils.flag(this, "negate")) {
|
|
12908
|
+
expected === undefined ? a.to.not.throw() : a.to.not.throw(expected);
|
|
12909
|
+
} else {
|
|
12910
|
+
expected === undefined ? a.to.throw() : a.to.throw(expected);
|
|
12911
|
+
}
|
|
12912
|
+
});
|
|
12913
|
+
}
|
|
12914
|
+
var JEST_MATCHERS;
|
|
12915
|
+
var init_chai_jest = __esm(() => {
|
|
12916
|
+
JEST_MATCHERS = [
|
|
12917
|
+
"toBe",
|
|
12918
|
+
"toEqual",
|
|
12919
|
+
"toBeTruthy",
|
|
12920
|
+
"toBeFalsy",
|
|
12921
|
+
"toBeNull",
|
|
12922
|
+
"toBeUndefined",
|
|
12923
|
+
"toBeDefined",
|
|
12924
|
+
"toBeNaN",
|
|
12925
|
+
"toBeGreaterThan",
|
|
12926
|
+
"toBeGreaterThanOrEqual",
|
|
12927
|
+
"toBeLessThan",
|
|
12928
|
+
"toBeLessThanOrEqual",
|
|
12929
|
+
"toBeCloseTo",
|
|
12930
|
+
"toContain",
|
|
12931
|
+
"toHaveLength",
|
|
12932
|
+
"toMatch",
|
|
12933
|
+
"toHaveProperty",
|
|
12934
|
+
"toBeInstanceOf",
|
|
12935
|
+
"toThrow"
|
|
12936
|
+
];
|
|
12937
|
+
});
|
|
12938
|
+
|
|
12834
12939
|
// tools/core/results.js
|
|
12835
12940
|
class ModuleInfo {
|
|
12836
12941
|
constructor({ path = null, present = new Set, counts = {}, warnings = [] }) {
|
|
@@ -14743,12 +14848,14 @@ function parseLimit(raw) {
|
|
|
14743
14848
|
var COMMANDS;
|
|
14744
14849
|
var init__registry = __esm(() => {
|
|
14745
14850
|
init_chai();
|
|
14851
|
+
init_chai_jest();
|
|
14746
14852
|
init_describe();
|
|
14747
14853
|
init_docs();
|
|
14748
14854
|
init_list();
|
|
14749
14855
|
init_lint();
|
|
14750
14856
|
init_render2();
|
|
14751
14857
|
init_test();
|
|
14858
|
+
use(jestMatchers);
|
|
14752
14859
|
COMMANDS = {
|
|
14753
14860
|
get: {
|
|
14754
14861
|
describe: "Summarize the module's exports and counts.",
|
|
@@ -15618,6 +15725,7 @@ init__registry();
|
|
|
15618
15725
|
init_feedback();
|
|
15619
15726
|
|
|
15620
15727
|
// tools/cli/commands/help.js
|
|
15728
|
+
init_chai_jest();
|
|
15621
15729
|
var exports_help = {};
|
|
15622
15730
|
__export(exports_help, {
|
|
15623
15731
|
run: () => run4,
|
|
@@ -15670,7 +15778,9 @@ MODULE CONVENTION
|
|
|
15670
15778
|
describe(title, fn) // untagged
|
|
15671
15779
|
describe(title, { component }, fn)// explicit tag with custom title
|
|
15672
15780
|
and test(title, fn) // fn may be async
|
|
15673
|
-
and expect
|
|
15781
|
+
and expect is chai, with jest-style matchers added:
|
|
15782
|
+
${JEST_MATCHERS.join(", ")}
|
|
15783
|
+
(chai's BDD chain like .to.equal also works; use .not to negate)
|
|
15674
15784
|
|
|
15675
15785
|
export function getRoot() // optional; returned by info
|
|
15676
15786
|
|