Skip to content

Commit 31be551

Browse files
committed
Refactoring
1 parent a82481e commit 31be551

18 files changed

+76
-59
lines changed

src/array/for_each_pair.test.ts

Lines changed: 54 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { assertEquals } from "https://deno.land/std@0.203.0/assert/assert_equals.ts";
21
import {
32
assertSpyCall,
43
assertSpyCalls,
@@ -7,49 +6,61 @@ import {
76
import forEachPair from "./for_each_pair.ts";
87

98
Deno.test(
10-
'Remove duplicates from array.',
11-
async (test) => {
12-
await test.step({
13-
name: 'Empty array',
14-
fn: () => {
15-
function dummyFunction(
16-
previousValue : number,
17-
currentValue : number
18-
) : {
19-
previousValue : number,
20-
currentValue : number
21-
} { return {
22-
previousValue, currentValue
23-
}}
24-
25-
const dummyFunctionSpy = spy(dummyFunction);
9+
'Remove duplicates from array.',
10+
async (test) => {
11+
await test.step({
12+
name: 'Empty array',
13+
fn: () => {
14+
function dummyFunction(
15+
previousValue : number,
16+
currentValue : number
17+
) : {
18+
previousValue : number,
19+
currentValue : number
20+
} { return {
21+
previousValue, currentValue
22+
}}
23+
24+
const dummyFunctionSpy = spy(dummyFunction);
2625

27-
forEachPair(
28-
[0, 2, 3, 7],
29-
dummyFunctionSpy
30-
)
26+
forEachPair(
27+
[0, 2, 3, 7],
28+
dummyFunctionSpy
29+
)
3130

32-
assertSpyCall(dummyFunctionSpy, 0, {
33-
args: [
34-
0,
35-
2
36-
]
37-
})
38-
assertSpyCall(dummyFunctionSpy, 1, {
39-
args: [
40-
2,
41-
3
42-
]
43-
})
44-
assertSpyCall(dummyFunctionSpy, 2, {
45-
args: [
46-
3,
47-
7
48-
]
49-
})
50-
51-
assertSpyCalls(dummyFunctionSpy, 3);
52-
}
31+
assertSpyCall(dummyFunctionSpy, 0, {
32+
args: [
33+
0,
34+
2
35+
],
36+
returned: {
37+
currentValue: 0,
38+
previousValue: 2
39+
}
40+
})
41+
assertSpyCall(dummyFunctionSpy, 1, {
42+
args: [
43+
2,
44+
3
45+
],
46+
returned: {
47+
currentValue: 2,
48+
previousValue: 3
49+
}
5350
})
54-
}
51+
assertSpyCall(dummyFunctionSpy, 2, {
52+
args: [
53+
3,
54+
7
55+
],
56+
returned: {
57+
currentValue: 3,
58+
previousValue: 7
59+
}
60+
})
61+
62+
assertSpyCalls(dummyFunctionSpy, 3);
63+
}
64+
})
65+
}
5566
)

src/format/mod.ts

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,8 @@
11
import formatString from "./format_string.ts";
22
import truncate from "./truncate.ts";
3-
import trimCharactersStart from "./trim_characters_start.ts";
4-
import trimCharactersEnd from "./trim_characters_end.ts";
5-
import trimCharacters from "./trim_characters.ts";
6-
import trimSequenceStart from './trim_sequence_start.ts';
7-
import trimSequenceEnd from './trim_sequence_end.ts';
8-
import trimSequence from './trim_sequence.ts';
9-
import reverseString from './reverse_string.ts';
3+
104

115
export {
126
formatString,
137
truncate,
14-
trimCharactersStart,
15-
trimCharactersEnd,
16-
trimCharacters,
17-
trimSequenceStart,
18-
trimSequenceEnd,
19-
trimSequence,
20-
reverseString
218
}

src/string/mod.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
import reverseString from './reverse_string.ts';
2+
import {trim} from './trim/mod.ts'
3+
14
export {
2-
5+
reverseString,
6+
trim
37
}
File renamed without changes.
File renamed without changes.

src/string/trim/mod.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import trimCharacters from './trim_characters.ts';
2+
import trimCharactersEnd from './trim_characters_end.ts';
3+
import trimCharactersStart from './trim_characters_start.ts';
4+
import trimSequence from './trim_sequence.ts';
5+
import trimSequenceEnd from './trim_sequence_end.ts';
6+
import trimSequenceStart from './trim_sequence_start.ts';
7+
8+
export const trim = {
9+
trimCharactersStart,
10+
trimCharactersEnd,
11+
trimCharacters,
12+
trimSequenceStart,
13+
trimSequenceEnd,
14+
trimSequence
15+
}
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)