Skip to content

Commit 68d3b18

Browse files
committed
more tests
1 parent 92de6bd commit 68d3b18

File tree

3 files changed

+79
-38
lines changed

3 files changed

+79
-38
lines changed

src/inputFieldArguments/AbstractInputFieldArgument.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@ export abstract class AbstractInputFieldArgument {
3434
return true;
3535
}
3636

37-
console.log(this.getConfig().allowedInputFieldTypes);
38-
3937
return this.getConfig().allowedInputFieldTypes.includes(inputFieldType);
4038
}
4139

tests/customMatchers/customMatchers.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,30 +14,30 @@ declare global {
1414
}
1515
}
1616

17-
export function toHaveWarnings(obj: { errorCollection: ErrorCollection }) {
17+
export function toHaveWarnings(obj: { errorCollection: ErrorCollection }): { pass: boolean; message: () => string } {
1818
if (obj.errorCollection.hasWarnings()) {
1919
return {
2020
pass: true,
21-
message: () => `expected error collection to have no warnings`,
21+
message: (): string => `expected error collection to have no warnings`,
2222
};
2323
} else {
2424
return {
2525
pass: false,
26-
message: () => `expected error collection to have warnings`,
26+
message: (): string => `expected error collection to have warnings`,
2727
};
2828
}
2929
}
3030

31-
export function toHaveErrors(obj: { errorCollection: ErrorCollection }) {
31+
export function toHaveErrors(obj: { errorCollection: ErrorCollection }): { pass: boolean; message: () => string } {
3232
if (obj.errorCollection.hasErrors()) {
3333
return {
3434
pass: true,
35-
message: () => `expected error collection to have no warnings`,
35+
message: (): string => `expected error collection to have no errors`,
3636
};
3737
} else {
3838
return {
3939
pass: false,
40-
message: () => `expected error collection to have warnings`,
40+
message: (): string => `expected error collection to have errors`,
4141
};
4242
}
4343
}

tests/parserTests/InputFieldParser.test.ts

Lines changed: 73 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -3,61 +3,104 @@ import { TestPlugin } from './testAPI/TestAPI';
33
const plugin = new TestPlugin();
44
const parser = plugin.api.inputFieldParser;
55

6-
describe('input field declarations, no templates, no local scope', () => {
7-
test('INPUT[text]', () => {
8-
const res = parser.parseString('INPUT[text]');
6+
describe('should not error or warn cases', () => {
7+
describe('no templates, no local scope', () => {
8+
test('INPUT[text]', () => {
9+
const res = parser.parseString('INPUT[text]');
910

10-
expect(res).not.toHaveWarnings();
11-
expect(res).not.toHaveErrors();
12-
});
11+
expect(res).not.toHaveWarnings();
12+
expect(res).not.toHaveErrors();
13+
});
1314

14-
test('INPUT[select(option(a), option(b, c), showcase)]', () => {
15-
const res = parser.parseString('INPUT[select(option(a), option(b, c), showcase)]');
15+
test('INPUT[select(option(a), option(b, c), showcase)]', () => {
16+
const res = parser.parseString('INPUT[select(option(a), option(b, c), showcase)]');
1617

17-
expect(res).not.toHaveWarnings();
18-
expect(res).not.toHaveErrors();
19-
});
18+
expect(res).not.toHaveWarnings();
19+
expect(res).not.toHaveErrors();
20+
});
2021

21-
test('INPUT[text:text]', () => {
22-
const res = parser.parseString('INPUT[text:text]');
22+
test('INPUT[text:text]', () => {
23+
const res = parser.parseString('INPUT[text:text]');
2324

24-
expect(res).not.toHaveWarnings();
25-
expect(res).not.toHaveErrors();
25+
expect(res).not.toHaveWarnings();
26+
expect(res).not.toHaveErrors();
27+
});
28+
29+
test('INPUT[text:["test"]]', () => {
30+
const res = parser.parseString('INPUT[text:["test"]]');
31+
32+
expect(res).not.toHaveWarnings();
33+
expect(res).not.toHaveErrors();
34+
});
35+
36+
test('INPUT[text:[0]]', () => {
37+
const res = parser.parseString('INPUT[text:[0]]');
38+
39+
expect(res).not.toHaveWarnings();
40+
expect(res).not.toHaveErrors();
41+
});
42+
43+
test('INPUT[text:file#text]', () => {
44+
const res = parser.parseString('INPUT[text:file#text]');
45+
46+
expect(res).not.toHaveWarnings();
47+
expect(res).not.toHaveErrors();
48+
});
49+
50+
test('INPUT[text:path/to/file#text]', () => {
51+
const res = parser.parseString('INPUT[text:path/to/file#text]');
52+
53+
expect(res).not.toHaveWarnings();
54+
expect(res).not.toHaveErrors();
55+
});
56+
57+
test('INPUT[text:path/to/other file#text]', () => {
58+
const res = parser.parseString('INPUT[text:path/to/other file#text]');
59+
60+
expect(res).not.toHaveWarnings();
61+
expect(res).not.toHaveErrors();
62+
});
2663
});
64+
});
2765

28-
test('INPUT[text:["test"]]', () => {
29-
const res = parser.parseString('INPUT[text:["test"]]');
66+
describe('should warn on deprecation', () => {
67+
test('INPUT[multi_select]', () => {
68+
const res = parser.parseString('INPUT[multi_select]');
3069

31-
expect(res).not.toHaveWarnings();
70+
expect(res).toHaveWarnings();
3271
expect(res).not.toHaveErrors();
3372
});
3473

35-
test('INPUT[text:[0]]', () => {
36-
const res = parser.parseString('INPUT[text:[0]]');
74+
test('INPUT[date_picker]', () => {
75+
const res = parser.parseString('INPUT[date_picker]');
3776

38-
expect(res).not.toHaveWarnings();
77+
expect(res).toHaveWarnings();
3978
expect(res).not.toHaveErrors();
4079
});
4180

42-
test('INPUT[text:file#text]', () => {
43-
const res = parser.parseString('INPUT[text:file#text]');
81+
test('INPUT[text_area]', () => {
82+
const res = parser.parseString('INPUT[text_area]');
4483

45-
expect(res).not.toHaveWarnings();
84+
expect(res).toHaveWarnings();
4685
expect(res).not.toHaveErrors();
4786
});
87+
});
4888

49-
test('INPUT[text:path/to/file#text]', () => {
50-
const res = parser.parseString('INPUT[text:path/to/file#text]');
89+
describe('should warn on invalid argument', () => {
90+
test('INPUT[text(invalidArgument)]', () => {
91+
const res = parser.parseString('INPUT[text(invalidArgument)]');
5192

52-
expect(res).not.toHaveWarnings();
93+
expect(res).toHaveWarnings();
5394
expect(res).not.toHaveErrors();
5495
});
96+
});
5597

56-
test('INPUT[text:path/to/other file#text]', () => {
57-
const res = parser.parseString('INPUT[text:path/to/other file#text]');
98+
describe('should error on invalid input field type', () => {
99+
test('INPUT[invalidType]', () => {
100+
const res = parser.parseString('INPUT[invalidType]');
58101

59102
expect(res).not.toHaveWarnings();
60-
expect(res).not.toHaveErrors();
103+
expect(res).toHaveErrors();
61104
});
62105
});
63106

0 commit comments

Comments
 (0)