fix default value of msgctxt field
I added a few more edge-cases to the tests for the new msgctxt field and revealed a bug during that. The default value has been set to empty string, but should have been null, since the spec says, this field is optional.
This commit is contained in:
parent
abca810905
commit
a5f3059661
@ -164,7 +164,7 @@ PO.parse = function (data) {
|
|||||||
|
|
||||||
PO.Item = function () {
|
PO.Item = function () {
|
||||||
this.msgid = '';
|
this.msgid = '';
|
||||||
this.msgctxt = '';
|
this.msgctxt = null;
|
||||||
this.references = [];
|
this.references = [];
|
||||||
this.msgid_plural = null;
|
this.msgid_plural = null;
|
||||||
this.msgstr = [];
|
this.msgstr = [];
|
||||||
|
@ -38,10 +38,28 @@ describe('Write', function () {
|
|||||||
assertHasLine(str, "msgstr \"Source\"");
|
assertHasLine(str, "msgstr \"Source\"");
|
||||||
});
|
});
|
||||||
|
|
||||||
it('write msgctxt', function () {
|
describe('msgctxt', function () {
|
||||||
|
it('should write context field to file', function () {
|
||||||
var input = fs.readFileSync(__dirname + '/fixtures/big.po', 'utf8');
|
var input = fs.readFileSync(__dirname + '/fixtures/big.po', 'utf8');
|
||||||
var po = PO.parse(input);
|
var po = PO.parse(input);
|
||||||
var str = po.toString();
|
var str = po.toString();
|
||||||
assertHasLine(str, 'msgctxt "folder action"');
|
assertHasLine(str, 'msgctxt "folder action"');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should ignore omitted context field', function () {
|
||||||
|
var po = new PO();
|
||||||
|
var item = new PO.Item();
|
||||||
|
po.items.push(item);
|
||||||
|
assert.ok(po.toString().indexOf('msgctxt') < 0);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should write empty context field', function () {
|
||||||
|
var po = new PO();
|
||||||
|
var item = new PO.Item();
|
||||||
|
|
||||||
|
item.msgctxt = '';
|
||||||
|
po.items.push(item);
|
||||||
|
assert.ok(po.toString().indexOf('msgctxt') >= 0);
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user