xcratch-create 1.1.0 → 1.2.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/package.json +1 -1
- package/template/jest.config.js +11 -0
- package/template/package.json +4 -4
- package/template/src/vm/extensions/block/index.js +1 -2
- package/template/test/.eslintrc.js +3 -3
- package/template/test/mocks/fileMock.js +1 -0
- package/template/test/setup-test.js +2 -4
- package/template/test/unit/block.test.js +4 -6
- package/template/.mocharc.js +0 -4
package/package.json
CHANGED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
testEnvironment: 'node',
|
|
3
|
+
transform: {
|
|
4
|
+
'^.+\\.jsx?$': 'babel-jest'
|
|
5
|
+
},
|
|
6
|
+
setupFilesAfterEnv: ['./test/setup-test.js'],
|
|
7
|
+
moduleNameMapper: {
|
|
8
|
+
'\\.(png|jpg|jpeg|gif|svg)$': '<rootDir>/test/mocks/fileMock.js'
|
|
9
|
+
},
|
|
10
|
+
testMatch: ['**/test/unit/**/*.test.js'],
|
|
11
|
+
};
|
package/template/package.json
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
"setup-dev": "node ./scripts/setup-dev.mjs",
|
|
7
7
|
"build": "rollup -c ./scripts/rollup.config.mjs",
|
|
8
8
|
"watch": "rollup -c ./scripts/rollup.config.mjs --watch",
|
|
9
|
-
"test": "
|
|
9
|
+
"test": "node --experimental-vm-modules node_modules/jest/bin/jest.js"
|
|
10
10
|
},
|
|
11
11
|
"devDependencies": {
|
|
12
12
|
"@babel/core": "^7.26.9",
|
|
@@ -22,14 +22,14 @@
|
|
|
22
22
|
"@rollup/plugin-json": "^6.1.0",
|
|
23
23
|
"@rollup/plugin-multi-entry": "^6.0.1",
|
|
24
24
|
"@rollup/plugin-node-resolve": "^16.0.0",
|
|
25
|
-
"chai": "^5.2.0",
|
|
26
25
|
"core-js": "^3.40.0",
|
|
27
26
|
"eslint": "^8.57.0",
|
|
28
27
|
"eslint-config-scratch": "^9.0.9",
|
|
29
28
|
"eslint-plugin-import": "^2.31.0",
|
|
30
|
-
"eslint-plugin-
|
|
29
|
+
"eslint-plugin-jest": "^27.6.3",
|
|
31
30
|
"fs-extra": "^11.3.0",
|
|
32
|
-
"
|
|
31
|
+
"jest": "^29.7.0",
|
|
32
|
+
"jest-environment-jsdom": "^29.7.0",
|
|
33
33
|
"rollup": "^4.34.7",
|
|
34
34
|
"rollup-plugin-polyfill-node": "^0.13.0"
|
|
35
35
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import BlockType from '../../extension-support/block-type';
|
|
2
2
|
import ArgumentType from '../../extension-support/argument-type';
|
|
3
3
|
import Cast from '../../util/cast';
|
|
4
|
-
import log from '../../util/log';
|
|
5
4
|
import translations from './translations.json';
|
|
6
5
|
import blockIcon from './block-icon.png';
|
|
7
6
|
|
|
@@ -138,7 +137,7 @@ class ExtensionBlocks {
|
|
|
138
137
|
doIt (args) {
|
|
139
138
|
const statement = Cast.toString(args.SCRIPT);
|
|
140
139
|
const func = new Function(`return (${statement})`);
|
|
141
|
-
|
|
140
|
+
console.log(`doIt: ${statement}`);
|
|
142
141
|
return func.call(this);
|
|
143
142
|
}
|
|
144
143
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
module.exports = {
|
|
2
2
|
root: true,
|
|
3
|
-
plugins: ["
|
|
4
|
-
extends: ["plugin:
|
|
3
|
+
plugins: ["jest"],
|
|
4
|
+
extends: ["plugin:jest/recommended"],
|
|
5
5
|
env: {
|
|
6
6
|
browser: true,
|
|
7
7
|
es6: true,
|
|
8
|
-
|
|
8
|
+
"jest/globals": true,
|
|
9
9
|
},
|
|
10
10
|
parserOptions: {
|
|
11
11
|
sourceType: "module",
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = 'test-file-stub';
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { describe, it } from "mocha";
|
|
2
|
-
import { expect } from "chai";
|
|
3
1
|
import { blockClass } from "../../src/vm/extensions/block/index.js";
|
|
4
2
|
|
|
5
3
|
describe("blockClass", () => {
|
|
@@ -9,14 +7,14 @@ describe("blockClass", () => {
|
|
|
9
7
|
}
|
|
10
8
|
};
|
|
11
9
|
|
|
12
|
-
|
|
10
|
+
test("should create an instance of blockClass", () => {
|
|
13
11
|
const block = new blockClass(runtime);
|
|
14
|
-
expect(block).
|
|
12
|
+
expect(block).toBeInstanceOf(blockClass);
|
|
15
13
|
});
|
|
16
14
|
|
|
17
|
-
|
|
15
|
+
test("doIt('3 + 4') should return 7", () => {
|
|
18
16
|
const block = new blockClass(runtime);
|
|
19
17
|
const result = block.doIt({SCRIPT: "3 + 4"});
|
|
20
|
-
expect(result).
|
|
18
|
+
expect(result).toBe(7);
|
|
21
19
|
});
|
|
22
20
|
});
|
package/template/.mocharc.js
DELETED