-
-
Notifications
You must be signed in to change notification settings - Fork 63
/
Copy pathtest.js
53 lines (43 loc) · 1.28 KB
/
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
import {EOL} from 'node:os';
import test from 'ava';
import clipboard from './index.js';
const writeRead = async input => {
await clipboard.write(input);
return clipboard.read();
};
const writeReadSync = input => {
clipboard.writeSync(input);
return clipboard.readSync();
};
test('async', async t => {
const fixture = 'foo';
t.is(await writeRead(fixture), fixture);
});
test('sync', t => {
const fixture = 'foo';
t.is(writeReadSync(fixture), fixture);
});
test('works with ascii', async t => {
const fixture = '123456789abcdefghijklmnopqrstuvwxyz+-=&_[]<^=>=/{:})-{(`)}';
t.is(await writeRead(fixture), fixture);
});
test('works with unicode', async t => {
const fixture = 'ĀāĂ㥹ĆćĈĉĊċČčĎ ፰፱፲፳፴፵፶፷፸፹፺፻፼ æøå ±';
t.is(await writeRead(fixture), fixture);
});
test('works with unicode #2', async t => {
const fixture = '你好';
t.is(await writeRead(fixture), fixture);
});
test('works with emojis', async t => {
const fixture = '🦄❤️🤘🐑💩';
t.is(await writeRead(fixture), fixture);
});
test('EOL handling', async t => {
const fixture = `line ${EOL} line`;
t.is(await writeRead(fixture), fixture);
});
test('does not strips eof', async t => {
const fixture = `somestring${EOL}`;
t.is(await writeRead(fixture), fixture);
});