-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathutil.test.js
79 lines (69 loc) · 2 KB
/
util.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import "babel-polyfill";
import chai from "chai";
const assert = chai.assert;
import { splitNoParen } from "../src/util";
describe("cqmd util", () => {
describe("splitNoParen", () => {
it("should split in the simple case", () => {
assert.deepEqual(splitNoParen("foo,bar,baz"), ["foo", "bar", "baz"]);
});
it("should split function calls", () => {
assert.deepEqual(splitNoParen("foo,bam(0), baz"), [
"foo",
"bam(0)",
" baz"
]);
});
it("should allow ranges", () => {
assert.deepEqual(splitNoParen("foo-bar,baz"), ["foo-bar", "baz"]);
});
it("should functions at the start of ranges", () => {
assert.deepEqual(splitNoParen("cats,foo(.fs)-bar,baz"), [
"cats",
"foo(.fs)-bar",
"baz"
]);
});
it("should functions at the end of ranges", () => {
assert.deepEqual(splitNoParen("cats,bar-foo(.fs),baz"), [
"cats",
"bar-foo(.fs)",
"baz"
]);
});
it("should allow groupings at the start of ranges", () => {
assert.deepEqual(splitNoParen("cats,(.fs-.foo)-.bar,baz"), [
"cats",
"(.fs-.foo)-.bar",
"baz"
]);
});
it("should allow groupings at the end of ranges", () => {
assert.deepEqual(splitNoParen("cats,.bar-(.fs-.foo),baz"), [
"cats",
".bar-(.fs-.foo)",
"baz"
]);
});
it("should allow function arguments", () => {
assert.deepEqual(splitNoParen("cats,.bar(.fs, .foo),baz"), [
"cats",
".bar(.fs, .foo)",
"baz"
]);
});
it("should allow nested functions", () => {
assert.deepEqual(splitNoParen("cats,.bar(bam(.fs, .qs), .foo),baz"), [
"cats",
".bar(bam(.fs, .qs), .foo)",
"baz"
]);
});
it("should parse the SO question", () => {
assert.deepEqual(
splitNoParen('"abc",ab(),c(d(),e()),f(g(),zyx),h(123)'),
['"abc"', "ab()", "c(d(),e())", "f(g(),zyx)", "h(123)"]
);
});
});
});