add tests to better document reference comments
pofile does not process reference comments in any way, since the format of references is not exactly specified. This test specifies, what users of pofile can expect the library to do.
This commit is contained in:
parent
2e1640d847
commit
cfc9b2ae82
4
test/fixtures/reference.po
vendored
4
test/fixtures/reference.po
vendored
@ -24,3 +24,7 @@ msgstr "Attribut title, en tant que texte brut"
|
|||||||
#: b
|
#: b
|
||||||
msgid "X"
|
msgid "X"
|
||||||
msgstr "Y"
|
msgstr "Y"
|
||||||
|
|
||||||
|
#: standard input:12 standard input:17
|
||||||
|
msgid "Z"
|
||||||
|
msgstr "ZZ"
|
||||||
|
@ -67,23 +67,34 @@ describe('Parse', function () {
|
|||||||
assert.deepEqual(item.extractedComments, ['Extracted comment']);
|
assert.deepEqual(item.extractedComments, ['Extracted comment']);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Handles string references', function () {
|
describe('Handles string references', function () {
|
||||||
var po = PO.parse(fs.readFileSync(__dirname + '/fixtures/reference.po', 'utf8'));
|
var po = PO.parse(fs.readFileSync(__dirname + '/fixtures/reference.po', 'utf8'));
|
||||||
assert.notEqual(po, null);
|
assert.notEqual(po, null);
|
||||||
assert.equal(po.items.length, 2);
|
assert.equal(po.items.length, 3);
|
||||||
|
|
||||||
|
it('in simple cases', function () {
|
||||||
var item = po.items[0];
|
var item = po.items[0];
|
||||||
assert.equal(item.msgid, 'Title, as plain text');
|
assert.equal(item.msgid, 'Title, as plain text');
|
||||||
assert.equal(item.msgstr, 'Attribut title, en tant que texte brut');
|
assert.equal(item.msgstr, 'Attribut title, en tant que texte brut');
|
||||||
assert.deepEqual(item.comments, ['Comment']);
|
assert.deepEqual(item.comments, ['Comment']);
|
||||||
assert.deepEqual(item.references, ['.tmp/crm/controllers/map.js']);
|
assert.deepEqual(item.references, ['.tmp/crm/controllers/map.js']);
|
||||||
|
});
|
||||||
|
|
||||||
item = po.items[1];
|
it('with two different references', function () {
|
||||||
|
var item = po.items[1];
|
||||||
assert.equal(item.msgid, 'X');
|
assert.equal(item.msgid, 'X');
|
||||||
assert.equal(item.msgstr, 'Y');
|
assert.equal(item.msgstr, 'Y');
|
||||||
assert.deepEqual(item.references, ['a', 'b']);
|
assert.deepEqual(item.references, ['a', 'b']);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('and does not process reference items', function () {
|
||||||
|
var item = po.items[2];
|
||||||
|
assert.equal(item.msgid, 'Z');
|
||||||
|
assert.equal(item.msgstr, 'ZZ');
|
||||||
|
assert.deepEqual(item.references, ['standard input:12 standard input:17']);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it('Parses flags', function () {
|
it('Parses flags', function () {
|
||||||
var po = PO.parse(fs.readFileSync(__dirname + '/fixtures/fuzzy.po', 'utf8'));
|
var po = PO.parse(fs.readFileSync(__dirname + '/fixtures/fuzzy.po', 'utf8'));
|
||||||
assert.notEqual(po, null);
|
assert.notEqual(po, null);
|
||||||
|
Loading…
Reference in New Issue
Block a user