1
- import attributeParser from '../src/public/app/services/attribute_parser.js' ;
2
- import { describe , it , expect , execute } from './mini_test.js' ;
1
+ import * as attributeParser from '../src/public/app/services/attribute_parser.js' ;
2
+
3
+ import { describe , it , expect , execute } from './mini_test' ;
3
4
4
5
describe ( "Lexing" , ( ) => {
5
6
it ( "simple label" , ( ) => {
6
- expect ( attributeParser . lex ( "#label" ) . map ( t => t . text ) )
7
+ expect ( attributeParser . lex ( "#label" ) . map ( ( t : any ) => t . text ) )
7
8
. toEqual ( [ "#label" ] ) ;
8
9
} ) ;
9
10
10
11
it ( "simple label with trailing spaces" , ( ) => {
11
- expect ( attributeParser . lex ( " #label " ) . map ( t => t . text ) )
12
+ expect ( attributeParser . lex ( " #label " ) . map ( ( t : any ) => t . text ) )
12
13
. toEqual ( [ "#label" ] ) ;
13
14
} ) ;
14
15
15
16
it ( "inherited label" , ( ) => {
16
- expect ( attributeParser . lex ( "#label(inheritable)" ) . map ( t => t . text ) )
17
+ expect ( attributeParser . lex ( "#label(inheritable)" ) . map ( ( t : any ) => t . text ) )
17
18
. toEqual ( [ "#label" , "(" , "inheritable" , ")" ] ) ;
18
19
19
- expect ( attributeParser . lex ( "#label ( inheritable ) " ) . map ( t => t . text ) )
20
+ expect ( attributeParser . lex ( "#label ( inheritable ) " ) . map ( ( t : any ) => t . text ) )
20
21
. toEqual ( [ "#label" , "(" , "inheritable" , ")" ] ) ;
21
22
} ) ;
22
23
23
24
it ( "label with value" , ( ) => {
24
- expect ( attributeParser . lex ( "#label=Hallo" ) . map ( t => t . text ) )
25
+ expect ( attributeParser . lex ( "#label=Hallo" ) . map ( ( t : any ) => t . text ) )
25
26
. toEqual ( [ "#label" , "=" , "Hallo" ] ) ;
26
27
} ) ;
27
28
@@ -32,25 +33,25 @@ describe("Lexing", () => {
32
33
} ) ;
33
34
34
35
it ( "relation with value" , ( ) => {
35
- expect ( attributeParser . lex ( '~relation=#root/RclIpMauTOKS/NFi2gL4xtPxM' ) . map ( t => t . text ) )
36
+ expect ( attributeParser . lex ( '~relation=#root/RclIpMauTOKS/NFi2gL4xtPxM' ) . map ( ( t : any ) => t . text ) )
36
37
. toEqual ( [ "~relation" , "=" , "#root/RclIpMauTOKS/NFi2gL4xtPxM" ] ) ;
37
38
} ) ;
38
39
39
40
it ( "use quotes to define value" , ( ) => {
40
- expect ( attributeParser . lex ( "#'label a'='hello\"` world'" ) . map ( t => t . text ) )
41
+ expect ( attributeParser . lex ( "#'label a'='hello\"` world'" ) . map ( ( t : any ) => t . text ) )
41
42
. toEqual ( [ "#label a" , "=" , 'hello"` world' ] ) ;
42
43
43
- expect ( attributeParser . lex ( '#"label a" = "hello\'` world"' ) . map ( t => t . text ) )
44
+ expect ( attributeParser . lex ( '#"label a" = "hello\'` world"' ) . map ( ( t : any ) => t . text ) )
44
45
. toEqual ( [ "#label a" , "=" , "hello'` world" ] ) ;
45
46
46
- expect ( attributeParser . lex ( '#`label a` = `hello\'" world`' ) . map ( t => t . text ) )
47
+ expect ( attributeParser . lex ( '#`label a` = `hello\'" world`' ) . map ( ( t : any ) => t . text ) )
47
48
. toEqual ( [ "#label a" , "=" , "hello'\" world" ] ) ;
48
49
} ) ;
49
50
} ) ;
50
51
51
52
describe ( "Parser" , ( ) => {
52
53
it ( "simple label" , ( ) => {
53
- const attrs = attributeParser . parse ( [ "#token" ] . map ( t => ( { text : t } ) ) ) ;
54
+ const attrs = attributeParser . parse ( [ "#token" ] . map ( ( t : any ) => ( { text : t } ) ) ) ;
54
55
55
56
expect ( attrs . length ) . toEqual ( 1 ) ;
56
57
expect ( attrs [ 0 ] . type ) . toEqual ( 'label' ) ;
@@ -60,7 +61,7 @@ describe("Parser", () => {
60
61
} ) ;
61
62
62
63
it ( "inherited label" , ( ) => {
63
- const attrs = attributeParser . parse ( [ "#token" , "(" , "inheritable" , ")" ] . map ( t => ( { text : t } ) ) ) ;
64
+ const attrs = attributeParser . parse ( [ "#token" , "(" , "inheritable" , ")" ] . map ( ( t : any ) => ( { text : t } ) ) ) ;
64
65
65
66
expect ( attrs . length ) . toEqual ( 1 ) ;
66
67
expect ( attrs [ 0 ] . type ) . toEqual ( 'label' ) ;
@@ -70,7 +71,7 @@ describe("Parser", () => {
70
71
} ) ;
71
72
72
73
it ( "label with value" , ( ) => {
73
- const attrs = attributeParser . parse ( [ "#token" , "=" , "val" ] . map ( t => ( { text : t } ) ) ) ;
74
+ const attrs = attributeParser . parse ( [ "#token" , "=" , "val" ] . map ( ( t : any ) => ( { text : t } ) ) ) ;
74
75
75
76
expect ( attrs . length ) . toEqual ( 1 ) ;
76
77
expect ( attrs [ 0 ] . type ) . toEqual ( 'label' ) ;
@@ -79,14 +80,14 @@ describe("Parser", () => {
79
80
} ) ;
80
81
81
82
it ( "relation" , ( ) => {
82
- let attrs = attributeParser . parse ( [ "~token" , "=" , "#root/RclIpMauTOKS/NFi2gL4xtPxM" ] . map ( t => ( { text : t } ) ) ) ;
83
+ let attrs = attributeParser . parse ( [ "~token" , "=" , "#root/RclIpMauTOKS/NFi2gL4xtPxM" ] . map ( ( t : any ) => ( { text : t } ) ) ) ;
83
84
84
85
expect ( attrs . length ) . toEqual ( 1 ) ;
85
86
expect ( attrs [ 0 ] . type ) . toEqual ( 'relation' ) ;
86
87
expect ( attrs [ 0 ] . name ) . toEqual ( "token" ) ;
87
88
expect ( attrs [ 0 ] . value ) . toEqual ( 'NFi2gL4xtPxM' ) ;
88
89
89
- attrs = attributeParser . parse ( [ "~token" , "=" , "#NFi2gL4xtPxM" ] . map ( t => ( { text : t } ) ) ) ;
90
+ attrs = attributeParser . parse ( [ "~token" , "=" , "#NFi2gL4xtPxM" ] . map ( ( t : any ) => ( { text : t } ) ) ) ;
90
91
91
92
expect ( attrs . length ) . toEqual ( 1 ) ;
92
93
expect ( attrs [ 0 ] . type ) . toEqual ( 'relation' ) ;
0 commit comments