diff options
Diffstat (limited to 'node_modules/typographic-quotes/test.js')
| -rw-r--r-- | node_modules/typographic-quotes/test.js | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/node_modules/typographic-quotes/test.js b/node_modules/typographic-quotes/test.js new file mode 100644 index 0000000..b8b3e72 --- /dev/null +++ b/node_modules/typographic-quotes/test.js @@ -0,0 +1,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`)); |