Skip to content

Commit adfce2f

Browse files
committed
Reset line-processor again
1 parent ce167a2 commit adfce2f

File tree

1 file changed

+57
-45
lines changed

1 file changed

+57
-45
lines changed

spec/line-processor-spec.js

Lines changed: 57 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -3,38 +3,50 @@ const LineProcessor = require("../lib/line-processor");
33
describe('Line Processor', () => {
44

55
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+
})
2133

2234
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+
})
2638

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+
})
3143

3244
describe('isQuotationMark', () => {
3345
it('should find the range for one ControlPattern and one word and execute the callback once', () => {
3446
const results = [];
3547
LineProcessor.findTidalWordRanges(
36-
`d1 $ s "superpiano" # note 0`,
37-
(result) => results.push(result));
48+
`d1 $ s "superpiano" # note 0`,
49+
(result) => results.push(result));
3850

3951
expect(results.length).toEqual(1);
4052
expect(results[0]).toEqual({ start: 8, end: 17});
@@ -43,8 +55,8 @@ describe('Line Processor', () => {
4355
it('should find the range for two ControlPatterns and several words and execute the callback accorgingly', () => {
4456
const results = [];
4557
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));
4860

4961
expect(results.length).toEqual(3);
5062
expect(results[0]).toEqual({ start: 9, end: 18});
@@ -56,8 +68,8 @@ describe('Line Processor', () => {
5668
it('should find the range for one relatively complex ControlPattern and several words and execute the callback accordingly', () => {
5769
const results = [];
5870
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));
6173

6274
expect(results.length).toEqual(7);
6375
expect(results[0]).toEqual({ start: 8, end: 17});
@@ -72,30 +84,30 @@ describe('Line Processor', () => {
7284

7385
describe('controlPatternsRegex', () => {
7486
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+
})
8092
})
8193

8294
describe('exceptedFunctionPatterns', () => {
8395
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+
})
88100

89101
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+
})
95107

96108
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+
})
100112
})
101113
})

0 commit comments

Comments
 (0)