@@ -5,6 +5,61 @@ describe('parse()', () => {
55 syntax : 'progressive'
66 } ) ;
77
8+ describe ( 'Identifiers' , ( ) => {
9+ it ( 'should parse a regular valid identifier' , ( ) => {
10+ expect ( parse ( '#id' ) ) . toEqual (
11+ ast . selector ( {
12+ rules : [
13+ ast . rule ( {
14+ items : [ ast . id ( { name : 'id' } ) ]
15+ } )
16+ ]
17+ } )
18+ ) ;
19+ } ) ;
20+ it ( 'should parse an identifier starting with a hyphen' , ( ) => {
21+ expect ( parse ( '#-id' ) ) . toEqual (
22+ ast . selector ( {
23+ rules : [
24+ ast . rule ( {
25+ items : [ ast . id ( { name : '-id' } ) ]
26+ } )
27+ ]
28+ } )
29+ ) ;
30+ } ) ;
31+ it ( 'should fail on an identifier starting with multiple hyphens' , ( ) => {
32+ expect ( ( ) => parse ( '#--id' ) ) . toThrow ( 'Identifiers cannot start with two hyphens with strict mode on.' ) ;
33+ } ) ;
34+ it ( 'should parse an identifier starting with multiple hyphens in case of strict: false' , ( ) => {
35+ expect ( createParser ( { strict : false } ) ( '#--id' ) ) . toEqual (
36+ ast . selector ( {
37+ rules : [
38+ ast . rule ( {
39+ items : [ ast . id ( { name : '--id' } ) ]
40+ } )
41+ ]
42+ } )
43+ ) ;
44+ } ) ;
45+ it ( 'should fail on an identifier starting with a hyphen and followed with a digit' , ( ) => {
46+ expect ( ( ) => parse ( '#-1' ) ) . toThrow ( 'Identifiers cannot start with hyphens followed by digits.' ) ;
47+ expect ( ( ) => createParser ( { strict : false } ) ( '#--1' ) ) . toThrow (
48+ 'Identifiers cannot start with hyphens followed by digits.'
49+ ) ;
50+ } ) ;
51+ it ( 'should parse an identifier consisting unicode characters' , ( ) => {
52+ expect ( parse ( '#ÈÈ' ) ) . toEqual (
53+ ast . selector ( {
54+ rules : [
55+ ast . rule ( {
56+ items : [ ast . id ( { name : 'ÈÈ' } ) ]
57+ } )
58+ ]
59+ } )
60+ ) ;
61+ } ) ;
62+ } ) ;
863 describe ( 'Tag Names' , ( ) => {
964 it ( 'should parse a tag name' , ( ) => {
1065 expect ( parse ( 'div' ) ) . toEqual (
0 commit comments