Skip to content

Commit aefc595

Browse files
committed
Finish rebase of master
1 parent dd2fa9f commit aefc595

File tree

1 file changed

+105
-92
lines changed

1 file changed

+105
-92
lines changed

spec/line-processor-spec.js

Lines changed: 105 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -2,100 +2,113 @@ const LineProcessor = require("../lib/line-processor");
22

33
describe('Line Processor', () => {
44

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-
})
21-
22-
describe('isQuotationMark', () => {
23-
it('should truthify quotation mark', () => {
24-
expect(LineProcessor.isQuotationMark('"')).toBe(true);
25-
})
26-
27-
it('should falsify non quotation mark', () => {
28-
expect(LineProcessor.isQuotationMark('*')).toBe(false);
29-
})
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+
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+
})
3032
})
3133

3234
describe('isQuotationMark', () => {
33-
it('should find the range for one ControlPattern and one word and execute the callback once', () => {
34-
const results = [];
35-
LineProcessor.findTidalWordRanges(
36-
`d1 $ s "superpiano" # note 0`,
37-
(result) => results.push(result));
38-
39-
expect(results.length).toEqual(1);
40-
expect(results[0]).toEqual({ start: 8, end: 17});
41-
})
42-
43-
it('should find the range for two ControlPatterns and several words and execute the callback accorgingly', () => {
44-
const results = [];
45-
LineProcessor.findTidalWordRanges(
46-
`d1 $ s "<superpiano 808>" # note "0"`,
47-
(result) => results.push(result));
48-
49-
expect(results.length).toEqual(3);
50-
expect(results[0]).toEqual({ start: 9, end: 18});
51-
expect(results[1]).toEqual({ start: 20, end: 22});
52-
expect(results[2]).toEqual({ start: 34, end: 34});
53-
})
54-
55-
56-
it('should find the range for one relatively complex ControlPattern and several words and execute the callback accordingly', () => {
57-
const results = [];
58-
LineProcessor.findTidalWordRanges(
59-
`d1 $ s "superpiano" # note "c'maj'4*<1 2 3>"`,
60-
(result) => results.push(result));
61-
62-
expect(results.length).toEqual(7);
63-
expect(results[0]).toEqual({ start: 8, end: 17});
64-
expect(results[1]).toEqual({ start: 28, end: 28});
65-
expect(results[2]).toEqual({ start: 30, end: 32});
66-
expect(results[3]).toEqual({ start: 34, end: 34});
67-
expect(results[4]).toEqual({ start: 37, end: 37});
68-
expect(results[5]).toEqual({ start: 39, end: 39});
69-
expect(results[6]).toEqual({ start: 41, end: 41});
70-
})
71-
})
72-
73-
describe('controlPatternsRegex', () => {
74-
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-
})
80-
})
81-
82-
describe('exceptedFunctionPatterns', () => {
83-
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-
})
88-
89-
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-
})
95-
96-
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-
})
35+
it('should truthify quotation mark', () => {
36+
expect(LineProcessor.isQuotationMark('"')).toBe(true);
37+
})
38+
39+
it('should falsify non quotation mark', () => {
40+
expect(LineProcessor.isQuotationMark('*')).toBe(false);
41+
})
42+
})
43+
44+
describe('isQuotationMark', () => {
45+
it('should find the range for one ControlPattern and one word and execute the callback once', () => {
46+
const results = [];
47+
LineProcessor.findTidalWordRanges(
48+
`d1 $ s "superpiano" # note 0`,
49+
(result) => results.push(result));
50+
51+
expect(results.length).toEqual(1);
52+
expect(results[0]).toEqual({ start: 8, end: 17 });
53+
})
54+
55+
it('should find the range for two ControlPatterns and several words and execute the callback accorgingly', () => {
56+
const results = [];
57+
LineProcessor.findTidalWordRanges(
58+
`d1 $ s "<superpiano 808>" # note "0"`,
59+
(result) => results.push(result));
60+
61+
expect(results.length).toEqual(3);
62+
expect(results[0]).toEqual({ start: 9, end: 18 });
63+
expect(results[1]).toEqual({ start: 20, end: 22 });
64+
expect(results[2]).toEqual({ start: 34, end: 34 });
65+
})
66+
67+
68+
it('should find the range for one relatively complex ControlPattern and several words and execute the callback accordingly', () => {
69+
const results = [];
70+
LineProcessor.findTidalWordRanges(
71+
`d1 $ s "superpiano" # note "c'maj'4*<1 2 3>"`,
72+
(result) => results.push(result));
73+
74+
expect(results.length).toEqual(7);
75+
expect(results[0]).toEqual({ start: 8, end: 17 });
76+
expect(results[1]).toEqual({ start: 28, end: 28 });
77+
expect(results[2]).toEqual({ start: 30, end: 32 });
78+
expect(results[3]).toEqual({ start: 34, end: 34 });
79+
expect(results[4]).toEqual({ start: 37, end: 37 });
80+
expect(results[5]).toEqual({ start: 39, end: 39 });
81+
expect(results[6]).toEqual({ start: 41, end: 41 });
10082
})
83+
})
84+
85+
describe('controlPatternsRegex', () => {
86+
it('should match all strings and their quotation marks in a line', () => {
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+
})
92+
})
93+
94+
describe('exceptedFunctionPatterns', () => {
95+
it('should match numerals function occurance in a line', () => {
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+
})
100+
101+
it('should match p function occurance in a line', () => {
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+
})
107+
108+
it('should not match an allowed control pattern in a line', () => {
109+
const testString = `d1 $ s "superpiano"`;
110+
expect(testString.match(LineProcessor.exceptedFunctionPatterns())).toBeNull()
111+
})
112+
})
101113
})
114+

0 commit comments

Comments
 (0)