@playcanvas/attribute-parser 1.6.1 → 1.7.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/LICENSE.md +19 -0
- package/dist/index.js +194566 -0
- package/dist/libs.d.ts +50978 -0
- package/package.json +49 -9
- 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/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,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: Entity attribute', function () {
|
|
7
|
-
let data;
|
|
8
|
-
before(async function () {
|
|
9
|
-
data = await parseAttributes('./entity.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 entity 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('entity');
|
|
28
|
-
expect(data[0].example.attributes.a.array).to.equal(false);
|
|
29
|
-
expect(data[0].example.attributes.a.default).to.equal(null);
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
it('b: should be a entity 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('entity');
|
|
36
|
-
expect(data[0].example.attributes.b.array).to.equal(false);
|
|
37
|
-
expect(data[0].example.attributes.b.default).to.equal(null);
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
it('c: should be a entity 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('entity');
|
|
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,79 +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: Enum 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.errors).to.be.empty;
|
|
26
|
-
expect(data[0].example.attributes).to.not.be.empty;
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
it('e: should be a enum attribute', function () {
|
|
30
|
-
expect(data[0].example.attributes.e).to.exist;
|
|
31
|
-
expect(data[0].example.attributes.e.name).to.equal('e');
|
|
32
|
-
expect(data[0].example.attributes.e.type).to.equal('number');
|
|
33
|
-
expect(data[0].example.attributes.e.array).to.equal(false);
|
|
34
|
-
expect(data[0].example.attributes.e.default).to.equal(13);
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
it('f: should be a enum attribute with a default value', function () {
|
|
38
|
-
expect(data[0].example.attributes.f).to.exist;
|
|
39
|
-
expect(data[0].example.attributes.f.name).to.equal('f');
|
|
40
|
-
expect(data[0].example.attributes.f.type).to.equal('number');
|
|
41
|
-
expect(data[0].example.attributes.f.array).to.equal(false);
|
|
42
|
-
expect(data[0].example.attributes.f.default).to.equal(1);
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
it('g: should be a enum attribute array with a size', function () {
|
|
46
|
-
expect(data[0].example.attributes.g).to.exist;
|
|
47
|
-
expect(data[0].example.attributes.g.name).to.equal('g');
|
|
48
|
-
expect(data[0].example.attributes.g.type).to.equal('number');
|
|
49
|
-
expect(data[0].example.attributes.g.array).to.equal(true);
|
|
50
|
-
expect(data[0].example.attributes.g.size).to.equal(2);
|
|
51
|
-
expect(data[0].example.attributes.g.default).equal(null);
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
it('h: should be a enum attribute', function () {
|
|
55
|
-
expect(data[0].example.attributes.h).to.exist;
|
|
56
|
-
expect(data[0].example.attributes.h.name).to.equal('h');
|
|
57
|
-
expect(data[0].example.attributes.h.type).to.equal('string');
|
|
58
|
-
expect(data[0].example.attributes.h.array).to.equal(false);
|
|
59
|
-
expect(data[0].example.attributes.h.enum).to.be.an('array').with.lengthOf(4);
|
|
60
|
-
expect(data[0].example.attributes.h.enum[0]).to.deep.equal({ A: 'a' });
|
|
61
|
-
expect(data[0].example.attributes.h.enum[1]).to.deep.equal({ B: 'b' });
|
|
62
|
-
expect(data[0].example.attributes.h.enum[2]).to.deep.equal({ C: 'c' });
|
|
63
|
-
expect(data[0].example.attributes.h.enum[3]).to.deep.equal({ 'A string key': 'd' });
|
|
64
|
-
expect(data[0].example.attributes.h.default).to.equal('');
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
it('j: should be a enum attribute array with a size', function () {
|
|
68
|
-
expect(data[0].example.attributes.i).to.exist;
|
|
69
|
-
expect(data[0].example.attributes.i.name).to.equal('i');
|
|
70
|
-
expect(data[0].example.attributes.i.type).to.equal('number');
|
|
71
|
-
expect(data[0].example.attributes.i.array).to.equal(false);
|
|
72
|
-
expect(data[0].example.attributes.i.default).equal(2);
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
runTests('./enum.valid.js');
|
|
79
|
-
runTests('./enum.valid.ts');
|
|
@@ -1,67 +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: Export Script', function () {
|
|
7
|
-
let data;
|
|
8
|
-
before(async function () {
|
|
9
|
-
data = await parseAttributes('./export.valid.js', './export.import.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', 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('ExampleExport: should exist without attributes or errors', function () {
|
|
25
|
-
expect(data[0]?.exampleExport).to.exist;
|
|
26
|
-
expect(data[0].exampleExport.attributes).to.be.empty;
|
|
27
|
-
expect(data[0].exampleExport.errors).to.be.empty;
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
it('ExampleDefault: should exist without attributes or errors', function () {
|
|
31
|
-
expect(data[0]?.exampleDefault).to.exist;
|
|
32
|
-
expect(data[0].exampleDefault.attributes).to.be.empty;
|
|
33
|
-
expect(data[0].exampleDefault.errors).to.be.empty;
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
it('ExampleImportAsExport: should not exist', function () {
|
|
37
|
-
expect(data[0]?.exampleImportAsExport).to.exist;
|
|
38
|
-
expect(data[0].exampleImportAsExport.attributes).to.not.be.empty;
|
|
39
|
-
expect(data[0].exampleImportAsExport.errors).to.be.empty;
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
it('ExampleExportAs: should not exist', function () {
|
|
43
|
-
expect(data[0]?.exampleExportAs).to.exist;
|
|
44
|
-
expect(data[0].exampleExportAs.attributes).to.not.be.empty;
|
|
45
|
-
expect(data[0].exampleExportAs.errors).to.be.empty;
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
it('ExampleImport: should exist with attributes', function () {
|
|
49
|
-
expect(data[0]?.exampleImport).to.exist;
|
|
50
|
-
expect(data[0].exampleImport.attributes).to.not.be.empty;
|
|
51
|
-
expect(data[0].exampleImport.attributes.prop.type).to.equal('number');
|
|
52
|
-
expect(data[0].exampleImport.attributes.prop.default).to.equal(10);
|
|
53
|
-
expect(data[0].exampleImport.errors).to.be.empty;
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
it('ExampleImportExtend: should exist with attributes', function () {
|
|
57
|
-
expect(data[0]?.exampleImportExtend).to.exist;
|
|
58
|
-
expect(data[0].exampleImportExtend.attributes).to.not.be.empty;
|
|
59
|
-
expect(data[0].exampleImportExtend.attributes.prop.type).to.equal('number');
|
|
60
|
-
expect(data[0].exampleImportExtend.attributes.prop.default).to.equal(10);
|
|
61
|
-
expect(data[0].exampleImportExtend.errors).to.be.empty;
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
it('ExampleNotExported: should not exist (not exported)', function () {
|
|
65
|
-
expect(data[0]?.exampleNotExported).to.not.exist;
|
|
66
|
-
});
|
|
67
|
-
});
|
|
@@ -1,110 +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: Script inheritance attributes', function () {
|
|
7
|
-
let data;
|
|
8
|
-
before(async function () {
|
|
9
|
-
data = await parseAttributes('./inherit.valid.js', './example.dep.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('ExampleExtended: should exist without errors', function () {
|
|
25
|
-
expect(data[0]?.exampleExtended).to.exist;
|
|
26
|
-
expect(data[0].exampleExtended.attributes).to.not.be.empty;
|
|
27
|
-
expect(data[0].exampleExtended.attributes.a).to.exist;
|
|
28
|
-
expect(data[0].exampleExtended.attributes.a.type).to.equal('boolean');
|
|
29
|
-
expect(data[0].exampleExtended.attributes.a.array).to.equal(false);
|
|
30
|
-
expect(data[0].exampleExtended.attributes.a.default).to.equal(false);
|
|
31
|
-
expect(data[0].exampleExtended.attributes.b).to.be.exists;
|
|
32
|
-
expect(data[0].exampleExtended.attributes.b.type).to.equal('number');
|
|
33
|
-
expect(data[0].exampleExtended.attributes.b.array).to.equal(false);
|
|
34
|
-
expect(data[0].exampleExtended.attributes.b.default).to.equal(0);
|
|
35
|
-
expect(data[0].exampleExtended.errors).to.be.empty;
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
it('ExampleExtendedExtended: should exist without errors', function () {
|
|
39
|
-
expect(data[0]?.exampleExtendedExtended).to.exist;
|
|
40
|
-
expect(data[0].exampleExtendedExtended.attributes).to.not.be.empty;
|
|
41
|
-
expect(data[0].exampleExtendedExtended.errors).to.be.empty;
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
it('ExampleAlias: should exist without errors', function () {
|
|
45
|
-
expect(data[0]?.exampleAlias).to.exist;
|
|
46
|
-
expect(data[0].exampleAlias.attributes).to.not.be.empty;
|
|
47
|
-
expect(data[0].exampleAlias.errors).to.be.empty;
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
it('Example#a: should be a checkbox attribute', function () {
|
|
51
|
-
expect(data[0].example.attributes.a).to.exist;
|
|
52
|
-
expect(data[0].example.attributes.a.name).to.equal('a');
|
|
53
|
-
expect(data[0].example.attributes.a.type).to.equal('boolean');
|
|
54
|
-
expect(data[0].example.attributes.a.array).to.equal(false);
|
|
55
|
-
expect(data[0].example.attributes.a.default).to.equal(false);
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
it('ExampleExtended#a: should be a checkbox attribute', function () {
|
|
59
|
-
expect(data[0].exampleExtended.attributes.a).to.exist;
|
|
60
|
-
expect(data[0].exampleExtended.attributes.a.name).to.equal('a');
|
|
61
|
-
expect(data[0].exampleExtended.attributes.a.type).to.equal('boolean');
|
|
62
|
-
expect(data[0].exampleExtended.attributes.a.array).to.equal(false);
|
|
63
|
-
expect(data[0].exampleExtended.attributes.a.default).to.equal(false);
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
it('ExampleExtended#b: should be a numeric attribute', function () {
|
|
67
|
-
expect(data[0].exampleExtended.attributes.b).to.exist;
|
|
68
|
-
expect(data[0].exampleExtended.attributes.b.name).to.equal('b');
|
|
69
|
-
expect(data[0].exampleExtended.attributes.b.type).to.equal('number');
|
|
70
|
-
expect(data[0].exampleExtended.attributes.b.array).to.equal(false);
|
|
71
|
-
expect(data[0].exampleExtended.attributes.b.default).to.equal(0);
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
it('ExampleExtendedExtended#a: should be a checkbox attribute', function () {
|
|
75
|
-
expect(data[0].exampleExtendedExtended.attributes.a).to.exist;
|
|
76
|
-
expect(data[0].exampleExtendedExtended.attributes.a.name).to.equal('a');
|
|
77
|
-
expect(data[0].exampleExtendedExtended.attributes.a.type).to.equal('boolean');
|
|
78
|
-
expect(data[0].exampleExtendedExtended.attributes.a.array).to.equal(false);
|
|
79
|
-
expect(data[0].exampleExtendedExtended.attributes.a.default).to.equal(false);
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
it('ExampleExtendedExtended#b: should be a numeric attribute', function () {
|
|
83
|
-
expect(data[0].exampleExtendedExtended.attributes.b).to.exist;
|
|
84
|
-
expect(data[0].exampleExtendedExtended.attributes.b.name).to.equal('b');
|
|
85
|
-
expect(data[0].exampleExtendedExtended.attributes.b.type).to.equal('number');
|
|
86
|
-
expect(data[0].exampleExtendedExtended.attributes.b.array).to.equal(false);
|
|
87
|
-
expect(data[0].exampleExtendedExtended.attributes.b.default).to.equal(0);
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
it('ExampleExtendedExtended#c: should be a string attribute', function () {
|
|
91
|
-
expect(data[0].exampleExtendedExtended.attributes.c).to.exist;
|
|
92
|
-
expect(data[0].exampleExtendedExtended.attributes.c.name).to.equal('c');
|
|
93
|
-
expect(data[0].exampleExtendedExtended.attributes.c.type).to.equal('string');
|
|
94
|
-
expect(data[0].exampleExtendedExtended.attributes.c.array).to.equal(false);
|
|
95
|
-
expect(data[0].exampleExtendedExtended.attributes.c.default).to.equal('');
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
it('ExampleAlias#a: should be a checkbox attribute', function () {
|
|
99
|
-
expect(data[0].exampleAlias.attributes.a).to.exist;
|
|
100
|
-
expect(data[0].exampleAlias.attributes.a.name).to.equal('a');
|
|
101
|
-
expect(data[0].exampleAlias.attributes.a.type).to.equal('boolean');
|
|
102
|
-
expect(data[0].exampleAlias.attributes.a.array).to.equal(false);
|
|
103
|
-
expect(data[0].exampleAlias.attributes.a.default).to.equal(false);
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
it('ExampleNoExtend: should not exist (does not extend Script)', function () {
|
|
107
|
-
expect(data[0].exampleNoExtend).to.not.exist;
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
});
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { expect } from 'chai';
|
|
2
|
-
import { describe, it, before } from 'mocha';
|
|
3
|
-
|
|
4
|
-
import { getAttributes } from '../../utils.js';
|
|
5
|
-
|
|
6
|
-
describe('VALID: Intellisense Parsing', function () {
|
|
7
|
-
|
|
8
|
-
let data;
|
|
9
|
-
before(async function () {
|
|
10
|
-
data = await getAttributes('./intellisense.valid.js');
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
it('only results should exist', function () {
|
|
14
|
-
expect(data).to.exist;
|
|
15
|
-
expect(data[0]).to.not.be.empty;
|
|
16
|
-
expect(data[1]).to.be.empty;
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
it('Example: should exist', function () {
|
|
20
|
-
expect(data[0]?.example).to.exist;
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
it('does not return static members', function () {
|
|
24
|
-
expect(data[0].example[0].name).to.not.equal('scriptName');
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
it('attributes have correct types', function () {
|
|
28
|
-
expect(data[0].folder[0].type).to.equal('any');
|
|
29
|
-
expect(data[0].folder[1].type).to.equal('number');
|
|
30
|
-
|
|
31
|
-
expect(data[0].example[0].type).to.equal('any');
|
|
32
|
-
expect(data[0].example[1].type).to.equal('number');
|
|
33
|
-
expect(data[0].example[2].type).to.equal('boolean');
|
|
34
|
-
expect(data[0].example[3].type).to.equal('string');
|
|
35
|
-
expect(data[0].example[4].type).to.equal('{}');
|
|
36
|
-
expect(data[0].example[5].type).to.equal('Vec3');
|
|
37
|
-
expect(data[0].example[6].type).to.equal('Folder');
|
|
38
|
-
});
|
|
39
|
-
});
|
|
@@ -1,315 +0,0 @@
|
|
|
1
|
-
import { expect } from 'chai';
|
|
2
|
-
import { describe, it, before } from 'mocha';
|
|
3
|
-
|
|
4
|
-
import { parseAttributes } from '../../utils.js';
|
|
5
|
-
|
|
6
|
-
describe('JS: VALID: Asset attribute', function () {
|
|
7
|
-
|
|
8
|
-
let data;
|
|
9
|
-
before(async function () {
|
|
10
|
-
data = await parseAttributes('./json.valid.js');
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
it('only results should exist', function () {
|
|
14
|
-
expect(data).to.exist;
|
|
15
|
-
expect(data[0]).to.not.be.empty;
|
|
16
|
-
expect(data[1]).to.be.empty;
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
it('Example: should exist without errors', function () {
|
|
20
|
-
expect(data[0]?.example).to.exist;
|
|
21
|
-
expect(data[0].example.attributes).to.not.be.empty;
|
|
22
|
-
expect(data[0].example.errors).to.be.empty;
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
it('f: should be a json attribute', function () {
|
|
26
|
-
expect(data[0].example.attributes.f).to.exist;
|
|
27
|
-
expect(data[0].example.attributes.f.name).to.equal('f');
|
|
28
|
-
expect(data[0].example.attributes.f.type).to.equal('json');
|
|
29
|
-
expect(data[0].example.attributes.f.array).to.equal(false);
|
|
30
|
-
expect(data[0].example.attributes.f.default).to.equal(null);
|
|
31
|
-
|
|
32
|
-
expect(data[0].example.attributes.f.schema).to.exist;
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
it('f[a]: should be a boolean attribute', function () {
|
|
36
|
-
expect(data[0].example.attributes.f.schema[0].name).to.equal('a');
|
|
37
|
-
expect(data[0].example.attributes.f.schema[0].type).to.equal('boolean');
|
|
38
|
-
expect(data[0].example.attributes.f.schema[0].array).to.equal(false);
|
|
39
|
-
expect(data[0].example.attributes.f.schema[0].default).to.equal(false);
|
|
40
|
-
expect(data[0].example.attributes.f.schema[0].description).to.equal('This is some description of the attribute.');
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
it('f[b]: should be a numeric attribute', function () {
|
|
44
|
-
expect(data[0].example.attributes.f.schema[1].name).to.equal('b');
|
|
45
|
-
expect(data[0].example.attributes.f.schema[1].type).to.equal('number');
|
|
46
|
-
expect(data[0].example.attributes.f.schema[1].array).to.equal(false);
|
|
47
|
-
expect(data[0].example.attributes.f.schema[1].min).to.equal(10);
|
|
48
|
-
expect(data[0].example.attributes.f.schema[1].max).to.equal(20);
|
|
49
|
-
expect(data[0].example.attributes.f.schema[1].default).to.equal(10);
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
it('f[c]: should be a string attribute', function () {
|
|
53
|
-
expect(data[0].example.attributes.f.schema[2].name).to.equal('c');
|
|
54
|
-
expect(data[0].example.attributes.f.schema[2].type).to.equal('string');
|
|
55
|
-
expect(data[0].example.attributes.f.schema[2].array).to.equal(false);
|
|
56
|
-
expect(data[0].example.attributes.f.schema[2].default).to.equal('hello');
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
it('f[d]: should be a vec3 attribute array', function () {
|
|
60
|
-
expect(data[0].example.attributes.f.schema[3].name).to.equal('d');
|
|
61
|
-
expect(data[0].example.attributes.f.schema[3].type).to.equal('vec3');
|
|
62
|
-
expect(data[0].example.attributes.f.schema[3].array).to.equal(true);
|
|
63
|
-
expect(data[0].example.attributes.f.schema[3].default).to.eql(null);
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
it('g: should be a json attribute array with a size', function () {
|
|
67
|
-
expect(data[0].example.attributes.g).to.exist;
|
|
68
|
-
expect(data[0].example.attributes.g.name).to.equal('g');
|
|
69
|
-
expect(data[0].example.attributes.g.type).to.equal('json');
|
|
70
|
-
expect(data[0].example.attributes.g.array).to.equal(true);
|
|
71
|
-
expect(data[0].example.attributes.g.size).to.equal(2);
|
|
72
|
-
expect(data[0].example.attributes.g.default).to.eql(null);
|
|
73
|
-
|
|
74
|
-
expect(data[0].example.attributes.g.schema).to.exist;
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
it('h: should be a nested json attribute (parent)', function () {
|
|
78
|
-
expect(data[0].example.attributes.h).to.exist;
|
|
79
|
-
expect(data[0].example.attributes.h.name).to.equal('h');
|
|
80
|
-
expect(data[0].example.attributes.h.type).to.equal('json');
|
|
81
|
-
expect(data[0].example.attributes.h.array).to.equal(false);
|
|
82
|
-
expect(data[0].example.attributes.h.default).to.eql(null);
|
|
83
|
-
|
|
84
|
-
expect(data[0].example.attributes.h.schema).to.exist;
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
it('h[x]: should be a nested json attribute (child)', function () {
|
|
88
|
-
expect(data[0].example.attributes.h.schema[0].name).to.equal('x');
|
|
89
|
-
expect(data[0].example.attributes.h.schema[0].type).to.equal('json');
|
|
90
|
-
expect(data[0].example.attributes.h.schema[0].array).to.equal(false);
|
|
91
|
-
expect(data[0].example.attributes.h.schema[0].default).to.eql(null);
|
|
92
|
-
|
|
93
|
-
expect(data[0].example.attributes.h.schema[0].schema).to.exist;
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
it('i: should be an inline default json attribute', function () {
|
|
97
|
-
expect(data[0].example.attributes.i).to.exist;
|
|
98
|
-
expect(data[0].example.attributes.i.name).to.equal('i');
|
|
99
|
-
expect(data[0].example.attributes.i.type).to.equal('json');
|
|
100
|
-
expect(data[0].example.attributes.i.array).to.equal(false);
|
|
101
|
-
expect(data[0].example.attributes.i.default).to.eql(null);
|
|
102
|
-
|
|
103
|
-
expect(data[0].example.attributes.i.schema).to.exist;
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
it('i[a]: should be a boolean attribute', function () {
|
|
107
|
-
expect(data[0].example.attributes.i.schema[0].name).to.equal('a');
|
|
108
|
-
expect(data[0].example.attributes.i.schema[0].type).to.equal('boolean');
|
|
109
|
-
expect(data[0].example.attributes.i.schema[0].array).to.equal(false);
|
|
110
|
-
expect(data[0].example.attributes.i.schema[0].default).to.equal(true);
|
|
111
|
-
expect(data[0].example.attributes.i.schema[0].description).to.equal('description of a');
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
it('i[b]: should be a numeric attribute', function () {
|
|
115
|
-
expect(data[0].example.attributes.i.schema[1].name).to.equal('b');
|
|
116
|
-
expect(data[0].example.attributes.i.schema[1].type).to.equal('number');
|
|
117
|
-
expect(data[0].example.attributes.i.schema[1].array).to.equal(false);
|
|
118
|
-
expect(data[0].example.attributes.i.schema[1].min).to.equal(10);
|
|
119
|
-
expect(data[0].example.attributes.i.schema[1].max).to.equal(20);
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
it('j: should be a typedef json attribute', function () {
|
|
123
|
-
expect(data[0].example.attributes.j).to.exist;
|
|
124
|
-
expect(data[0].example.attributes.j.name).to.equal('j');
|
|
125
|
-
expect(data[0].example.attributes.j.type).to.equal('json');
|
|
126
|
-
expect(data[0].example.attributes.j.array).to.equal(false);
|
|
127
|
-
expect(data[0].example.attributes.j.default).to.eql(null);
|
|
128
|
-
|
|
129
|
-
expect(data[0].example.attributes.j.schema).to.exist;
|
|
130
|
-
});
|
|
131
|
-
|
|
132
|
-
it('k: should be an inline typedef json attribute', function () {
|
|
133
|
-
expect(data[0].example.attributes.k).to.exist;
|
|
134
|
-
expect(data[0].example.attributes.k.name).to.equal('k');
|
|
135
|
-
expect(data[0].example.attributes.k.type).to.equal('json');
|
|
136
|
-
expect(data[0].example.attributes.k.array).to.equal(false);
|
|
137
|
-
expect(data[0].example.attributes.k.default).to.eql(null);
|
|
138
|
-
|
|
139
|
-
expect(data[0].example.attributes.k.schema).to.exist;
|
|
140
|
-
});
|
|
141
|
-
|
|
142
|
-
it('l: should be an inline type json attribute', function () {
|
|
143
|
-
expect(data[0].example.attributes.l).to.exist;
|
|
144
|
-
expect(data[0].example.attributes.l.name).to.equal('l');
|
|
145
|
-
expect(data[0].example.attributes.l.type).to.equal('json');
|
|
146
|
-
expect(data[0].example.attributes.l.array).to.equal(false);
|
|
147
|
-
expect(data[0].example.attributes.l.default).to.eql(null);
|
|
148
|
-
|
|
149
|
-
expect(data[0].example.attributes.l.schema).to.exist;
|
|
150
|
-
});
|
|
151
|
-
|
|
152
|
-
it('m: should be a self reference json attribute', function () {
|
|
153
|
-
expect(data[0].example.attributes.m).to.exist;
|
|
154
|
-
expect(data[0].example.attributes.m.name).to.equal('m');
|
|
155
|
-
expect(data[0].example.attributes.m.type).to.equal('json');
|
|
156
|
-
expect(data[0].example.attributes.m.array).to.equal(false);
|
|
157
|
-
expect(data[0].example.attributes.m.default).to.eql(null);
|
|
158
|
-
|
|
159
|
-
expect(data[0].example.attributes.m.schema).to.exist;
|
|
160
|
-
});
|
|
161
|
-
|
|
162
|
-
it('n: should not be recognised as an attribute (no attribute tag)', function () {
|
|
163
|
-
expect(data[0].example.attributes.n).to.not.exist;
|
|
164
|
-
});
|
|
165
|
-
|
|
166
|
-
it('o: should not be recognised as an attribute (type not an interface)', function () {
|
|
167
|
-
expect(data[0].example.attributes.o).to.not.exist;
|
|
168
|
-
});
|
|
169
|
-
});
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
describe('TS: VALID: Asset attribute', function () {
|
|
173
|
-
|
|
174
|
-
let data;
|
|
175
|
-
before(async function () {
|
|
176
|
-
data = await parseAttributes('./json.valid.ts');
|
|
177
|
-
});
|
|
178
|
-
|
|
179
|
-
it('only results should exist', function () {
|
|
180
|
-
expect(data).to.exist;
|
|
181
|
-
expect(data[0]).to.not.be.empty;
|
|
182
|
-
expect(data[1]).to.be.empty;
|
|
183
|
-
});
|
|
184
|
-
|
|
185
|
-
it('Example: should exist without errors', function () {
|
|
186
|
-
expect(data[0]?.example).to.exist;
|
|
187
|
-
expect(data[0].example.attributes).to.not.be.empty;
|
|
188
|
-
expect(data[0].example.errors).to.be.empty;
|
|
189
|
-
});
|
|
190
|
-
|
|
191
|
-
it('f: should be a json attribute', function () {
|
|
192
|
-
expect(data[0].example.attributes.f).to.exist;
|
|
193
|
-
expect(data[0].example.attributes.f.name).to.equal('f');
|
|
194
|
-
expect(data[0].example.attributes.f.type).to.equal('json');
|
|
195
|
-
expect(data[0].example.attributes.f.array).to.equal(false);
|
|
196
|
-
expect(data[0].example.attributes.f.default).to.equal(null);
|
|
197
|
-
|
|
198
|
-
expect(data[0].example.attributes.f.schema).to.exist;
|
|
199
|
-
});
|
|
200
|
-
|
|
201
|
-
it('f[a]: should be a boolean attribute', function () {
|
|
202
|
-
expect(data[0].example.attributes.f.schema[0].name).to.equal('a');
|
|
203
|
-
expect(data[0].example.attributes.f.schema[0].type).to.equal('boolean');
|
|
204
|
-
expect(data[0].example.attributes.f.schema[0].array).to.equal(false);
|
|
205
|
-
expect(data[0].example.attributes.f.schema[0].default).to.equal(false);
|
|
206
|
-
expect(data[0].example.attributes.f.schema[0].description).to.equal('This is some description of the attribute.');
|
|
207
|
-
});
|
|
208
|
-
|
|
209
|
-
it('f[b]: should be a numeric attribute', function () {
|
|
210
|
-
expect(data[0].example.attributes.f.schema[1].name).to.equal('b');
|
|
211
|
-
expect(data[0].example.attributes.f.schema[1].type).to.equal('number');
|
|
212
|
-
expect(data[0].example.attributes.f.schema[1].array).to.equal(false);
|
|
213
|
-
expect(data[0].example.attributes.f.schema[1].default).to.equal(10);
|
|
214
|
-
expect(data[0].example.attributes.f.schema[1].min).to.equal(10);
|
|
215
|
-
expect(data[0].example.attributes.f.schema[1].max).to.equal(20);
|
|
216
|
-
});
|
|
217
|
-
|
|
218
|
-
it('f[c]: should be a string attribute', function () {
|
|
219
|
-
expect(data[0].example.attributes.f.schema[2].name).to.equal('c');
|
|
220
|
-
expect(data[0].example.attributes.f.schema[2].type).to.equal('string');
|
|
221
|
-
expect(data[0].example.attributes.f.schema[2].array).to.equal(false);
|
|
222
|
-
expect(data[0].example.attributes.f.schema[2].default).to.equal('hello');
|
|
223
|
-
});
|
|
224
|
-
|
|
225
|
-
it('f[d]: should be a vec3 attribute array', function () {
|
|
226
|
-
expect(data[0].example.attributes.f.schema[3].name).to.equal('d');
|
|
227
|
-
expect(data[0].example.attributes.f.schema[3].type).to.equal('vec3');
|
|
228
|
-
expect(data[0].example.attributes.f.schema[3].array).to.equal(true);
|
|
229
|
-
expect(data[0].example.attributes.f.schema[3].default).to.eql(null);
|
|
230
|
-
});
|
|
231
|
-
|
|
232
|
-
it('g: should be a json attribute array with a size', function () {
|
|
233
|
-
expect(data[0].example.attributes.g).to.exist;
|
|
234
|
-
expect(data[0].example.attributes.g.name).to.equal('g');
|
|
235
|
-
expect(data[0].example.attributes.g.type).to.equal('json');
|
|
236
|
-
expect(data[0].example.attributes.g.array).to.equal(true);
|
|
237
|
-
expect(data[0].example.attributes.g.size).to.equal(2);
|
|
238
|
-
expect(data[0].example.attributes.g.default).to.eql(null);
|
|
239
|
-
|
|
240
|
-
expect(data[0].example.attributes.g.schema).to.exist;
|
|
241
|
-
});
|
|
242
|
-
|
|
243
|
-
it('h: should be a nested json attribute (parent)', function () {
|
|
244
|
-
expect(data[0].example.attributes.h).to.exist;
|
|
245
|
-
expect(data[0].example.attributes.h.name).to.equal('h');
|
|
246
|
-
expect(data[0].example.attributes.h.type).to.equal('json');
|
|
247
|
-
expect(data[0].example.attributes.h.array).to.equal(false);
|
|
248
|
-
expect(data[0].example.attributes.h.default).to.eql(null);
|
|
249
|
-
|
|
250
|
-
expect(data[0].example.attributes.h.schema).to.exist;
|
|
251
|
-
});
|
|
252
|
-
|
|
253
|
-
it('h[x]: should be a nested json attribute (child)', function () {
|
|
254
|
-
expect(data[0].example.attributes.h.schema[0].name).to.equal('x');
|
|
255
|
-
expect(data[0].example.attributes.h.schema[0].type).to.equal('json');
|
|
256
|
-
expect(data[0].example.attributes.h.schema[0].array).to.equal(false);
|
|
257
|
-
expect(data[0].example.attributes.h.schema[0].default).to.eql(null);
|
|
258
|
-
|
|
259
|
-
expect(data[0].example.attributes.h.schema[0].schema).to.exist;
|
|
260
|
-
});
|
|
261
|
-
|
|
262
|
-
it('i: should be an inline default json attribute', function () {
|
|
263
|
-
expect(data[0].example.attributes.i).to.exist;
|
|
264
|
-
expect(data[0].example.attributes.i.name).to.equal('i');
|
|
265
|
-
expect(data[0].example.attributes.i.type).to.equal('json');
|
|
266
|
-
expect(data[0].example.attributes.i.array).to.equal(false);
|
|
267
|
-
expect(data[0].example.attributes.i.default).to.eql(null);
|
|
268
|
-
|
|
269
|
-
expect(data[0].example.attributes.i.schema).to.exist;
|
|
270
|
-
});
|
|
271
|
-
|
|
272
|
-
it('i[a]: should be a boolean attribute', function () {
|
|
273
|
-
expect(data[0].example.attributes.i.schema[0].name).to.equal('a');
|
|
274
|
-
expect(data[0].example.attributes.i.schema[0].type).to.equal('boolean');
|
|
275
|
-
expect(data[0].example.attributes.i.schema[0].array).to.equal(false);
|
|
276
|
-
expect(data[0].example.attributes.i.schema[0].default).to.equal(true);
|
|
277
|
-
expect(data[0].example.attributes.i.schema[0].description).to.equal('description of a');
|
|
278
|
-
});
|
|
279
|
-
|
|
280
|
-
it('i[b]: should be a numeric attribute', function () {
|
|
281
|
-
expect(data[0].example.attributes.i.schema[1].name).to.equal('b');
|
|
282
|
-
expect(data[0].example.attributes.i.schema[1].type).to.equal('number');
|
|
283
|
-
expect(data[0].example.attributes.i.schema[1].array).to.equal(false);
|
|
284
|
-
expect(data[0].example.attributes.i.schema[1].min).to.equal(10);
|
|
285
|
-
expect(data[0].example.attributes.i.schema[1].max).to.equal(20);
|
|
286
|
-
});
|
|
287
|
-
|
|
288
|
-
it('l: should be an inline type json attribute', function () {
|
|
289
|
-
expect(data[0].example.attributes.l).to.exist;
|
|
290
|
-
expect(data[0].example.attributes.l.name).to.equal('l');
|
|
291
|
-
expect(data[0].example.attributes.l.type).to.equal('json');
|
|
292
|
-
expect(data[0].example.attributes.l.array).to.equal(false);
|
|
293
|
-
expect(data[0].example.attributes.l.default).to.eql(null);
|
|
294
|
-
|
|
295
|
-
expect(data[0].example.attributes.l.schema).to.exist;
|
|
296
|
-
});
|
|
297
|
-
|
|
298
|
-
it('m: should be a self reference json attribute', function () {
|
|
299
|
-
expect(data[0].example.attributes.m).to.exist;
|
|
300
|
-
expect(data[0].example.attributes.m.name).to.equal('m');
|
|
301
|
-
expect(data[0].example.attributes.m.type).to.equal('json');
|
|
302
|
-
expect(data[0].example.attributes.m.array).to.equal(false);
|
|
303
|
-
expect(data[0].example.attributes.m.default).to.eql(null);
|
|
304
|
-
|
|
305
|
-
expect(data[0].example.attributes.m.schema).to.exist;
|
|
306
|
-
});
|
|
307
|
-
|
|
308
|
-
it('n: should not be recognised as an attribute (no attribute tag)', function () {
|
|
309
|
-
expect(data[0].example.attributes.n).to.not.exist;
|
|
310
|
-
});
|
|
311
|
-
|
|
312
|
-
it('o: should not be recognised as an attribute (type not an interface)', function () {
|
|
313
|
-
expect(data[0].example.attributes.o).to.not.exist;
|
|
314
|
-
});
|
|
315
|
-
});
|