forked from sindresorhus/validate-element-name
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.js
More file actions
44 lines (41 loc) · 1.35 KB
/
test.js
File metadata and controls
44 lines (41 loc) · 1.35 KB
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
import test from 'ava';
import m from './';
test('returns false for `isValid` and with a `message` for invalid names', t => {
t.false(m('').isValid);
t.false(m('foo').isValid);
t.false(m('annotation-xml').isValid);
t.false(m('0-foo').isValid);
t.false(m('-foo').isValid);
t.false(m('foo-$').isValid);
t.false(m('foo-/').isValid);
t.false(m('FOO-BAR').isValid);
t.false(m('foo/').isValid);
t.truthy(m('foo/').message);
});
test('returns true for `isValid` and without `message` for valid names', t => {
t.true(m('foo-bar').isValid);
t.falsy(m('foo-bar').message);
t.true(m('não-tém').isValid);
t.true(m('foo-bÅr').isValid);
});
test('returns true for `isValid` with warnings for not recommended names', t => {
t.true(m('polymer-').isValid);
t.truthy(m('polymer-').message);
t.true(m('x-').isValid);
t.true(m('ng-').isValid);
t.true(m('unicorn-').isValid);
t.truthy(m('unicorn-').message);
t.truthy(m('unicorn-ø').message);
t.truthy(m('uni--corn').message);
t.truthy(m('uni-----corn').message);
t.truthy(m('uni-co___rn').message);
t.false(m('øl-unicorn').isValid);
t.truthy(m('øl-unicorn').message);
t.true(m('uni-co.rn').isValid);
t.truthy(m('uni-co.rn').message);
t.true(m('uni-corné').isValid);
t.truthy(m('uni-corné').message);
t.true(m('xml-unicorn').isValid);
t.truthy(m('xml-unicorn').message);
t.truthy(m('foo-💩').message);
});