@@ -3,38 +3,50 @@ const LineProcessor = require("../lib/line-processor");
3
3
describe ( 'Line Processor' , ( ) => {
4
4
5
5
describe ( 'isValidTidalWordChar' , ( ) => {
6
- it ( 'should truthify a valid digit' , ( ) => {
7
- expect ( LineProcessor . isValidTidalWordChar ( '5' ) ) . toBe ( true ) ;
8
- } )
9
- it ( 'should truthify a valid upper case char' , ( ) => {
10
- expect ( LineProcessor . isValidTidalWordChar ( 'M' ) ) . toBe ( true ) ;
11
- } )
12
-
13
- it ( 'should truthify a valid lower case char' , ( ) => {
14
- expect ( LineProcessor . isValidTidalWordChar ( 't' ) ) . toBe ( true ) ;
15
- } )
16
-
17
- it ( 'should falsify an invalid char' , ( ) => {
18
- expect ( LineProcessor . isValidTidalWordChar ( '*' ) ) . toBe ( false ) ;
19
- } )
20
- } )
6
+ it ( 'should truthify a valid digit' , ( ) => {
7
+ expect ( LineProcessor . isValidTidalWordChar ( '5' ) ) . toBe ( true ) ;
8
+ } )
9
+ it ( 'should truthify a valid upper case char' , ( ) => {
10
+ expect ( LineProcessor . isValidTidalWordChar ( 'M' ) ) . toBe ( true ) ;
11
+ } )
12
+
13
+ it ( 'should truthify a valid lower case char' , ( ) => {
14
+ expect ( LineProcessor . isValidTidalWordChar ( 't' ) ) . toBe ( true ) ;
15
+ } )
16
+
17
+ it ( 'should falsify an invalid char' , ( ) => {
18
+ expect ( LineProcessor . isValidTidalWordChar ( '*' ) ) . toBe ( false ) ;
19
+ } )
20
+
21
+ it ( 'should truthify a valid minus' , ( ) => {
22
+ expect ( LineProcessor . isValidTidalWordChar ( '-' ) ) . toBe ( true ) ;
23
+ } )
24
+
25
+ it ( 'should truthify a valid dot' , ( ) => {
26
+ expect ( LineProcessor . isValidTidalWordChar ( '.' ) ) . toBe ( true ) ;
27
+ } )
28
+
29
+ it ( 'should truthify a valid colon' , ( ) => {
30
+ expect ( LineProcessor . isValidTidalWordChar ( ':' ) ) . toBe ( true ) ;
31
+ } )
32
+ } )
21
33
22
34
describe ( 'isQuotationMark' , ( ) => {
23
- it ( 'should truthify quotation mark' , ( ) => {
24
- expect ( LineProcessor . isQuotationMark ( '"' ) ) . toBe ( true ) ;
25
- } )
35
+ it ( 'should truthify quotation mark' , ( ) => {
36
+ expect ( LineProcessor . isQuotationMark ( '"' ) ) . toBe ( true ) ;
37
+ } )
26
38
27
- it ( 'should falsify non quotation mark' , ( ) => {
28
- expect ( LineProcessor . isQuotationMark ( '*' ) ) . toBe ( false ) ;
29
- } )
30
- } )
39
+ it ( 'should falsify non quotation mark' , ( ) => {
40
+ expect ( LineProcessor . isQuotationMark ( '*' ) ) . toBe ( false ) ;
41
+ } )
42
+ } )
31
43
32
44
describe ( 'isQuotationMark' , ( ) => {
33
45
it ( 'should find the range for one ControlPattern and one word and execute the callback once' , ( ) => {
34
46
const results = [ ] ;
35
47
LineProcessor . findTidalWordRanges (
36
- `d1 $ s "superpiano" # note 0` ,
37
- ( result ) => results . push ( result ) ) ;
48
+ `d1 $ s "superpiano" # note 0` ,
49
+ ( result ) => results . push ( result ) ) ;
38
50
39
51
expect ( results . length ) . toEqual ( 1 ) ;
40
52
expect ( results [ 0 ] ) . toEqual ( { start : 8 , end : 17 } ) ;
@@ -43,8 +55,8 @@ describe('Line Processor', () => {
43
55
it ( 'should find the range for two ControlPatterns and several words and execute the callback accorgingly' , ( ) => {
44
56
const results = [ ] ;
45
57
LineProcessor . findTidalWordRanges (
46
- `d1 $ s "<superpiano 808>" # note "0"` ,
47
- ( result ) => results . push ( result ) ) ;
58
+ `d1 $ s "<superpiano 808>" # note "0"` ,
59
+ ( result ) => results . push ( result ) ) ;
48
60
49
61
expect ( results . length ) . toEqual ( 3 ) ;
50
62
expect ( results [ 0 ] ) . toEqual ( { start : 9 , end : 18 } ) ;
@@ -56,8 +68,8 @@ describe('Line Processor', () => {
56
68
it ( 'should find the range for one relatively complex ControlPattern and several words and execute the callback accordingly' , ( ) => {
57
69
const results = [ ] ;
58
70
LineProcessor . findTidalWordRanges (
59
- `d1 $ s "superpiano" # note "c'maj'4*<1 2 3>"` ,
60
- ( result ) => results . push ( result ) ) ;
71
+ `d1 $ s "superpiano" # note "c'maj'4*<1 2 3>"` ,
72
+ ( result ) => results . push ( result ) ) ;
61
73
62
74
expect ( results . length ) . toEqual ( 7 ) ;
63
75
expect ( results [ 0 ] ) . toEqual ( { start : 8 , end : 17 } ) ;
@@ -72,30 +84,30 @@ describe('Line Processor', () => {
72
84
73
85
describe ( 'controlPatternsRegex' , ( ) => {
74
86
it ( 'should match all strings and their quotation marks in a line' , ( ) => {
75
- const testString = `d1 $ s "<superpiano 808>" # note "0"` ;
76
- const expected = [ `"<superpiano 808>"` , `"0"` ] ;
77
-
78
- expect ( testString . match ( LineProcessor . controlPatternsRegex ( ) ) ) . toEqual ( expected ) ;
79
- } )
87
+ const testString = `d1 $ s "<superpiano 808>" # note "0"` ;
88
+ const expected = [ `"<superpiano 808>"` , `"0"` ] ;
89
+
90
+ expect ( testString . match ( LineProcessor . controlPatternsRegex ( ) ) ) . toEqual ( expected ) ;
91
+ } )
80
92
} )
81
93
82
94
describe ( 'exceptedFunctionPatterns' , ( ) => {
83
95
it ( 'should match numerals function occurance in a line' , ( ) => {
84
- const testString = `numerals = "0 1 2 3"` ;
85
- const expected = 'numerals = "0 1 2 3"' ;
86
- expect ( testString . match ( LineProcessor . exceptedFunctionPatterns ( ) ) [ 0 ] ) . toEqual ( expected ) ;
87
- } )
96
+ const testString = `numerals = "0 1 2 3"` ;
97
+ const expected = 'numerals = "0 1 2 3"' ;
98
+ expect ( testString . match ( LineProcessor . exceptedFunctionPatterns ( ) ) [ 0 ] ) . toEqual ( expected ) ;
99
+ } )
88
100
89
101
it ( 'should match p function occurance in a line' , ( ) => {
90
- const testString = `p "hello" $ s "808"` ;
91
- const expected = 'p "hello" $ s "808"' ;
92
-
93
- expect ( testString . match ( LineProcessor . exceptedFunctionPatterns ( ) ) [ 0 ] ) . toEqual ( expected ) ;
94
- } )
102
+ const testString = `p "hello" $ s "808"` ;
103
+ const expected = 'p "hello" $ s "808"' ;
104
+
105
+ expect ( testString . match ( LineProcessor . exceptedFunctionPatterns ( ) ) [ 0 ] ) . toEqual ( expected ) ;
106
+ } )
95
107
96
108
it ( 'should not match an allowed control pattern in a line' , ( ) => {
97
- const testString = `d1 $ s "superpiano"` ;
98
- expect ( testString . match ( LineProcessor . exceptedFunctionPatterns ( ) ) ) . toBeNull ( )
99
- } )
109
+ const testString = `d1 $ s "superpiano"` ;
110
+ expect ( testString . match ( LineProcessor . exceptedFunctionPatterns ( ) ) ) . toBeNull ( )
111
+ } )
100
112
} )
101
113
} )
0 commit comments