-
Notifications
You must be signed in to change notification settings - Fork 0
/
skype-copy-paste-formatter.test.js
267 lines (217 loc) · 6.17 KB
/
skype-copy-paste-formatter.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
// Type this into console: yarn test
// Tutorial: https://jestjs.io/docs/en/getting-started
// yarn test --coverage=true to get code coverage report
const SkypeCopyPasteFormatter = require('./skype-copy-paste-formatter');
test('General test', () => {
let scpf = new SkypeCopyPasteFormatter();
expect(scpf.getFormattedText(
`I'm getting ready to consider 2k (not 4k) for a main monitor
But, I don't want to spend too much
7:27 PM
Have you tried out 2k? Is it noticeably better?
Bob44, 7:27 PM
I have not.
But its gonna be awhile before 4k
Cause gaming still not there
7:28 PM
Yeah. Gpus are getting good, but increasing res and hz brings them back down to mediocre
Bob44, 7:28 PM
Yeah, but 4k can't even have 144hz yet
And it stresses out the VC more than 1080p or 2k`,
'Jeff22',
'other-person'
)).toBe(
`[[Bob44]] I'm getting ready to consider 2k (not 4k) for a main monitor
[[Bob44]] But, I don't want to spend too much
[[Jeff22]] Have you tried out 2k? Is it noticeably better?
[[Bob44]] I have not.
[[Bob44]] But its gonna be awhile before 4k
[[Bob44]] Cause gaming still not there
[[Jeff22]] Yeah. Gpus are getting good, but increasing res and hz brings them back down to mediocre
[[Bob44]] Yeah, but 4k can't even have 144hz yet
[[Bob44]] And it stresses out the VC more than 1080p or 2k`
);
});
test('No usernames', () => {
let scpf = new SkypeCopyPasteFormatter();
expect(scpf.getFormattedText(
`Haha no worries
Yeah 3rd monitor, gaming specs would prob be overkill
Just need to drag some windows on it when I'm multitasking for work`,
'Jeff22',
'you'
)).toBe(
`[[Jeff22]] Haha no worries
[[Jeff22]] Yeah 3rd monitor, gaming specs would prob be overkill
[[Jeff22]] Just need to drag some windows on it when I'm multitasking for work`
);
});
test('1 timestamp, 0 usernames', () => {
let scpf = new SkypeCopyPasteFormatter();
expect(scpf.getFormattedText(
`7:11 PM
Haha no worries
Yeah 3rd monitor, gaming specs would prob be overkill
Just need to drag some windows on it when I'm multitasking for work`,
'Jeff22',
'you'
)).toBe(
`[[Jeff22]] Haha no worries
[[Jeff22]] Yeah 3rd monitor, gaming specs would prob be overkill
[[Jeff22]] Just need to drag some windows on it when I'm multitasking for work`
);
});
test('1 username, 2 timestamps, line breaks', () => {
let scpf = new SkypeCopyPasteFormatter();
expect(scpf.getFormattedText(
`Bob44, 7:24 PM
I'm getting ready to consider 2k (not 4k) for a main monitor
But, I don't want to spend too much
7:27 PM
Have you tried out 2k? Is it noticeably better?`,
'Jeff22',
'you'
)).toBe(
`[[Bob44]] I'm getting ready to consider 2k (not 4k) for a main monitor
[[Bob44]] But, I don't want to spend too much
[[Jeff22]] Have you tried out 2k? Is it noticeably better?`
);
});
test("Already formatted (don't double format)", () => {
let scpf = new SkypeCopyPasteFormatter();
expect(scpf.getFormattedText(
`[[Bob44]] I'm getting ready to consider 2k (not 4k) for a main monitor
[[Bob44]] But, I don't want to spend too much
[[Jeff22]] Have you tried out 2k? Is it noticeably better?
[[Bob44]] I have not.
[[Bob44]] But its gonna be awhile before 4k
[[Bob44]] Cause gaming still not there
[[Jeff22]] Yeah. Gpus are getting good, but increasing res and hz brings them back down to mediocre
[[Bob44]] Yeah, but 4k can't even have 144hz yet
[[Bob44]] And it stresses out the VC more than 1080p or 2k`,
'Jeff22',
'you'
)).toBe(
`[[Bob44]] I'm getting ready to consider 2k (not 4k) for a main monitor
[[Bob44]] But, I don't want to spend too much
[[Jeff22]] Have you tried out 2k? Is it noticeably better?
[[Bob44]] I have not.
[[Bob44]] But its gonna be awhile before 4k
[[Bob44]] Cause gaming still not there
[[Jeff22]] Yeah. Gpus are getting good, but increasing res and hz brings them back down to mediocre
[[Bob44]] Yeah, but 4k can't even have 144hz yet
[[Bob44]] And it stresses out the VC more than 1080p or 2k`
);
});
test('Trim test (1 space at end of every line)', () => {
let scpf = new SkypeCopyPasteFormatter();
expect(scpf.getFormattedText(
`Testing 123
Testing 123 `,
'Jeff22',
'you'
)).toBe(
`[[Jeff22]] Testing 123
[[Jeff22]] Testing 123`
);
});
test('Fix line breaks', () => {
let scpf = new SkypeCopyPasteFormatter();
expect(scpf.getFormattedText(
`Testing.Hello, how are you?I'm good, you?I'm excellent!That's great to hear.
This is a test.
Of the emergency broadcast system.
I see.
Ok.`,
'Jeff22',
'you'
)).toBe(
`[[Jeff22]] Testing.
[[Jeff22]] Hello, how are you?
[[Jeff22]] I'm good, you?
[[Jeff22]] I'm excellent!
[[Jeff22]] That's great to hear.
[[Jeff22]] This is a test.
[[Jeff22]] Of the emergency broadcast system.
[[Jeff22]] I see.
[[Jeff22]] Ok.`
);
});
test('Fancy punctuation', () => {
let scpf = new SkypeCopyPasteFormatter();
expect(scpf.getFormattedText(
`'“': '"',
'”': '"',
'‘': '\'',
'’': '\'',
'¼': '1/4',
'½': '1/2',
'¾': '3/4',
'–': '-',
'—': '--',
'…': '...',`,
'Jeff22',
'you'
)).toBe(
`[[Jeff22]] '"': '"',
[[Jeff22]] '"': '"',
[[Jeff22]] ''': '\'',
[[Jeff22]] ''': '\'',
[[Jeff22]] '1/4': '1/4',
[[Jeff22]] '1/2': '1/2',
[[Jeff22]] '3/4': '3/4',
[[Jeff22]] '-': '-',
[[Jeff22]] '--': '--',
[[Jeff22]] '...': '...',`
);
});
test('Double fancy punctuation', () => {
let scpf = new SkypeCopyPasteFormatter();
expect(scpf.getFormattedText(
`“““`,
'Jeff22',
'you'
)).toBe(
`[[Jeff22]] """`
);
});
test('0 usernames, line breaks', () => {
let scpf = new SkypeCopyPasteFormatter();
expect(scpf.getFormattedText(
`Line 1
Line 2
Line 3`,
'Jeff22',
'you'
)).toBe(
`[[Jeff22]] Line 1
[[Jeff22]] Line 2
[[Jeff22]] Line 3`
);
});
test('For logs with no line breaks, handle username in middle of log correctly', () => {
let scpf = new SkypeCopyPasteFormatter();
expect(scpf.getFormattedText(
`The word word word.They word word word.Username, 5:52 AMIf word word word. The word word word.The word word word. The word word word.The word word word.`,
'Jeff22',
'you'
)).toBe(
`[[Jeff22]] The word word word.
[[Jeff22]] They word word word.
[[Username]] If word word word. The word word word.
[[Username]] The word word word. The word word word.
[[Username]] The word word word.`
);
});
/* Template:
test('', () => {
let scpf = new SkypeCopyPasteFormatter();
expect(scpf.getFormattedText(
``,
'Jeff22',
'you'
)).toBe(
``
);
});
*/