From b2e53d790bc4f5c6a02cdd3bddd26462f0e0aa17 Mon Sep 17 00:00:00 2001 From: Ruben Vermeersch Date: Tue, 17 Dec 2013 14:56:47 +0100 Subject: [PATCH] Test references. --- test/fixtures/reference.po | 26 ++++++++++++++++++++++++++ test/parse.js | 17 +++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 test/fixtures/reference.po diff --git a/test/fixtures/reference.po b/test/fixtures/reference.po new file mode 100644 index 0000000..8b3a695 --- /dev/null +++ b/test/fixtures/reference.po @@ -0,0 +1,26 @@ +# French translation of Link (6.x-2.9) +# Copyright (c) 2011 by the French translation team +# +msgid "" +msgstr "" +"Project-Id-Version: Link (6.x-2.9)\n" +"POT-Creation-Date: 2011-12-31 23:39+0000\n" +"PO-Revision-Date: 2013-12-17 14:21+0100\n" +"Language-Team: French\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n > 1);\n" +"Last-Translator: Ruben Vermeersch \n" +"Language: fr\n" +"X-Generator: Poedit 1.6.2\n" + +# Comment +#: .tmp/crm/controllers/map.js +msgid "Title, as plain text" +msgstr "Attribut title, en tant que texte brut" + +#: a +#: b +msgid "X" +msgstr "Y" diff --git a/test/parse.js b/test/parse.js index ea03a3a..51ee2d8 100644 --- a/test/parse.js +++ b/test/parse.js @@ -33,4 +33,21 @@ describe('Parse', function () { assert.equal(item.msgstr, "Attribut title, en tant que texte brut"); assert.deepEqual(item.comments, ["Comment"]); }); + + it('Handles string references', function () { + var po = PO.parse(fs.readFileSync(__dirname + '/fixtures/reference.po', 'utf8')); + assert.notEqual(po, null); + assert.equal(po.items.length, 2); + + var item = po.items[0]; + assert.equal(item.msgid, "Title, as plain text"); + assert.equal(item.msgstr, "Attribut title, en tant que texte brut"); + assert.deepEqual(item.comments, ["Comment"]); + assert.deepEqual(item.references, [".tmp/crm/controllers/map.js"]); + + item = po.items[1]; + assert.equal(item.msgid, "X"); + assert.equal(item.msgstr, "Y"); + assert.deepEqual(item.references, ["a", "b"]); + }); });