Skip to content

Commit c07015e

Browse files
committed
test: add coverage for both Id and ID (case-insensitive Apex)
- Add test for Id (lowercase d) as field type - Add test for ID (uppercase D) as field type - Add test for Id in generic type parameters - Add test for ID in generic type parameters - Verifies Apex case-insensitive support for Id/ID primitive type
1 parent 74824a3 commit c07015e

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

test/type-name.tests.ts

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,5 +86,59 @@ describe('Grammar', () => {
8686
Token.Punctuation.Semicolon,
8787
]);
8888
});
89+
90+
it('Id type (lowercase d) - Apex is case-insensitive', async () => {
91+
const input = Input.InClass(`Id recordId;`);
92+
const tokens = await tokenize(input);
93+
94+
tokens.should.deep.equal([
95+
Token.PrimitiveType.ID,
96+
Token.Identifiers.FieldName('recordId'),
97+
Token.Punctuation.Semicolon,
98+
]);
99+
});
100+
101+
it('ID type (uppercase D) - Apex is case-insensitive', async () => {
102+
const input = Input.InClass(`ID recordId;`);
103+
const tokens = await tokenize(input);
104+
105+
tokens.should.deep.equal([
106+
{ text: 'ID', type: 'keyword.type.apex' },
107+
Token.Identifiers.FieldName('recordId'),
108+
Token.Punctuation.Semicolon,
109+
]);
110+
});
111+
112+
it('Id in generic type parameter', async () => {
113+
const input = Input.InClass(`Map<Id, Account> accounts;`);
114+
const tokens = await tokenize(input);
115+
116+
tokens.should.deep.equal([
117+
Token.Type('Map'),
118+
Token.Punctuation.TypeParameters.Begin,
119+
Token.PrimitiveType.ID,
120+
Token.Punctuation.Comma,
121+
Token.Type('Account'),
122+
Token.Punctuation.TypeParameters.End,
123+
Token.Identifiers.FieldName('accounts'),
124+
Token.Punctuation.Semicolon,
125+
]);
126+
});
127+
128+
it('ID in generic type parameter', async () => {
129+
const input = Input.InClass(`Map<ID, Account> accounts;`);
130+
const tokens = await tokenize(input);
131+
132+
tokens.should.deep.equal([
133+
Token.Type('Map'),
134+
Token.Punctuation.TypeParameters.Begin,
135+
{ text: 'ID', type: 'keyword.type.apex' },
136+
Token.Punctuation.Comma,
137+
Token.Type('Account'),
138+
Token.Punctuation.TypeParameters.End,
139+
Token.Identifiers.FieldName('accounts'),
140+
Token.Punctuation.Semicolon,
141+
]);
142+
});
89143
});
90144
});

0 commit comments

Comments
 (0)