-
Notifications
You must be signed in to change notification settings - Fork 4
/
test.ts
60 lines (52 loc) · 1.73 KB
/
test.ts
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
// Copyright (c) 2019 Rafał Pocztarski. All rights reserved.
// MIT License (Expat). See: https://github.com/rsp/deno-clipboard
import { test } from 'https://deno.land/[email protected]/testing/mod.ts';
import { assertEquals } from 'https://deno.land/[email protected]/testing/asserts.ts';
import { clipboard } from './mod.ts';
// The tests currently ingnore trailing newlines
// because of some issues on Windows, see Readme.
test({
name: 'single line data',
async fn() {
const input = 'single line data';
await clipboard.writeText(input);
const output = await clipboard.readText();
assertEquals(output.replace(/\n+$/, ''), input.replace(/\n+$/, ''));
}
});
test({
name: 'multi line data',
async fn() {
const input = 'multi\nline\ndata';
await clipboard.writeText(input);
const output = await clipboard.readText();
assertEquals(output.replace(/\n+$/, ''), input.replace(/\n+$/, ''));
}
});
test({
name: 'multi line data dangling newlines',
async fn() {
const input = '\n\n\nmulti\n\n\n\n\n\nline\ndata\n\n\n\n\n';
await clipboard.writeText(input);
const output = await clipboard.readText();
assertEquals(output.replace(/\n+$/, ''), input.replace(/\n+$/, ''));
}
});
test({
name: 'data with special characters',
async fn() {
const input = '`~!@#$%^&*()_+-=[]{};\':",./<>?\t\n';
await clipboard.writeText(input);
const output = await clipboard.readText();
assertEquals(output.replace(/\n+$/, ''), input.replace(/\n+$/, ''));
}
});
test({
name: 'data with unicode characters',
async fn() {
const input = 'Rafał';
await clipboard.writeText(input);
const output = await clipboard.readText();
assertEquals(output.replace(/\n+$/, ''), input.replace(/\n+$/, ''));
}
});