Skip to content

Commit 77bddc4

Browse files
committed
[string.js][s]: lint formatting
1 parent 2c94ac0 commit 77bddc4

1 file changed

Lines changed: 165 additions & 166 deletions

File tree

danfojs/tests/core/strings.js

Lines changed: 165 additions & 166 deletions
Original file line numberDiff line numberDiff line change
@@ -1,169 +1,168 @@
1-
import { assert } from "chai"
2-
import { Str } from '../../src/core/strings'
3-
import { Series } from "../../src/core/series"
4-
1+
import { assert } from "chai";
2+
import { Str } from '../../src/core/strings';
3+
import { Series } from "../../src/core/series";
54

65

76
describe("Str", function () {
8-
it("Converts all characters to lowercase.", function () {
9-
let data = ['lower', 'CAPITALS', 'this is a sentence', 'SwApCaSe']
10-
let res = ['lower', 'capitals', 'this is a sentence', 'swapcase']
11-
let str = new Str(new Series(data))
12-
assert.deepEqual(str.toLowerCase().values, res)
13-
})
14-
it("Converts all characters to uppercase.", function () {
15-
let data = ['lower', 'CAPITALS', 'this is a sentence', 'SwApCaSe']
16-
let res = ['LOWER', 'CAPITALS', 'THIS IS A SENTENCE', 'SWAPCASE']
17-
let str = new Str(new Series(data))
18-
assert.deepEqual(str.toUpperCase().values, res)
19-
})
20-
it("Converts all characters to capital case.", function () {
21-
let data = ['lower', 'CAPITALS', 'this is a sentence', 'SwApCaSe']
22-
let res = ['Lower', 'Capitals', 'This is a sentence', 'Swapcase']
23-
let str = new Str(new Series(data))
24-
assert.deepEqual(str.capitalize().values, res)
25-
})
26-
27-
it("Returns the character at the specified index (position)", function () {
28-
let data = ['lower', 'CAPITALS', 'this is a sentence', 'SwApCaSe']
29-
let res = ["w", "P", "i", "A"]
30-
let str = new Str(new Series(data))
31-
assert.deepEqual(str.charAt(2).values, res)
32-
})
33-
it("Joins two or more strings. 0 joins from the start", function () {
34-
let data = ['lower', 'CAPITALS', 'sentence', 'SwApCaSe']
35-
let data2 = ['XX', 'YY', 'BB', '01']
36-
37-
let res = ['XXlower', 'YYCAPITALS', 'BBsentence', '01SwApCaSe']
38-
let str = new Str(new Series(data))
39-
assert.deepEqual(str.concat(data2, 0).values, res)
40-
})
41-
42-
it("Joins two or more strings. 1 joins from the end", function () {
43-
let data = ['lower', 'CAPITALS', 'sentence', 'SwApCaSe']
44-
let data2 = ['XX', 'YY', 'BB', '01']
45-
46-
let res = ['lowerXX', 'CAPITALSYY', 'sentenceBB', 'SwApCaSe01']
47-
let str = new Str(new Series(data))
48-
assert.deepEqual(str.concat(data2, 1).values, res)
49-
})
50-
51-
it("Joins two arrays of strings. 0 joins from the start", function () {
52-
let data = ['lower', 'CAPITALS', 'sentence', 'SwApCaSe']
53-
let res = ['prelower', 'preCAPITALS', 'presentence', 'preSwApCaSe']
54-
let str = new Str(new Series(data))
55-
assert.deepEqual(str.concat("pre", 0).values, res)
56-
})
57-
58-
it("Joins two or more strings. 1 joins from the end", function () {
59-
let data = ['lower', 'CAPITALS', 'this is a sentence', 'SwApCaSe']
60-
let res = ['lowerpost', 'CAPITALSpost', 'this is a sentencepost', 'SwApCaSepost']
61-
let str = new Str(new Series(data))
62-
assert.deepEqual(str.concat("post", 1).values, res)
63-
})
64-
65-
it("Checks whether a string begins with specified characters", function () {
66-
let data = ['lower', 'CAPITALS', 'this is a sentence', 'SwApCaSe']
67-
let res = [true, false, false, false]
68-
let str = new Str(new Series(data))
69-
assert.deepEqual(str.startsWith("l").values, res)
70-
})
71-
it("Checks whether a string ends with specified characters", function () {
72-
let data = ['lower', 'CAPITALS', 'this is a sentence', 'SwApCaSe']
73-
let res = [false, false, true, true]
74-
let str = new Str(new Series(data))
75-
assert.deepEqual(str.endsWith("e").values, res)
76-
})
77-
78-
it("Checks whether a string contains the specified string/characters", function () {
79-
let data = ['lower', 'CAPITALS', 'this is a sentence', 'SwApCaSe']
80-
let res = [false, false, true, false]
81-
let str = new Str(new Series(data))
82-
assert.deepEqual(str.includes("sentence").values, res)
83-
})
84-
85-
it("Returns the position of the first found occurrence of a specified value in a string", function () {
86-
let data = ['lower', 'CAPITALS', 'this is a sentence', 'SwApCaSe']
87-
let res = [-1, 0, -1, 4]
88-
let str = new Str(new Series(data))
89-
assert.deepEqual(str.indexOf("C").values, res)
90-
})
91-
92-
it("Returns the position of the last found occurrence of a specified value in a string", function () {
93-
let data = ['lower', 'CAPITALS', 'this is a sentence', 'SwApCaSe']
94-
let res = [4, -1, -1, -1]
95-
let str = new Str(new Series(data))
96-
assert.deepEqual(str.lastIndexOf("r").values, res)
97-
})
98-
99-
it("Returns a new string with a specified number of copies of an existing string", function () {
100-
let data = ['a', 'b', 'c', 'd']
101-
let res = ['aaa', 'bbb', 'ccc', 'ddd']
102-
let str = new Str(new Series(data))
103-
assert.deepEqual(str.repeat(3).values, res)
104-
})
105-
106-
it("Searches a string for a specified value, or a regular expression, and returns a new string where the specified values are replaced", function () {
107-
let data = ['lower', 'CAPITALS', 'this is a sentence', 'SwApCaSe']
108-
let res = ['lower', 'CXXXPITALS', 'this is a sentence', 'SwXXXpCaSe']
109-
let str = new Str(new Series(data))
110-
assert.deepEqual(str.replace("A", "XXX").values, res)
111-
})
112-
113-
it("Searches a string for a specified value, or regular expression, and returns the position of the match", function () {
114-
let data = ['lower', 'CAPITALS', 'this is a sentence', 'SwApCaSe']
115-
let res = [-1, 1, -1, 2]
116-
let str = new Str(new Series(data))
117-
assert.deepEqual(str.search("A").values, res)
118-
})
119-
120-
it("Extracts a part of a string and returns a new string", function () {
121-
let data = ['lower', 'CAPITALS', 'this is a sentence', 'SwApCaSe']
122-
let res = ['ow', 'AP', 'hi', 'wA']
123-
let str = new Str(new Series(data))
124-
assert.deepEqual(str.slice(1, 3).values, res)
125-
})
126-
127-
it("Splits a string into an array of substrings", function () {
128-
let data = ['lower part', 'CAPITALS city', 'is a sentence', 'SwAp CaSe']
129-
let res = ["lower,part", "CAPITALS,city", "is,a,sentence", "SwAp,CaSe"]
130-
let str = new Str(new Series(data))
131-
assert.deepEqual(str.split(" ").values, res)
132-
})
133-
134-
it("Extracts the characters from a string, beginning at a specified start position, and through the specified number of character", function () {
135-
let data = ['lower part', 'CAPITALS city', 'this is a sentence', 'SwAp CaSe']
136-
let res = [" p", "AL", "is", "Ca"]
137-
let str = new Str(new Series(data))
138-
assert.deepEqual(str.substr(5, 2).values, res)
139-
})
140-
141-
it("Extracts the characters from a string, between two specified indices", function () {
142-
let data = ['lower part', 'CAPITALS city', 'this is a sentence', 'SwAp CaSe']
143-
let res = ["w", "P", "i", "A"]
144-
let str = new Str(new Series(data))
145-
assert.deepEqual(str.substring(2, 3).values, res)
146-
})
147-
148-
it("Removes whitespace from both ends of a string", function () {
149-
let data = ['lower part ', ' CAPITALS city', ' this is a sentence', ' SwAp CaSe']
150-
let res = ['lower part', 'CAPITALS city', 'this is a sentence', 'SwAp CaSe']
151-
let str = new Str(new Series(data))
152-
assert.deepEqual(str.trim().values, res)
153-
})
154-
155-
it("Joins strings to specified value", function () {
156-
let data = ['lower part', 'CAPITALS city', 'this is a sentence', 'SwAp CaSe']
157-
let res = ['lower part,new', 'CAPITALS city,new', 'this is a sentence,new', 'SwAp CaSe,new']
158-
let str = new Str(new Series(data))
159-
assert.deepEqual(str.join("new", ",").values, res)
160-
})
161-
162-
it("Counts the number of characters in string", function () {
163-
let data = ['lower part', 'CAPITALS', 'this is a sentence', 'SwApCaSe']
164-
let res = [10, 8, 18, 8]
165-
let str = new Str(new Series(data))
166-
assert.deepEqual(str.len().values, res)
167-
})
168-
169-
})
7+
it("Converts all characters to lowercase.", function () {
8+
let data = [ 'lower', 'CAPITALS', 'this is a sentence', 'SwApCaSe' ];
9+
let res = [ 'lower', 'capitals', 'this is a sentence', 'swapcase' ];
10+
let str = new Str(new Series(data));
11+
assert.deepEqual(str.toLowerCase().values, res);
12+
});
13+
it("Converts all characters to uppercase.", function () {
14+
let data = [ 'lower', 'CAPITALS', 'this is a sentence', 'SwApCaSe' ];
15+
let res = [ 'LOWER', 'CAPITALS', 'THIS IS A SENTENCE', 'SWAPCASE' ];
16+
let str = new Str(new Series(data));
17+
assert.deepEqual(str.toUpperCase().values, res);
18+
});
19+
it("Converts all characters to capital case.", function () {
20+
let data = [ 'lower', 'CAPITALS', 'this is a sentence', 'SwApCaSe' ];
21+
let res = [ 'Lower', 'Capitals', 'This is a sentence', 'Swapcase' ];
22+
let str = new Str(new Series(data));
23+
assert.deepEqual(str.capitalize().values, res);
24+
});
25+
26+
it("Returns the character at the specified index (position)", function () {
27+
let data = [ 'lower', 'CAPITALS', 'this is a sentence', 'SwApCaSe' ];
28+
let res = [ "w", "P", "i", "A" ];
29+
let str = new Str(new Series(data));
30+
assert.deepEqual(str.charAt(2).values, res);
31+
});
32+
it("Joins two or more strings. 0 joins from the start", function () {
33+
let data = [ 'lower', 'CAPITALS', 'sentence', 'SwApCaSe' ];
34+
let data2 = [ 'XX', 'YY', 'BB', '01' ];
35+
36+
let res = [ 'XXlower', 'YYCAPITALS', 'BBsentence', '01SwApCaSe' ];
37+
let str = new Str(new Series(data));
38+
assert.deepEqual(str.concat(data2, 0).values, res);
39+
});
40+
41+
it("Joins two or more strings. 1 joins from the end", function () {
42+
let data = [ 'lower', 'CAPITALS', 'sentence', 'SwApCaSe' ];
43+
let data2 = [ 'XX', 'YY', 'BB', '01' ];
44+
45+
let res = [ 'lowerXX', 'CAPITALSYY', 'sentenceBB', 'SwApCaSe01' ];
46+
let str = new Str(new Series(data));
47+
assert.deepEqual(str.concat(data2, 1).values, res);
48+
});
49+
50+
it("Joins two arrays of strings. 0 joins from the start", function () {
51+
let data = [ 'lower', 'CAPITALS', 'sentence', 'SwApCaSe' ];
52+
let res = [ 'prelower', 'preCAPITALS', 'presentence', 'preSwApCaSe' ];
53+
let str = new Str(new Series(data));
54+
assert.deepEqual(str.concat("pre", 0).values, res);
55+
});
56+
57+
it("Joins two or more strings. 1 joins from the end", function () {
58+
let data = [ 'lower', 'CAPITALS', 'this is a sentence', 'SwApCaSe' ];
59+
let res = [ 'lowerpost', 'CAPITALSpost', 'this is a sentencepost', 'SwApCaSepost' ];
60+
let str = new Str(new Series(data));
61+
assert.deepEqual(str.concat("post", 1).values, res);
62+
});
63+
64+
it("Checks whether a string begins with specified characters", function () {
65+
let data = [ 'lower', 'CAPITALS', 'this is a sentence', 'SwApCaSe' ];
66+
let res = [ true, false, false, false ];
67+
let str = new Str(new Series(data));
68+
assert.deepEqual(str.startsWith("l").values, res);
69+
});
70+
it("Checks whether a string ends with specified characters", function () {
71+
let data = [ 'lower', 'CAPITALS', 'this is a sentence', 'SwApCaSe' ];
72+
let res = [ false, false, true, true ];
73+
let str = new Str(new Series(data));
74+
assert.deepEqual(str.endsWith("e").values, res);
75+
});
76+
77+
it("Checks whether a string contains the specified string/characters", function () {
78+
let data = [ 'lower', 'CAPITALS', 'this is a sentence', 'SwApCaSe' ];
79+
let res = [ false, false, true, false ];
80+
let str = new Str(new Series(data));
81+
assert.deepEqual(str.includes("sentence").values, res);
82+
});
83+
84+
it("Returns the position of the first found occurrence of a specified value in a string", function () {
85+
let data = [ 'lower', 'CAPITALS', 'this is a sentence', 'SwApCaSe' ];
86+
let res = [ -1, 0, -1, 4 ];
87+
let str = new Str(new Series(data));
88+
assert.deepEqual(str.indexOf("C").values, res);
89+
});
90+
91+
it("Returns the position of the last found occurrence of a specified value in a string", function () {
92+
let data = [ 'lower', 'CAPITALS', 'this is a sentence', 'SwApCaSe' ];
93+
let res = [ 4, -1, -1, -1 ];
94+
let str = new Str(new Series(data));
95+
assert.deepEqual(str.lastIndexOf("r").values, res);
96+
});
97+
98+
it("Returns a new string with a specified number of copies of an existing string", function () {
99+
let data = [ 'a', 'b', 'c', 'd' ];
100+
let res = [ 'aaa', 'bbb', 'ccc', 'ddd' ];
101+
let str = new Str(new Series(data));
102+
assert.deepEqual(str.repeat(3).values, res);
103+
});
104+
105+
it("Searches a string for a specified value, or a regular expression, and returns a new string where the specified values are replaced", function () {
106+
let data = [ 'lower', 'CAPITALS', 'this is a sentence', 'SwApCaSe' ];
107+
let res = [ 'lower', 'CXXXPITALS', 'this is a sentence', 'SwXXXpCaSe' ];
108+
let str = new Str(new Series(data));
109+
assert.deepEqual(str.replace("A", "XXX").values, res);
110+
});
111+
112+
it("Searches a string for a specified value, or regular expression, and returns the position of the match", function () {
113+
let data = [ 'lower', 'CAPITALS', 'this is a sentence', 'SwApCaSe' ];
114+
let res = [ -1, 1, -1, 2 ];
115+
let str = new Str(new Series(data));
116+
assert.deepEqual(str.search("A").values, res);
117+
});
118+
119+
it("Extracts a part of a string and returns a new string", function () {
120+
let data = [ 'lower', 'CAPITALS', 'this is a sentence', 'SwApCaSe' ];
121+
let res = [ 'ow', 'AP', 'hi', 'wA' ];
122+
let str = new Str(new Series(data));
123+
assert.deepEqual(str.slice(1, 3).values, res);
124+
});
125+
126+
it("Splits a string into an array of substrings", function () {
127+
let data = [ 'lower part', 'CAPITALS city', 'is a sentence', 'SwAp CaSe' ];
128+
let res = [ "lower,part", "CAPITALS,city", "is,a,sentence", "SwAp,CaSe" ];
129+
let str = new Str(new Series(data));
130+
assert.deepEqual(str.split(" ").values, res);
131+
});
132+
133+
it("Extracts the characters from a string, beginning at a specified start position, and through the specified number of character", function () {
134+
let data = [ 'lower part', 'CAPITALS city', 'this is a sentence', 'SwAp CaSe' ];
135+
let res = [ " p", "AL", "is", "Ca" ];
136+
let str = new Str(new Series(data));
137+
assert.deepEqual(str.substr(5, 2).values, res);
138+
});
139+
140+
it("Extracts the characters from a string, between two specified indices", function () {
141+
let data = [ 'lower part', 'CAPITALS city', 'this is a sentence', 'SwAp CaSe' ];
142+
let res = [ "w", "P", "i", "A" ];
143+
let str = new Str(new Series(data));
144+
assert.deepEqual(str.substring(2, 3).values, res);
145+
});
146+
147+
it("Removes whitespace from both ends of a string", function () {
148+
let data = [ 'lower part ', ' CAPITALS city', ' this is a sentence', ' SwAp CaSe' ];
149+
let res = [ 'lower part', 'CAPITALS city', 'this is a sentence', 'SwAp CaSe' ];
150+
let str = new Str(new Series(data));
151+
assert.deepEqual(str.trim().values, res);
152+
});
153+
154+
it("Joins strings to specified value", function () {
155+
let data = [ 'lower part', 'CAPITALS city', 'this is a sentence', 'SwAp CaSe' ];
156+
let res = [ 'lower part,new', 'CAPITALS city,new', 'this is a sentence,new', 'SwAp CaSe,new' ];
157+
let str = new Str(new Series(data));
158+
assert.deepEqual(str.join("new", ",").values, res);
159+
});
160+
161+
it("Counts the number of characters in string", function () {
162+
let data = [ 'lower part', 'CAPITALS', 'this is a sentence', 'SwApCaSe' ];
163+
let res = [ 10, 8, 18, 8 ];
164+
let str = new Str(new Series(data));
165+
assert.deepEqual(str.len().values, res);
166+
});
167+
168+
});

0 commit comments

Comments
 (0)