-
Notifications
You must be signed in to change notification settings - Fork 3
/
test.js
55 lines (39 loc) · 2.18 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
54
55
import quotes from './index';
import { equal } from 'assert';
const american = { locale: 'en-us' };
const russian = { locale: 'ru' };
const french = { locale: 'fr' };
it('should do nothing if locale is undefined', () =>
equal(quotes(`foo 'foo' bar`), `foo 'foo' bar`));
it('should fix simple quotes', () => {
equal(quotes(`foo 'foo' bar`, american), `foo “foo” bar`);
equal(quotes(`foo "foo" bar`, american), `foo “foo” bar`);
});
it('should fix nested quotes', () => {
equal(quotes(`foo "foo 'inside' bar" bar`, american), `foo “foo ‘inside’ bar” bar`);
equal(quotes(`foo 'foo "inside" bar' bar`, american), `foo “foo ‘inside’ bar” bar`);
});
it('should fix simple quotes for French', () =>
equal(quotes(`foo 'foo' bar`, french), `foo « foo » bar`));
it('should not fuck up not closed quotes', () =>
equal(quotes(`foo "foo" "bar`, american), `foo “foo” "bar`));
it('should fix simple quotes in the start', () =>
equal(quotes(`'foo' bar`, american), `“foo” bar`));
it('should fix simple quotes in the end', () =>
equal(quotes(`foo 'foo'`, american), `foo “foo”`));
it('should fix simple quotes ending quite before dot', () =>
equal(quotes(`foo 'foo'. bar`, american), `foo “foo”. bar`));
it('should fix simple quotes ending quite before coma', () =>
equal(quotes(`foo "foo", bar`, american), `foo “foo”, bar`));
it('should fix simple quotes and not messing up with apostrophes', () =>
equal(quotes(`foo's 'foo' bar`, american), `foo's “foo” bar`));
it('should fix simple several quotes in a row', () =>
equal(quotes(`foo 'foo' bar 'foo' bar`, american), `foo “foo” bar “foo” bar`));
it('should fix nested quotes for French', () =>
equal(quotes(`foo "foo 'inside' bar" bar`, french), `foo « foo “ inside ” bar » bar`));
it('should fix nested quotes in start', () =>
equal(quotes(`"foo 'inside' bar" bar`, american), `“foo ‘inside’ bar” bar`));
it('should fix nested quotes in end', () =>
equal(quotes(`foo "foo 'inside' bar"`, american), `foo “foo ‘inside’ bar”`));
it('should not change apostrophes', () =>
equal(quotes(`I'm not changing apostrophes`, american), `I'm not changing apostrophes`));