Add more tests for parsing.
This commit is contained in:
parent
a4ba136901
commit
5ce49c6201
20
test/fixtures/comment.po
vendored
Normal file
20
test/fixtures/comment.po
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
# 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 <ruben@rocketeer.be>\n"
|
||||
"Language: fr\n"
|
||||
"X-Generator: Poedit 1.6.2\n"
|
||||
|
||||
# Comment
|
||||
msgid "Title, as plain text"
|
||||
msgstr "Attribut title, en tant que texte brut"
|
24
test/fixtures/multi-line.po
vendored
Normal file
24
test/fixtures/multi-line.po
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
# 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 <ruben@rocketeer.be>\n"
|
||||
"Language: fr\n"
|
||||
"X-Generator: Poedit 1.6.2\n"
|
||||
|
||||
msgid ""
|
||||
"The following placeholder tokens can be used in both paths and titles. When "
|
||||
"used in a path or title, they will be replaced with the appropriate values."
|
||||
msgstr ""
|
||||
"Les ébauches de jetons suivantes peuvent être utilisées à la fois dans les "
|
||||
"chemins et dans les titres. Lorsqu'elles sont utilisées dans un chemin ou un "
|
||||
"titre, elles seront remplacées par les valeurs appropriées."
|
36
test/parse.js
Normal file
36
test/parse.js
Normal file
@ -0,0 +1,36 @@
|
||||
var assert = require('assert');
|
||||
var fs = require('fs');
|
||||
var PO = require('..');
|
||||
|
||||
describe('Parse', function () {
|
||||
it('Parses the big po file', function () {
|
||||
var po = PO.parse(fs.readFileSync(__dirname + '/fixtures/big.po', 'utf8'));
|
||||
assert.notEqual(po, null);
|
||||
assert.equal(po.items.length, 67);
|
||||
|
||||
var item = po.items[0];
|
||||
assert.equal(item.msgid, "Title");
|
||||
assert.equal(item.msgstr, "Titre");
|
||||
});
|
||||
|
||||
it('Handles multi-line strings', function () {
|
||||
var po = PO.parse(fs.readFileSync(__dirname + '/fixtures/multi-line.po', 'utf8'));
|
||||
assert.notEqual(po, null);
|
||||
assert.equal(po.items.length, 1);
|
||||
|
||||
var item = po.items[0];
|
||||
assert.equal(item.msgid, "The following placeholder tokens can be used in both paths and titles. When used in a path or title, they will be replaced with the appropriate values.");
|
||||
assert.equal(item.msgstr, "Les ébauches de jetons suivantes peuvent être utilisées à la fois dans les chemins et dans les titres. Lorsqu'elles sont utilisées dans un chemin ou un titre, elles seront remplacées par les valeurs appropriées.");
|
||||
});
|
||||
|
||||
it('Handles string comments', function () {
|
||||
var po = PO.parse(fs.readFileSync(__dirname + '/fixtures/comment.po', 'utf8'));
|
||||
assert.notEqual(po, null);
|
||||
assert.equal(po.items.length, 1);
|
||||
|
||||
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"]);
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue
Block a user