-
Notifications
You must be signed in to change notification settings - Fork 12k
/
Copy pathhtml-selector_spec.ts
62 lines (51 loc) · 2.04 KB
/
html-selector_spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import { formatValidator } from './format-validator';
import { htmlSelectorFormat } from './html-selector';
describe('Schematics HTML selector format', () => {
it('accepts correct selectors', async () => {
const data = { selector: 'my-selector' };
const dataSchema = {
properties: { selector: { type: 'string', format: 'html-selector' } },
};
const result = await formatValidator(data, dataSchema, [htmlSelectorFormat]);
expect(result.success).toBeTrue();
});
it('rejects selectors starting with invalid characters', async () => {
const data = { selector: 'my-selector$' };
const dataSchema = {
properties: { selector: { type: 'string', format: 'html-selector' } },
};
const result = await formatValidator(data, dataSchema, [htmlSelectorFormat]);
expect(result.success).toBeFalse();
});
it('rejects selectors starting with number', async () => {
const data = { selector: '1selector' };
const dataSchema = {
properties: { selector: { type: 'string', format: 'html-selector' } },
};
const result = await formatValidator(data, dataSchema, [htmlSelectorFormat]);
expect(result.success).toBeFalse();
});
it('accepts selectors with non-letter after dash', async () => {
const data = { selector: 'my-1selector' };
const dataSchema = {
properties: { selector: { type: 'string', format: 'html-selector' } },
};
const result = await formatValidator(data, dataSchema, [htmlSelectorFormat]);
expect(result.success).toBeTrue();
});
it('accepts selectors with unicode', async () => {
const data = { selector: 'app-root😀' };
const dataSchema = {
properties: { selector: { type: 'string', format: 'html-selector' } },
};
const result = await formatValidator(data, dataSchema, [htmlSelectorFormat]);
expect(result.success).toBeTrue();
});
});