diff options
author | Florian Dold <florian.dold@gmail.com> | 2016-10-10 03:43:44 +0200 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2016-10-10 03:43:44 +0200 |
commit | abd94a7f5a50f43c797a11b53549ae48fff667c3 (patch) | |
tree | ab8ed457f65cdd72e13e0571d2975729428f1551 /node_modules/gettext-parser/test | |
parent | a0247c6a3fd6a09a41a7e35a3441324c4dcb58be (diff) |
add node_modules to address #4364
Diffstat (limited to 'node_modules/gettext-parser/test')
-rw-r--r-- | node_modules/gettext-parser/test/fixtures/latin13-mo.json | 69 | ||||
-rw-r--r-- | node_modules/gettext-parser/test/fixtures/latin13-po.json | 100 | ||||
-rw-r--r-- | node_modules/gettext-parser/test/fixtures/latin13.mo | bin | 0 -> 697 bytes | |||
-rw-r--r-- | node_modules/gettext-parser/test/fixtures/latin13.po | 60 | ||||
-rw-r--r-- | node_modules/gettext-parser/test/fixtures/utf8-mo.json | 69 | ||||
-rw-r--r-- | node_modules/gettext-parser/test/fixtures/utf8-po.json | 127 | ||||
-rw-r--r-- | node_modules/gettext-parser/test/fixtures/utf8.mo | bin | 0 -> 691 bytes | |||
-rw-r--r-- | node_modules/gettext-parser/test/fixtures/utf8.po | 75 | ||||
-rw-r--r-- | node_modules/gettext-parser/test/folder-test.js | 40 | ||||
-rw-r--r-- | node_modules/gettext-parser/test/mo-compiler-test.js | 30 | ||||
-rw-r--r-- | node_modules/gettext-parser/test/mo-parser-test.js | 29 | ||||
-rw-r--r-- | node_modules/gettext-parser/test/po-compiler-test.js | 30 | ||||
-rw-r--r-- | node_modules/gettext-parser/test/po-parser-test.js | 61 |
13 files changed, 690 insertions, 0 deletions
diff --git a/node_modules/gettext-parser/test/fixtures/latin13-mo.json b/node_modules/gettext-parser/test/fixtures/latin13-mo.json new file mode 100644 index 000000000..c91b4f78e --- /dev/null +++ b/node_modules/gettext-parser/test/fixtures/latin13-mo.json @@ -0,0 +1,69 @@ +{ + "charset": "iso-8859-13", + "headers": { + "project-id-version": "gettext-parser", + "report-msgid-bugs-to": "andris@node.ee", + "pot-creation-date": "2012-05-18 14:28:00+03:00", + "po-revision-date": "2012-05-18 14:44+0300", + "last-translator": "Andris Reinman <andris@kreata.ee>", + "language-team": "gettext-parser <andris@node.ee>", + "mime-version": "1.0", + "content-type": "text/plain; charset=iso-8859-13", + "content-transfer-encoding": "8bit", + "language": "", + "plural-forms": "nplurals=2; plural=(n!=1);", + "x-poedit-language": "Estonian", + "x-poedit-country": "ESTONIA", + "x-poedit-sourcecharset": "iso-8859-13" + }, + "translations": { + "": { + "": { + "msgid": "", + "msgstr": [ + "Project-Id-Version: gettext-parser\nReport-Msgid-Bugs-To: andris@node.ee\nPOT-Creation-Date: 2012-05-18 14:28:00+03:00\nPO-Revision-Date: 2012-05-18 14:44+0300\nLast-Translator: Andris Reinman <andris@kreata.ee>\nLanguage-Team: gettext-parser <andris@node.ee>\nMIME-Version: 1.0\nContent-Type: text/plain; charset=iso-8859-13\nContent-Transfer-Encoding: 8bit\nLanguage: \nPlural-Forms: nplurals=2; plural=(n!=1);\nX-Poedit-Language: Estonian\nX-Poedit-Country: ESTONIA\nX-Poedit-Sourcecharset: iso-8859-13\n" + ] + }, + "o1": { + "msgid": "o1", + "msgstr": [ + "t1" + ] + }, + "o2-1": { + "msgid": "o2-1", + "msgid_plural": "o2-2", + "msgstr": [ + "t2-1", + "t2-2" + ] + }, + "o3-õäöü": { + "msgid": "o3-õäöü", + "msgstr": [ + "t3-žš" + ] + } + }, + "c1": { + "co1": { + "msgctxt": "c1", + "msgid": "co1", + "msgstr": [ + "ct1" + ] + } + }, + "c2": { + "co2-1": { + "msgctxt": "c2", + "msgid": "co2-1", + "msgid_plural": "co2-2", + "msgstr": [ + "ct2-1", + "ct2-2" + ] + } + } + } +}
\ No newline at end of file diff --git a/node_modules/gettext-parser/test/fixtures/latin13-po.json b/node_modules/gettext-parser/test/fixtures/latin13-po.json new file mode 100644 index 000000000..c4b394d0c --- /dev/null +++ b/node_modules/gettext-parser/test/fixtures/latin13-po.json @@ -0,0 +1,100 @@ +{ + "charset": "iso-8859-13", + "headers": { + "project-id-version": "gettext-parser", + "report-msgid-bugs-to": "andris@node.ee", + "pot-creation-date": "2012-05-18 14:28:00+03:00", + "po-revision-date": "2012-05-18 14:44+0300", + "last-translator": "Andris Reinman <andris@kreata.ee>", + "language-team": "gettext-parser <andris@node.ee>", + "mime-version": "1.0", + "content-type": "text/plain; charset=iso-8859-13", + "content-transfer-encoding": "8bit", + "language": "", + "plural-forms": "nplurals=2; plural=(n!=1);", + "x-poedit-language": "Estonian", + "x-poedit-country": "ESTONIA", + "x-poedit-sourcecharset": "iso-8859-13" + }, + "translations": { + "": { + "": { + "msgid": "", + "comments": { + "translator": "gettext-parser test file.\nCopyright (C) 2012 Andris Reinman\nThis file is distributed under the same license as the gettext-parser package.\nANDRIS REINMAN <andris@node.ee>, 2012.\n" + }, + "msgstr": [ + "Project-Id-Version: gettext-parser\nReport-Msgid-Bugs-To: andris@node.ee\nPOT-Creation-Date: 2012-05-18 14:28:00+03:00\nPO-Revision-Date: 2012-05-18 14:44+0300\nLast-Translator: Andris Reinman <andris@kreata.ee>\nLanguage-Team: gettext-parser <andris@node.ee>\nMIME-Version: 1.0\nContent-Type: text/plain; charset=iso-8859-13\nContent-Transfer-Encoding: 8bit\nLanguage: \nPlural-Forms: nplurals=2; plural=(n!=1);\nX-Poedit-Language: Estonian\nX-Poedit-Country: ESTONIA\nX-Poedit-Sourcecharset: iso-8859-13\n" + ] + }, + "o1": { + "msgid": "o1", + "comments": { + "translator": "Normal string" + }, + "msgstr": [ + "t1" + ] + }, + "o2-1": { + "msgid": "o2-1", + "comments": { + "translator": "Plural string" + }, + "msgid_plural": "o2-2", + "msgstr": [ + "t2-1", + "t2-2" + ] + }, + "o3-õäöü": { + "msgid": "o3-õäöü", + "comments": { + "translator": "Normal string with special chars" + }, + "msgstr": [ + "t3-žš" + ] + }, + "test": { + "msgid": "test", + "comments": { + "translator": "Normal comment line 1\nNormal comment line 2", + "extracted": "Editors note line 1\nEditors note line 2", + "reference": "/absolute/path:13\n/absolute/path:14", + "flag": "line 1\nline 2", + "previous": "line 3\nline 4" + }, + "msgstr": [ + "test" + ] + } + }, + "c1": { + "co1": { + "msgid": "co1", + "msgctxt": "c1", + "comments": { + "translator": "Normal string in a context" + }, + "msgstr": [ + "ct1" + ] + } + }, + "c2": { + "co2-1": { + "msgid": "co2-1", + "msgctxt": "c2", + "comments": { + "translator": "Plural string in a context" + }, + "msgid_plural": "co2-2", + "msgstr": [ + "ct2-1", + "ct2-2" + ] + } + } + } +}
\ No newline at end of file diff --git a/node_modules/gettext-parser/test/fixtures/latin13.mo b/node_modules/gettext-parser/test/fixtures/latin13.mo Binary files differnew file mode 100644 index 000000000..bbfd0eb09 --- /dev/null +++ b/node_modules/gettext-parser/test/fixtures/latin13.mo diff --git a/node_modules/gettext-parser/test/fixtures/latin13.po b/node_modules/gettext-parser/test/fixtures/latin13.po new file mode 100644 index 000000000..d42a339bf --- /dev/null +++ b/node_modules/gettext-parser/test/fixtures/latin13.po @@ -0,0 +1,60 @@ +# gettext-parser test file. +# Copyright (C) 2012 Andris Reinman +# This file is distributed under the same license as the gettext-parser package. +# ANDRIS REINMAN <andris@node.ee>, 2012. +# +msgid "" +msgstr "" +"Project-Id-Version: gettext-parser\n" +"Report-Msgid-Bugs-To: andris@node.ee\n" +"POT-Creation-Date: 2012-05-18 14:28:00+03:00\n" +"PO-Revision-Date: 2012-05-18 14:44+0300\n" +"Last-Translator: Andris Reinman <andris@kreata.ee>\n" +"Language-Team: gettext-parser <andris@node.ee>\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=iso-8859-13\n" +"Content-Transfer-Encoding: 8bit\n" +"Language: \n" +"Plural-Forms: nplurals=2; plural=(n!=1);\n" +"X-Poedit-Language: Estonian\n" +"X-Poedit-Country: ESTONIA\n" +"X-Poedit-Sourcecharset: iso-8859-13\n" + +# Normal string +msgid "o1" +msgstr "t1" + +# Plural string +msgid "o2-1" +msgid_plural "o2-2" +msgstr[0] "t2-1" +msgstr[1] "t2-2" + +# Normal string with special chars +msgid "o3-õäöü" +msgstr "t3-þð" + +# Normal comment line 1 +# Normal comment line 2 +#: /absolute/path:13 +#: /absolute/path:14 +#. Editors note line 1 +#. Editors note line 2 +#, line 1 +#, line 2 +#| line 3 +#| line 4 +msgid "test" +msgstr "test" + +# Normal string in a context +msgctxt "c1" +msgid "co1" +msgstr "ct1" + +# Plural string in a context +msgctxt "c2" +msgid "co2-1" +msgid_plural "co2-2" +msgstr[0] "ct2-1" +msgstr[1] "ct2-2"
\ No newline at end of file diff --git a/node_modules/gettext-parser/test/fixtures/utf8-mo.json b/node_modules/gettext-parser/test/fixtures/utf8-mo.json new file mode 100644 index 000000000..29b2c0852 --- /dev/null +++ b/node_modules/gettext-parser/test/fixtures/utf8-mo.json @@ -0,0 +1,69 @@ +{ + "charset": "utf-8", + "headers": { + "project-id-version": "gettext-parser", + "report-msgid-bugs-to": "andris@node.ee", + "pot-creation-date": "2012-05-18 14:28:00+03:00", + "po-revision-date": "2012-05-18 14:37+0300", + "last-translator": "Andris Reinman <andris@kreata.ee>", + "language-team": "gettext-parser <andris@node.ee>", + "mime-version": "1.0", + "content-type": "text/plain; charset=utf-8", + "content-transfer-encoding": "8bit", + "language": "", + "plural-forms": "nplurals=2; plural=(n!=1);", + "x-poedit-language": "Estonian", + "x-poedit-country": "ESTONIA", + "x-poedit-sourcecharset": "utf-8" + }, + "translations": { + "": { + "": { + "msgid": "", + "msgstr": [ + "Project-Id-Version: gettext-parser\nReport-Msgid-Bugs-To: andris@node.ee\nPOT-Creation-Date: 2012-05-18 14:28:00+03:00\nPO-Revision-Date: 2012-05-18 14:37+0300\nLast-Translator: Andris Reinman <andris@kreata.ee>\nLanguage-Team: gettext-parser <andris@node.ee>\nMIME-Version: 1.0\nContent-Type: text/plain; charset=utf-8\nContent-Transfer-Encoding: 8bit\nLanguage: \nPlural-Forms: nplurals=2; plural=(n!=1);\nX-Poedit-Language: Estonian\nX-Poedit-Country: ESTONIA\nX-Poedit-Sourcecharset: utf-8\n" + ] + }, + "o1": { + "msgid": "o1", + "msgstr": [ + "t1" + ] + }, + "o2-1": { + "msgid": "o2-1", + "msgid_plural": "o2-2", + "msgstr": [ + "t2-1", + "t2-2" + ] + }, + "o3-õäöü": { + "msgid": "o3-õäöü", + "msgstr": [ + "t3-žš" + ] + } + }, + "c1": { + "co1": { + "msgctxt": "c1", + "msgid": "co1", + "msgstr": [ + "ct1" + ] + } + }, + "c2": { + "co2-1": { + "msgctxt": "c2", + "msgid": "co2-1", + "msgid_plural": "co2-2", + "msgstr": [ + "ct2-1", + "ct2-2" + ] + } + } + } +}
\ No newline at end of file diff --git a/node_modules/gettext-parser/test/fixtures/utf8-po.json b/node_modules/gettext-parser/test/fixtures/utf8-po.json new file mode 100644 index 000000000..e5921b7e8 --- /dev/null +++ b/node_modules/gettext-parser/test/fixtures/utf8-po.json @@ -0,0 +1,127 @@ +{ + "charset": "utf-8", + "headers": { + "project-id-version": "gettext-parser", + "report-msgid-bugs-to": "andris@node.ee", + "pot-creation-date": "2012-05-18 14:28:00+03:00", + "po-revision-date": "2012-05-18 14:37+0300", + "last-translator": "Andris Reinman <andris@kreata.ee>", + "language-team": "gettext-parser <andris@node.ee>", + "mime-version": "1.0", + "content-type": "text/plain; charset=utf-8", + "content-transfer-encoding": "8bit", + "language": "", + "plural-forms": "nplurals=2; plural=(n!=1);", + "x-poedit-language": "Estonian", + "x-poedit-country": "ESTONIA", + "x-poedit-sourcecharset": "utf-8" + }, + "translations": { + "": { + "": { + "msgid": "", + "comments": { + "translator": "gettext-parser test file.\nCopyright (C) 2012 Andris Reinman\nThis file is distributed under the same license as the gettext-parser package.\nANDRIS REINMAN <andris@node.ee>, 2012.\n" + }, + "msgstr": [ + "Project-Id-Version: gettext-parser\nReport-Msgid-Bugs-To: andris@node.ee\nPOT-Creation-Date: 2012-05-18 14:28:00+03:00\nPO-Revision-Date: 2012-05-18 14:37+0300\nLast-Translator: Andris Reinman <andris@kreata.ee>\nLanguage-Team: gettext-parser <andris@node.ee>\nMIME-Version: 1.0\nContent-Type: text/plain; charset=utf-8\nContent-Transfer-Encoding: 8bit\nLanguage: \nPlural-Forms: nplurals=2; plural=(n!=1);\nX-Poedit-Language: Estonian\nX-Poedit-Country: ESTONIA\nX-Poedit-Sourcecharset: utf-8\n" + ] + }, + "o1": { + "msgid": "o1", + "comments": { + "translator": "Normal string" + }, + "msgstr": [ + "t1" + ] + }, + "o2-1": { + "msgid": "o2-1", + "comments": { + "translator": "Plural string" + }, + "msgid_plural": "o2-2\no2-3\no2-4", + "msgstr": [ + "t2-1", + "t2-2" + ] + }, + "o3-õäöü": { + "msgid": "o3-õäöü", + "comments": { + "translator": "Normal string with special chars" + }, + "msgstr": [ + "t3-žš" + ] + }, + "test": { + "msgid": "test", + "comments": { + "translator": "Normal comment line 1\nNormal comment line 2", + "extracted": "Editors note line 1\nEditors note line 2", + "reference": "/absolute/path:13\n/absolute/path:14", + "flag": "line 1\nline 2", + "previous": "line 3\nline 4" + }, + "msgstr": [ + "test" + ] + }, + "\"\\'\t": { + "msgid": "\"\\'\t", + "comments": { + "translator": "String with escapes" + }, + "msgstr": [ + "\"\\'\t" + ] + } + }, + "c1": { + "co1": { + "msgid": "co1", + "msgctxt": "c1", + "comments": { + "translator": "Normal string in a context" + }, + "msgstr": [ + "ct1" + ] + } + }, + "c2": { + "co2-1": { + "msgid": "co2-1", + "msgctxt": "c2", + "comments": { + "translator": "Plural string in a context" + }, + "msgid_plural": "co2-2", + "msgstr": [ + "ct2-1", + "ct2-2" + ] + } + }, + "Button label": { + "Log in": { + "msgid": "Log in", + "msgctxt": "Button label", + "msgstr": [ + "" + ] + } + }, + "Dialog title": { + "Log in": { + "msgid": "Log in", + "msgctxt": "Dialog title", + "msgstr": [ + "" + ] + } + } + } +}
\ No newline at end of file diff --git a/node_modules/gettext-parser/test/fixtures/utf8.mo b/node_modules/gettext-parser/test/fixtures/utf8.mo Binary files differnew file mode 100644 index 000000000..efafe43e6 --- /dev/null +++ b/node_modules/gettext-parser/test/fixtures/utf8.mo diff --git a/node_modules/gettext-parser/test/fixtures/utf8.po b/node_modules/gettext-parser/test/fixtures/utf8.po new file mode 100644 index 000000000..3d879463a --- /dev/null +++ b/node_modules/gettext-parser/test/fixtures/utf8.po @@ -0,0 +1,75 @@ +# gettext-parser test file. +# Copyright (C) 2012 Andris Reinman +# This file is distributed under the same license as the gettext-parser package. +# ANDRIS REINMAN <andris@node.ee>, 2012. +# +msgid "" +msgstr "" +"Project-Id-Version: gettext-parser\n" +"Report-Msgid-Bugs-To: andris@node.ee\n" +"POT-Creation-Date: 2012-05-18 14:28:00+03:00\n" +"PO-Revision-Date: 2012-05-18 14:37+0300\n" +"Last-Translator: Andris Reinman <andris@kreata.ee>\n" +"Language-Team: gettext-parser <andris@node.ee>\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=utf-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Language: \n" +"Plural-Forms: nplurals=2; plural=(n!=1);\n" +"X-Poedit-Language: Estonian\n" +"X-Poedit-Country: ESTONIA\n" +"X-Poedit-Sourcecharset: utf-8\n" + +# Normal string +msgid "o1" +msgstr "t1" + +# Plural string +msgid "o2-1" +msgid_plural "" +"o2-2\n" +"o2-3\n" +"o2-4" +msgstr[0] "t2-1" +msgstr[1] "t2-2" + +# Normal string with special chars +msgid "o3-õäöü" +msgstr "t3-žš" + +# Normal comment line 1 +# Normal comment line 2 +#: /absolute/path:13 +#: /absolute/path:14 +#. Editors note line 1 +#. Editors note line 2 +#, line 1 +#, line 2 +#| line 3 +#| line 4 +msgid "test" +msgstr "test" + +# String with escapes +msgid "\"\\'\t" +msgstr "\"\\'\t" + +# Normal string in a context +msgctxt "c1" +msgid "co1" +msgstr "ct1" + +# Plural string in a context +msgctxt "c2" +msgid "co2-1" +msgid_plural "co2-2" +msgstr[0] "ct2-1" +msgstr[1] "ct2-2" + +msgctxt "Button label" +msgid "Log in" +msgstr "" + +msgctxt "Dialog title" +msgid "Log in" +msgstr ""
\ No newline at end of file diff --git a/node_modules/gettext-parser/test/folder-test.js b/node_modules/gettext-parser/test/folder-test.js new file mode 100644 index 000000000..7f1bbecae --- /dev/null +++ b/node_modules/gettext-parser/test/folder-test.js @@ -0,0 +1,40 @@ +'use strict'; + +var chai = require('chai'); +var sharedFuncs = require('../lib/shared'); + +var expect = chai.expect; +chai.config.includeStack = true; + +describe('Folding tests', function() { + + it('Short line, no folding', function() { + var line = 'abc def ghi'; + var folded = sharedFuncs.foldLine(line); + + expect(line).to.equal(folded.join('')); + expect(folded.length).to.equal(1); + }); + + it('Short line, force fold with newline', function() { + var line = 'abc \\ndef \\nghi'; + var folded = sharedFuncs.foldLine(line); + + expect(line).to.equal(folded.join('')); + expect(folded).to.deep.equal(['abc \\n', 'def \\n', 'ghi']); + }); + + it('Long line', function() { + var expected = ['Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum pretium ', + 'a nunc ac fringilla. Nulla laoreet tincidunt tincidunt. Proin tristique ', + 'vestibulum mauris non aliquam. Vivamus volutpat odio nisl, sed placerat ', + 'turpis sodales a. Vestibulum quis lectus ac elit sagittis sodales ac a ', + 'felis. Nulla iaculis, nisl ut mattis fringilla, tortor quam tincidunt ', + 'lorem, quis feugiat purus felis ut velit. Donec euismod eros ut leo ', + 'lobortis tristique.' + ]; + var folded = sharedFuncs.foldLine(expected.join('')); + expect(folded).to.deep.equal(expected); + }); + +});
\ No newline at end of file diff --git a/node_modules/gettext-parser/test/mo-compiler-test.js b/node_modules/gettext-parser/test/mo-compiler-test.js new file mode 100644 index 000000000..77b820f81 --- /dev/null +++ b/node_modules/gettext-parser/test/mo-compiler-test.js @@ -0,0 +1,30 @@ +'use strict'; + +var chai = require('chai'); +var gettextParser = require('..'); +var fs = require('fs'); + +var expect = chai.expect; +chai.config.includeStack = true; + +describe('MO Compiler', function() { + + describe('UTF-8', function() { + it('should compile', function() { + var json = JSON.parse(fs.readFileSync(__dirname + '/fixtures/utf8-mo.json', 'utf-8')); + var mo = fs.readFileSync(__dirname + '/fixtures/utf8.mo'); + + var compiled = gettextParser.mo.compile(json); + expect(compiled).to.deep.equal(mo); + }); + }); + + describe('Latin-13', function() { + it('should compile', function() { + var json = JSON.parse(fs.readFileSync(__dirname + '/fixtures/latin13-mo.json', 'utf-8')); + var mo = fs.readFileSync(__dirname + '/fixtures/latin13.mo'); + var compiled = gettextParser.mo.compile(json); + expect(compiled).to.deep.equal(mo); + }); + }); +});
\ No newline at end of file diff --git a/node_modules/gettext-parser/test/mo-parser-test.js b/node_modules/gettext-parser/test/mo-parser-test.js new file mode 100644 index 000000000..a8d9895c4 --- /dev/null +++ b/node_modules/gettext-parser/test/mo-parser-test.js @@ -0,0 +1,29 @@ +'use strict'; + +var chai = require('chai'); +var gettextParser = require('..'); +var fs = require('fs'); + +var expect = chai.expect; +chai.config.includeStack = true; + +describe('MO Parser', function() { + + describe('UTF-8', function() { + it('should parse', function() { + var mo = fs.readFileSync(__dirname + '/fixtures/utf8.mo'); + var json = JSON.parse(fs.readFileSync(__dirname + '/fixtures/utf8-mo.json', 'utf-8')); + var parsed = gettextParser.mo.parse(mo); + expect(parsed).to.deep.equal(json); + }); + }); + + describe('Latin-13', function() { + it('should parse', function() { + var mo = fs.readFileSync(__dirname + '/fixtures/latin13.mo'); + var json = JSON.parse(fs.readFileSync(__dirname + '/fixtures/latin13-mo.json', 'utf-8')); + var parsed = gettextParser.mo.parse(mo); + expect(parsed).to.deep.equal(json); + }); + }); +});
\ No newline at end of file diff --git a/node_modules/gettext-parser/test/po-compiler-test.js b/node_modules/gettext-parser/test/po-compiler-test.js new file mode 100644 index 000000000..d93ae825a --- /dev/null +++ b/node_modules/gettext-parser/test/po-compiler-test.js @@ -0,0 +1,30 @@ +'use strict'; + +var chai = require('chai'); +var gettextParser = require('..'); +var fs = require('fs'); + +var expect = chai.expect; +chai.config.includeStack = true; + +describe('PO Compiler', function() { + + describe('UTF-8', function() { + it('should compile', function() { + var json = JSON.parse(fs.readFileSync(__dirname + '/fixtures/utf8-po.json', 'utf-8')); + var po = fs.readFileSync(__dirname + '/fixtures/utf8.po'); + + var compiled = gettextParser.po.compile(json); + expect(compiled).to.deep.equal(po); + }); + }); + + describe('Latin-13', function() { + it('should compile', function() { + var json = JSON.parse(fs.readFileSync(__dirname + '/fixtures/latin13-po.json', 'utf-8')); + var po = fs.readFileSync(__dirname + '/fixtures/latin13.po'); + var compiled = gettextParser.po.compile(json); + expect(compiled).to.deep.equal(po); + }); + }); +});
\ No newline at end of file diff --git a/node_modules/gettext-parser/test/po-parser-test.js b/node_modules/gettext-parser/test/po-parser-test.js new file mode 100644 index 000000000..8e908fec9 --- /dev/null +++ b/node_modules/gettext-parser/test/po-parser-test.js @@ -0,0 +1,61 @@ +'use strict'; + +var chai = require('chai'); +var gettextParser = require('..'); +var fs = require('fs'); + +var expect = chai.expect; +chai.config.includeStack = true; + +describe('PO Parser', function() { + + describe('UTF-8', function() { + it('should parse', function() { + var po = fs.readFileSync(__dirname + '/fixtures/utf8.po'); + var json = JSON.parse(fs.readFileSync(__dirname + '/fixtures/utf8-po.json', 'utf-8')); + var parsed = gettextParser.po.parse(po); + expect(parsed).to.deep.equal(json); + }); + }); + + describe('UTF-8 as a string', function() { + it('should parse', function() { + var po = fs.readFileSync(__dirname + '/fixtures/utf8.po', 'utf-8'); + var json = JSON.parse(fs.readFileSync(__dirname + '/fixtures/utf8-po.json', 'utf-8')); + var parsed = gettextParser.po.parse(po); + expect(parsed).to.deep.equal(json); + }); + }); + + describe('Stream input', function() { + it('should parse', function(done) { + var po = fs.createReadStream(__dirname + '/fixtures/utf8.po', { + highWaterMark: 1 // ensure that any utf-8 sequences will be broken when streaming + }); + var json = JSON.parse(fs.readFileSync(__dirname + '/fixtures/utf8-po.json', 'utf-8')); + + var parsed; + var stream = po.pipe(gettextParser.po.createParseStream({ + initialTreshold: 800 // home many bytes to cache for parsing the header + })); + stream.on('data', function(data) { + parsed = data; + }); + stream.on('end', function() { + expect(parsed).to.deep.equal(json); + done(); + }); + + }); + }); + + describe('Latin-13', function() { + it('should parse', function() { + var po = fs.readFileSync(__dirname + '/fixtures/latin13.po'); + var json = JSON.parse(fs.readFileSync(__dirname + '/fixtures/latin13-po.json', 'utf-8')); + var parsed = gettextParser.po.parse(po); + expect(parsed).to.deep.equal(json); + }); + }); + +});
\ No newline at end of file |