@playcanvas/attribute-parser 1.6.1 → 1.7.1
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/LICENSE.md +19 -0
- package/dist/index.js +445 -0
- package/dist/libs.d.ts +50978 -0
- package/package.json +50 -10
- package/types/index.d.ts +55 -0
- package/types/parsers/attribute-parser.d.ts +55 -0
- package/types/parsers/parsing-error.d.ts +6 -0
- package/types/parsers/script-parser.d.ts +124 -0
- package/types/utils/attribute-utils.d.ts +5 -0
- package/{src/utils/generic-utils.js → types/utils/generic-utils.d.ts} +1 -10
- package/types/utils/tag-utils.d.ts +16 -0
- package/types/utils/ts-utils.d.ts +103 -0
- package/.github/workflows/ci.yml +0 -49
- package/eslint.config.mjs +0 -35
- package/renovate.json +0 -25
- package/src/index.js +0 -273
- package/src/parsers/attribute-parser.js +0 -197
- package/src/parsers/parsing-error.js +0 -14
- package/src/parsers/script-parser.js +0 -432
- package/src/utils/attribute-utils.js +0 -53
- package/src/utils/tag-utils.js +0 -73
- package/src/utils/ts-utils.js +0 -634
- package/test/fixtures/asset.invalid.js +0 -27
- package/test/fixtures/asset.invalid.ts +0 -24
- package/test/fixtures/asset.valid.js +0 -26
- package/test/fixtures/asset.valid.ts +0 -21
- package/test/fixtures/checkbox.valid.js +0 -23
- package/test/fixtures/color.valid.js +0 -23
- package/test/fixtures/conditional.valid.js +0 -22
- package/test/fixtures/curve.invalid.js +0 -29
- package/test/fixtures/curve.valid.js +0 -49
- package/test/fixtures/empty.valid.js +0 -0
- package/test/fixtures/entity.valid.js +0 -23
- package/test/fixtures/enum.valid.js +0 -66
- package/test/fixtures/enum.valid.ts +0 -50
- package/test/fixtures/example.dep.js +0 -9
- package/test/fixtures/export.import.js +0 -8
- package/test/fixtures/export.valid.js +0 -26
- package/test/fixtures/inherit.valid.js +0 -45
- package/test/fixtures/intellisense.valid.js +0 -40
- package/test/fixtures/json.invalid.js +0 -23
- package/test/fixtures/json.valid.js +0 -115
- package/test/fixtures/json.valid.ts +0 -81
- package/test/fixtures/misc.invalid.js +0 -24
- package/test/fixtures/misc.valid.js +0 -51
- package/test/fixtures/numeric.invalid.js +0 -38
- package/test/fixtures/numeric.valid.js +0 -63
- package/test/fixtures/playcanvas.d.ts +0 -47963
- package/test/fixtures/program.invalid.js +0 -12
- package/test/fixtures/program.valid.js +0 -27
- package/test/fixtures/text.valid.js +0 -31
- package/test/fixtures/vector.invalid.js +0 -14
- package/test/fixtures/vector.valid.js +0 -24
- package/test/tests/invalid/asset.test.js +0 -47
- package/test/tests/invalid/curve.test.js +0 -23
- package/test/tests/invalid/json.test.js +0 -27
- package/test/tests/invalid/misc.test.js +0 -41
- package/test/tests/invalid/numeric.test.js +0 -55
- package/test/tests/invalid/program.test.js +0 -17
- package/test/tests/invalid/vector.test.js +0 -28
- package/test/tests/valid/asset.test.js +0 -59
- package/test/tests/valid/checkbox.test.js +0 -57
- package/test/tests/valid/color.test.js +0 -49
- package/test/tests/valid/conditional.test.js +0 -45
- package/test/tests/valid/curve.test.js +0 -76
- package/test/tests/valid/empty.test.js +0 -17
- package/test/tests/valid/entity.test.js +0 -49
- package/test/tests/valid/enum.test.js +0 -79
- package/test/tests/valid/export.test.js +0 -67
- package/test/tests/valid/inherit.test.js +0 -110
- package/test/tests/valid/intellisense.test.js +0 -39
- package/test/tests/valid/json.test.js +0 -315
- package/test/tests/valid/misc.test.js +0 -54
- package/test/tests/valid/numeric.test.js +0 -103
- package/test/tests/valid/program.test.js +0 -23
- package/test/tests/valid/text.test.js +0 -58
- package/test/tests/valid/vector.test.js +0 -53
- package/test/utils.js +0 -54
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import * as TWEEN from 'https://cdnjs.cloudflare.com/ajax/libs/tween.js/23.1.2/tween.esm.js';
|
|
2
|
-
import confetti from 'https://esm.sh/canvas-confetti@1.6.0';
|
|
3
|
-
import { Script } from 'playcanvas';
|
|
4
|
-
|
|
5
|
-
/** @enum {number} */
|
|
6
|
-
export const MyEnum = { value: 0 };
|
|
7
|
-
|
|
8
|
-
class Example extends Script {
|
|
9
|
-
static scriptName = 'customExample';
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* @attribute
|
|
13
|
-
* @precision 1
|
|
14
|
-
* @type {number}
|
|
15
|
-
*/
|
|
16
|
-
a;
|
|
17
|
-
|
|
18
|
-
initialize() {
|
|
19
|
-
confetti();
|
|
20
|
-
new TWEEN.Tween({ x: 0 }).to({ x: 100 }, 1000).start();
|
|
21
|
-
|
|
22
|
-
// This is an intentional type error, but the parser should ignore these
|
|
23
|
-
this.a = 'string';
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export { Example };
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
// eslint-disable
|
|
2
|
-
import { Script } from 'playcanvas';
|
|
3
|
-
|
|
4
|
-
class Example extends Script {
|
|
5
|
-
/**
|
|
6
|
-
* @attribute
|
|
7
|
-
* @type {string}
|
|
8
|
-
*/
|
|
9
|
-
a;
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* @attribute
|
|
13
|
-
*/
|
|
14
|
-
b = 'example';
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* @attribute
|
|
18
|
-
* @type {string}
|
|
19
|
-
* @placeholder Example text
|
|
20
|
-
*/
|
|
21
|
-
c;
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* @attribute
|
|
25
|
-
* @type {string[]}
|
|
26
|
-
* @size 2
|
|
27
|
-
*/
|
|
28
|
-
d;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export { Example };
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
// eslint-disable-next-line
|
|
2
|
-
import { Script, Vec2, Vec3, Vec4 } from 'playcanvas';
|
|
3
|
-
|
|
4
|
-
class Example extends Script {
|
|
5
|
-
/**
|
|
6
|
-
* @attribute
|
|
7
|
-
* @type {Vec2}
|
|
8
|
-
*/
|
|
9
|
-
a;
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* @attribute
|
|
13
|
-
*/
|
|
14
|
-
b = new Vec3(1, 2, 3);
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* @attribute
|
|
18
|
-
* @type {Vec4[]}
|
|
19
|
-
* @size 2
|
|
20
|
-
*/
|
|
21
|
-
c;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export { Example };
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { expect } from 'chai';
|
|
2
|
-
import { describe, it, before } from 'mocha';
|
|
3
|
-
|
|
4
|
-
import { parseAttributes } from '../../utils.js';
|
|
5
|
-
|
|
6
|
-
describe('INVALID: Asset attribute', function () {
|
|
7
|
-
let data;
|
|
8
|
-
before(async function () {
|
|
9
|
-
data = await parseAttributes('./asset.invalid.js');
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
it('only results should exist', function () {
|
|
13
|
-
expect(data).to.exist;
|
|
14
|
-
expect(data[0]).to.not.be.empty;
|
|
15
|
-
expect(data[1]).to.be.empty;
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
it('Example: should exist with errors (3)', function () {
|
|
19
|
-
expect(data[0]?.example).to.exist;
|
|
20
|
-
expect(data[0].example.attributes).to.not.be.empty;
|
|
21
|
-
expect(data[0].example.errors.length).to.equal(3);
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
it('a: should fallback to an asset attribute without resource', function () {
|
|
25
|
-
expect(data[0].example.attributes.a).to.exist;
|
|
26
|
-
expect(data[0].example.attributes.a.name).to.equal('a');
|
|
27
|
-
expect(data[0].example.attributes.a.type).to.equal('asset');
|
|
28
|
-
expect(data[0].example.attributes.a.default).to.not.exist;
|
|
29
|
-
expect(data[0].example.attributes.a.assetType).to.not.exist;
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
it('b: should fallback to an asset attribute without resource', function () {
|
|
33
|
-
expect(data[0].example.attributes.b).to.exist;
|
|
34
|
-
expect(data[0].example.attributes.b.name).to.equal('b');
|
|
35
|
-
expect(data[0].example.attributes.b.type).to.equal('asset');
|
|
36
|
-
expect(data[0].example.attributes.b.default).to.not.exist;
|
|
37
|
-
expect(data[0].example.attributes.b.assetType).to.not.exist;
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
it('c: should fallback to an asset attribute without resource', function () {
|
|
41
|
-
expect(data[0].example.attributes.c).to.exist;
|
|
42
|
-
expect(data[0].example.attributes.c.name).to.equal('c');
|
|
43
|
-
expect(data[0].example.attributes.c.type).to.equal('asset');
|
|
44
|
-
expect(data[0].example.attributes.c.default).to.not.exist;
|
|
45
|
-
expect(data[0].example.attributes.c.assetType).to.not.exist;
|
|
46
|
-
});
|
|
47
|
-
});
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { expect } from 'chai';
|
|
2
|
-
import { describe, it, before } from 'mocha';
|
|
3
|
-
|
|
4
|
-
import { parseAttributes } from '../../utils.js';
|
|
5
|
-
|
|
6
|
-
describe('INVALID: Curve attribute', function () {
|
|
7
|
-
let data;
|
|
8
|
-
before(async function () {
|
|
9
|
-
data = await parseAttributes('./curve.invalid.js');
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
it('only results should exist', function () {
|
|
13
|
-
expect(data).to.exist;
|
|
14
|
-
expect(data[0]).to.not.be.empty;
|
|
15
|
-
expect(data[1]).to.be.empty;
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
it('Example: should exist with errors (4)', function () {
|
|
19
|
-
expect(data[0]?.example).to.exist;
|
|
20
|
-
expect(data[0].example.attributes).to.not.be.empty;
|
|
21
|
-
expect(data[0].example.errors.length).to.equal(4);
|
|
22
|
-
});
|
|
23
|
-
});
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { expect } from 'chai';
|
|
2
|
-
import { describe, it, before } from 'mocha';
|
|
3
|
-
|
|
4
|
-
import { parseAttributes } from '../../utils.js';
|
|
5
|
-
|
|
6
|
-
describe('INVALID: JSON attribute', function () {
|
|
7
|
-
let data;
|
|
8
|
-
before(async function () {
|
|
9
|
-
data = await parseAttributes('./json.invalid.js');
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
it('only results should exist', function () {
|
|
13
|
-
expect(data).to.exist;
|
|
14
|
-
expect(data[0]).to.not.be.empty;
|
|
15
|
-
expect(data[1]).to.be.empty;
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
it('Example: should exist with errors (1)', function () {
|
|
19
|
-
expect(data[0]?.example).to.exist;
|
|
20
|
-
expect(data[0].example.attributes).to.be.empty;
|
|
21
|
-
expect(data[0].example.errors.length).to.equal(1);
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
it('o: should not be recognised as an attribute (type not an interface)', function () {
|
|
25
|
-
expect(data[0].example.attributes.o).to.not.exist;
|
|
26
|
-
});
|
|
27
|
-
});
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { expect } from 'chai';
|
|
2
|
-
import { describe, it, before } from 'mocha';
|
|
3
|
-
|
|
4
|
-
import { parseAttributes } from '../../utils.js';
|
|
5
|
-
|
|
6
|
-
describe('INVALID: Misc attribute types', function () {
|
|
7
|
-
let data;
|
|
8
|
-
before(async function () {
|
|
9
|
-
data = await parseAttributes('./misc.invalid.js');
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
it('only results should exist', function () {
|
|
13
|
-
expect(data).to.exist;
|
|
14
|
-
expect(data[0]).to.not.be.empty;
|
|
15
|
-
expect(data[1]).to.be.empty;
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
it('Example: should exist with attributes and errors (4)', function () {
|
|
19
|
-
expect(data[0].example).to.exist;
|
|
20
|
-
expect(data[0].example.attributes).to.not.be.empty;
|
|
21
|
-
expect(data[0].example.errors.length).to.equal(3);
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
it('e: should not be recognised as an attribute (cannot infer GraphNode type)', function () {
|
|
25
|
-
expect(data[0].example.attributes.e).to.not.exist;
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
it('f: should not be recognised as an attribute (cannot infer custom Vec3 type)', function () {
|
|
29
|
-
expect(data[0].example.attributes.f).to.not.exist;
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
it('g: should fallback to a numeric attribute array without size', function () {
|
|
33
|
-
expect(data[0].example.attributes.g).to.exist;
|
|
34
|
-
expect(data[0].example.attributes.g.name).to.equal('g');
|
|
35
|
-
expect(data[0].example.attributes.g.type).to.equal('number');
|
|
36
|
-
expect(data[0].example.attributes.g.array).to.equal(true);
|
|
37
|
-
expect(data[0].example.attributes.g.default).to.not.exist;
|
|
38
|
-
expect(data[0].example.attributes.g.size).to.not.exist;
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
});
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { expect } from 'chai';
|
|
2
|
-
import { describe, it, before } from 'mocha';
|
|
3
|
-
|
|
4
|
-
import { parseAttributes } from '../../utils.js';
|
|
5
|
-
|
|
6
|
-
describe('INVALID: Numeric attribute', function () {
|
|
7
|
-
let data;
|
|
8
|
-
before(async function () {
|
|
9
|
-
data = await parseAttributes('./numeric.invalid.js');
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
it('only results should exist', function () {
|
|
13
|
-
expect(data).to.exist;
|
|
14
|
-
expect(data[0]).to.not.be.empty;
|
|
15
|
-
expect(data[1]).to.be.empty;
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
it('Example: should exist with attributes and errors (6)', function () {
|
|
19
|
-
expect(data[0]?.example).to.exist;
|
|
20
|
-
expect(data[0].example.attributes).to.not.be.empty;
|
|
21
|
-
expect(data[0].example.errors.length).to.equal(6);
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
it('a: should fallback to a numeric attribute without range', function () {
|
|
25
|
-
expect(data[0].example.attributes.a).to.exist;
|
|
26
|
-
expect(data[0].example.attributes.a.name).to.equal('a');
|
|
27
|
-
expect(data[0].example.attributes.a.type).to.equal('number');
|
|
28
|
-
expect(data[0].example.attributes.a.array).to.equal(false);
|
|
29
|
-
expect(data[0].example.attributes.a.default).to.equal(0);
|
|
30
|
-
expect(data[0].example.attributes.a.min).to.not.exist;
|
|
31
|
-
expect(data[0].example.attributes.a.max).to.not.exist;
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
it('b: should not be recognised as an attribute (step tag dropped)', function () {
|
|
35
|
-
expect(data[0].example.attributes.b).to.not.exist;
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
it('c: should not be recognised as an attribute (precision tag dropped)', function () {
|
|
39
|
-
expect(data[0].example.attributes.c).to.not.exist;
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
it('d: should fallback to a numeric attribute without step and precision', function () {
|
|
43
|
-
expect(data[0].example.attributes.d).to.exist;
|
|
44
|
-
expect(data[0].example.attributes.d.name).to.equal('d');
|
|
45
|
-
expect(data[0].example.attributes.d.type).to.equal('number');
|
|
46
|
-
expect(data[0].example.attributes.d.array).to.equal(false);
|
|
47
|
-
expect(data[0].example.attributes.d.step).to.not.exist;
|
|
48
|
-
expect(data[0].example.attributes.d.precision).to.not.exist;
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
it('e: should not be recognised as an attribute (step tag dropped)', function () {
|
|
52
|
-
expect(data[0].example.attributes.e).to.exist;
|
|
53
|
-
expect(data[0].example.attributes.e.step).to.not.exist;
|
|
54
|
-
});
|
|
55
|
-
});
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { expect } from 'chai';
|
|
2
|
-
import { describe, it, before } from 'mocha';
|
|
3
|
-
|
|
4
|
-
import { parseAttributes } from '../../utils.js';
|
|
5
|
-
|
|
6
|
-
describe('INVALID: Program ', function () {
|
|
7
|
-
let data;
|
|
8
|
-
before(async function () {
|
|
9
|
-
data = await parseAttributes('./program.invalid.js');
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
it('only errors should exist (1)', function () {
|
|
13
|
-
expect(data).to.exist;
|
|
14
|
-
expect(data[0]).to.be.empty;
|
|
15
|
-
expect(data[1].length).to.equal(4);
|
|
16
|
-
});
|
|
17
|
-
});
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { expect } from 'chai';
|
|
2
|
-
import { describe, it, before } from 'mocha';
|
|
3
|
-
|
|
4
|
-
import { parseAttributes } from '../../utils.js';
|
|
5
|
-
|
|
6
|
-
describe('INVALID: Vector attribute', function () {
|
|
7
|
-
let data;
|
|
8
|
-
before(async function () {
|
|
9
|
-
data = await parseAttributes('./vector.invalid.js');
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
it('only results should exist', function () {
|
|
13
|
-
expect(data).to.exist;
|
|
14
|
-
expect(data[0]).to.not.be.empty;
|
|
15
|
-
expect(data[1]).to.be.empty;
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
it('Example: should exist with errors (1)', function () {
|
|
19
|
-
expect(data[0]?.example).to.exist;
|
|
20
|
-
expect(data[0].example.attributes).to.be.empty;
|
|
21
|
-
expect(data[0].example.errors.length).to.equal(1);
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
it('d: should not be recognized as an attribute (extends vector and not is vector)', function () {
|
|
25
|
-
expect(data[0].example.attributes.d).to.not.exist;
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
});
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { expect } from 'chai';
|
|
2
|
-
import { describe, it, before } from 'mocha';
|
|
3
|
-
|
|
4
|
-
import { parseAttributes } from '../../utils.js';
|
|
5
|
-
|
|
6
|
-
function runTests(fileName) {
|
|
7
|
-
|
|
8
|
-
const isTS = fileName.endsWith('.ts');
|
|
9
|
-
const script = isTS ? 'TS' : 'JS';
|
|
10
|
-
|
|
11
|
-
describe(`${script}: VALID: Asset attribute`, function () {
|
|
12
|
-
let data;
|
|
13
|
-
before(async function () {
|
|
14
|
-
data = await parseAttributes(fileName);
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
it('only results should exist', function () {
|
|
18
|
-
expect(data).to.exist;
|
|
19
|
-
expect(data[0]).to.not.be.empty;
|
|
20
|
-
expect(data[1]).to.be.empty;
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
it('Example: should exist without errors', function () {
|
|
24
|
-
expect(data[0]?.example).to.exist;
|
|
25
|
-
expect(data[0].example.attributes).to.not.be.empty;
|
|
26
|
-
expect(data[0].example.errors).to.be.empty;
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
it('a: should be a asset attribute', function () {
|
|
30
|
-
expect(data[0].example.attributes.a).to.exist;
|
|
31
|
-
expect(data[0].example.attributes.a.name).to.equal('a');
|
|
32
|
-
expect(data[0].example.attributes.a.type).to.equal('asset');
|
|
33
|
-
expect(data[0].example.attributes.a.array).to.equal(false);
|
|
34
|
-
expect(data[0].example.attributes.a.default).to.equal(null);
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
it('b: should be a asset attribute with a texture resource', function () {
|
|
38
|
-
expect(data[0].example.attributes.b).to.exist;
|
|
39
|
-
expect(data[0].example.attributes.b.name).to.equal('b');
|
|
40
|
-
expect(data[0].example.attributes.b.type).to.equal('asset');
|
|
41
|
-
expect(data[0].example.attributes.b.array).to.equal(false);
|
|
42
|
-
expect(data[0].example.attributes.b.default).to.equal(null);
|
|
43
|
-
expect(data[0].example.attributes.b.assetType).to.equal('texture');
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
it('c: should be a asset attribute array with a container resource', function () {
|
|
47
|
-
expect(data[0].example.attributes.c).to.exist;
|
|
48
|
-
expect(data[0].example.attributes.c.name).to.equal('c');
|
|
49
|
-
expect(data[0].example.attributes.c.type).to.equal('asset');
|
|
50
|
-
expect(data[0].example.attributes.c.array).to.equal(true);
|
|
51
|
-
expect(data[0].example.attributes.c.default).to.equal(null);
|
|
52
|
-
expect(data[0].example.attributes.c.assetType).to.equal('container');
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
runTests('./asset.valid.js');
|
|
59
|
-
runTests('./asset.valid.ts');
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { expect } from 'chai';
|
|
2
|
-
import { describe, it, before } from 'mocha';
|
|
3
|
-
|
|
4
|
-
import { parseAttributes } from '../../utils.js';
|
|
5
|
-
|
|
6
|
-
function runTests(fileName) {
|
|
7
|
-
|
|
8
|
-
const isTS = fileName.endsWith('.ts');
|
|
9
|
-
const script = isTS ? 'TS' : 'JS';
|
|
10
|
-
|
|
11
|
-
describe(`${script}: VALID: Checkbox attribute`, function () {
|
|
12
|
-
let data;
|
|
13
|
-
before(async function () {
|
|
14
|
-
data = await parseAttributes(fileName);
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
it('only results should exist', function () {
|
|
18
|
-
expect(data).to.exist;
|
|
19
|
-
expect(data[0]).to.not.be.empty;
|
|
20
|
-
expect(data[1]).to.be.empty;
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
it('Example: should exist without errors', function () {
|
|
24
|
-
expect(data[0]?.example).to.exist;
|
|
25
|
-
expect(data[0].example.attributes).to.not.be.empty;
|
|
26
|
-
expect(data[0].example.errors).to.be.empty;
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
it('a: should be a checkbox attribute', function () {
|
|
30
|
-
expect(data[0].example.attributes.a).to.exist;
|
|
31
|
-
expect(data[0].example.attributes.a.name).to.equal('a');
|
|
32
|
-
expect(data[0].example.attributes.a.type).to.equal('boolean');
|
|
33
|
-
expect(data[0].example.attributes.a.array).to.equal(false);
|
|
34
|
-
expect(data[0].example.attributes.a.default).to.equal(false);
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
it('b: should be a checkbox attribute with a default value', function () {
|
|
38
|
-
expect(data[0].example.attributes.b).to.exist;
|
|
39
|
-
expect(data[0].example.attributes.b.name).to.equal('b');
|
|
40
|
-
expect(data[0].example.attributes.b.type).to.equal('boolean');
|
|
41
|
-
expect(data[0].example.attributes.b.array).to.equal(false);
|
|
42
|
-
expect(data[0].example.attributes.b.default).to.equal(true);
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
it('c: should be a checkbox attribute array with a size', function () {
|
|
46
|
-
expect(data[0].example.attributes.c).to.exist;
|
|
47
|
-
expect(data[0].example.attributes.c.name).to.equal('c');
|
|
48
|
-
expect(data[0].example.attributes.c.type).to.equal('boolean');
|
|
49
|
-
expect(data[0].example.attributes.c.array).to.equal(true);
|
|
50
|
-
expect(data[0].example.attributes.c.size).to.equal(2);
|
|
51
|
-
expect(data[0].example.attributes.c.default).equal(null);
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
runTests('./checkbox.valid.js');
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { expect } from 'chai';
|
|
2
|
-
import { describe, it, before } from 'mocha';
|
|
3
|
-
|
|
4
|
-
import { parseAttributes } from '../../utils.js';
|
|
5
|
-
|
|
6
|
-
describe('VALID: Color attribute', function () {
|
|
7
|
-
let data;
|
|
8
|
-
before(async function () {
|
|
9
|
-
data = await parseAttributes('./color.valid.js');
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
it('only results should exist', function () {
|
|
13
|
-
expect(data).to.exist;
|
|
14
|
-
expect(data[0]).to.not.be.empty;
|
|
15
|
-
expect(data[1]).to.be.empty;
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
it('Example: should exist without errors', function () {
|
|
19
|
-
expect(data[0]?.example).to.exist;
|
|
20
|
-
expect(data[0].example.attributes).to.not.be.empty;
|
|
21
|
-
expect(data[0].example.errors).to.be.empty;
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
it('a: should be a color attribute', function () {
|
|
25
|
-
expect(data[0].example.attributes.a).to.exist;
|
|
26
|
-
expect(data[0].example.attributes.a.name).to.equal('a');
|
|
27
|
-
expect(data[0].example.attributes.a.type).to.equal('rgba');
|
|
28
|
-
expect(data[0].example.attributes.a.array).to.equal(false);
|
|
29
|
-
expect(data[0].example.attributes.a.default).to.eql([1, 1, 1, 1]);
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
it('b: should be a color attribute with a default value', function () {
|
|
33
|
-
expect(data[0].example.attributes.b).to.exist;
|
|
34
|
-
expect(data[0].example.attributes.b.name).to.equal('b');
|
|
35
|
-
expect(data[0].example.attributes.b.type).to.equal('rgba');
|
|
36
|
-
expect(data[0].example.attributes.b.array).to.equal(false);
|
|
37
|
-
expect(data[0].example.attributes.b.default).to.eql([1, 0, 0, 1]);
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
it('c: should be a color attribute array with a size', function () {
|
|
41
|
-
expect(data[0].example.attributes.c).to.exist;
|
|
42
|
-
expect(data[0].example.attributes.c.name).to.equal('c');
|
|
43
|
-
expect(data[0].example.attributes.c.type).to.equal('rgba');
|
|
44
|
-
expect(data[0].example.attributes.c.array).to.equal(true);
|
|
45
|
-
expect(data[0].example.attributes.c.size).to.equal(2);
|
|
46
|
-
expect(data[0].example.attributes.c.default).equal(null);
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
});
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { expect } from 'chai';
|
|
2
|
-
import { describe, it, before } from 'mocha';
|
|
3
|
-
|
|
4
|
-
import { parseAttributes } from '../../utils.js';
|
|
5
|
-
|
|
6
|
-
describe('VALID: Conditional Tags', function () {
|
|
7
|
-
let data;
|
|
8
|
-
before(async function () {
|
|
9
|
-
data = await parseAttributes('./conditional.valid.js');
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
it('only results should exist', function () {
|
|
13
|
-
expect(data).to.exist;
|
|
14
|
-
expect(data[0]).to.not.be.empty;
|
|
15
|
-
expect(data[1]).to.be.empty;
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
it('Example: should exist without errors', function () {
|
|
19
|
-
expect(data[0]?.example).to.exist;
|
|
20
|
-
expect(data[0].example.attributes).to.not.be.empty;
|
|
21
|
-
expect(data[0].example.errors).to.be.empty;
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
it('a: should conditional `@visibleif` tag', function () {
|
|
25
|
-
expect(data[0].example.attributes.a).exist;
|
|
26
|
-
expect(data[0].example.attributes.a.name).to.equal('a');
|
|
27
|
-
expect(data[0].example.attributes.a.type).to.equal('number');
|
|
28
|
-
expect(data[0].example.attributes.a.visibleif).to.equal('b === 2');
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
it('b: should conditional `@enabledif` tag', function () {
|
|
32
|
-
expect(data[0].example.attributes.b).exist;
|
|
33
|
-
expect(data[0].example.attributes.b.name).to.equal('b');
|
|
34
|
-
expect(data[0].example.attributes.b.type).to.equal('number');
|
|
35
|
-
expect(data[0].example.attributes.b.enabledif).to.equal('a === 3');
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
it('c: should not include `@enabledif` or `@visibleif` tag if none is declared', function () {
|
|
39
|
-
expect(data[0].example.attributes.c).exist;
|
|
40
|
-
expect(data[0].example.attributes.c.name).to.equal('c');
|
|
41
|
-
expect(data[0].example.attributes.c.type).to.equal('number');
|
|
42
|
-
expect(data[0].example.attributes.c.enabledif).to.not.exist;
|
|
43
|
-
expect(data[0].example.attributes.c.visibleif).to.not.exist;
|
|
44
|
-
});
|
|
45
|
-
});
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import { expect } from 'chai';
|
|
2
|
-
import { describe, it, before } from 'mocha';
|
|
3
|
-
|
|
4
|
-
import { parseAttributes } from '../../utils.js';
|
|
5
|
-
|
|
6
|
-
describe('VALID: Curve attribute', function () {
|
|
7
|
-
let data;
|
|
8
|
-
before(async function () {
|
|
9
|
-
data = await parseAttributes('./curve.valid.js');
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
it('only results should exist', function () {
|
|
13
|
-
expect(data).to.exist;
|
|
14
|
-
expect(data[0]).to.not.be.empty;
|
|
15
|
-
expect(data[1]).to.be.empty;
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
it('Example: should exist without errors', function () {
|
|
19
|
-
expect(data[0]?.example).to.exist;
|
|
20
|
-
expect(data[0].example.attributes).to.not.be.empty;
|
|
21
|
-
expect(data[0].example.errors).to.be.empty;
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
it('a: should be a curve attribute', function () {
|
|
25
|
-
expect(data[0].example.attributes.a).exist;
|
|
26
|
-
expect(data[0].example.attributes.a.name).to.equal('a');
|
|
27
|
-
expect(data[0].example.attributes.a.type).to.equal('curve');
|
|
28
|
-
expect(data[0].example.attributes.a.array).to.equal(false);
|
|
29
|
-
expect(data[0].example.attributes.a.default).to.not.exist;
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
it('b: should be a curve attribute with a default value', function () {
|
|
33
|
-
expect(data[0].example.attributes.b).exist;
|
|
34
|
-
expect(data[0].example.attributes.b.name).to.equal('b');
|
|
35
|
-
expect(data[0].example.attributes.b.type).to.equal('curve');
|
|
36
|
-
expect(data[0].example.attributes.b.array).to.equal(false);
|
|
37
|
-
expect(data[0].example.attributes.b.default).to.eql([0, 0, 1, 1]);
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
it('c: should be a curve attribute with a color', function () {
|
|
41
|
-
expect(data[0].example.attributes.c).exist;
|
|
42
|
-
expect(data[0].example.attributes.c.name).to.equal('c');
|
|
43
|
-
expect(data[0].example.attributes.c.type).to.equal('curve');
|
|
44
|
-
expect(data[0].example.attributes.c.array).to.equal(false);
|
|
45
|
-
expect(data[0].example.attributes.a.default).to.not.exist;
|
|
46
|
-
expect(data[0].example.attributes.c.color).to.equal('r');
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
it('d: should be a curve attribute with a color and curve', function () {
|
|
50
|
-
expect(data[0].example.attributes.d).exist;
|
|
51
|
-
expect(data[0].example.attributes.d.name).to.equal('d');
|
|
52
|
-
expect(data[0].example.attributes.d.type).to.equal('curve');
|
|
53
|
-
expect(data[0].example.attributes.d.array).to.equal(false);
|
|
54
|
-
expect(data[0].example.attributes.a.default).to.not.exist;
|
|
55
|
-
expect(data[0].example.attributes.d.color).to.equal('rgb');
|
|
56
|
-
expect(data[0].example.attributes.d.curves).to.deep.equal(['x', 'y', 'z']);
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
it('e: should be a curve attribute array with a size', function () {
|
|
60
|
-
expect(data[0].example.attributes.e).exist;
|
|
61
|
-
expect(data[0].example.attributes.e.name).to.equal('e');
|
|
62
|
-
expect(data[0].example.attributes.e.type).to.equal('curve');
|
|
63
|
-
expect(data[0].example.attributes.e.array).to.equal(true);
|
|
64
|
-
expect(data[0].example.attributes.e.size).to.equal(2);
|
|
65
|
-
expect(data[0].example.attributes.e.default).to.not.exist;
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
it('f: should be a curve attribute in an unsual format', function () {
|
|
69
|
-
expect(data[0].example.attributes.f).exist;
|
|
70
|
-
expect(data[0].example.attributes.f.name).to.equal('f');
|
|
71
|
-
expect(data[0].example.attributes.f.type).to.equal('curve');
|
|
72
|
-
expect(data[0].example.attributes.f.array).to.equal(false);
|
|
73
|
-
expect(data[0].example.attributes.f.color).to.equal('rgba');
|
|
74
|
-
expect(data[0].example.attributes.f.curves).to.deep.equal(['x', 'y', 'z']);
|
|
75
|
-
});
|
|
76
|
-
});
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { expect } from 'chai';
|
|
2
|
-
import { describe, it, before } from 'mocha';
|
|
3
|
-
|
|
4
|
-
import { parseAttributes } from '../../utils.js';
|
|
5
|
-
|
|
6
|
-
describe('VALID: Program ', function () {
|
|
7
|
-
let data;
|
|
8
|
-
before(async function () {
|
|
9
|
-
data = await parseAttributes('./empty.valid.js');
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
it('only results should exist', function () {
|
|
13
|
-
expect(data).to.exist;
|
|
14
|
-
expect(data[0]).to.be.empty;
|
|
15
|
-
expect(data[1]).to.be.empty;
|
|
16
|
-
});
|
|
17
|
-
});
|