From abd94a7f5a50f43c797a11b53549ae48fff667c3 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Mon, 10 Oct 2016 03:43:44 +0200 Subject: add node_modules to address #4364 --- node_modules/po2json/test/po2json_test.js | 144 ++++++++++++++++++++++++++++++ 1 file changed, 144 insertions(+) create mode 100644 node_modules/po2json/test/po2json_test.js (limited to 'node_modules/po2json/test/po2json_test.js') diff --git a/node_modules/po2json/test/po2json_test.js b/node_modules/po2json/test/po2json_test.js new file mode 100644 index 000000000..18385274c --- /dev/null +++ b/node_modules/po2json/test/po2json_test.js @@ -0,0 +1,144 @@ +var po2json = require(".."), + fs = require("fs"), + Jed = require("jed"); + +module.exports["parse"] = { + setUp: function(callback){ + this.po = fs.readFileSync(__dirname + "/fixtures/pl.po"); + this.json = JSON.parse(fs.readFileSync(__dirname + "/fixtures/pl.json", "utf-8")); + callback(); + }, + + parse: function(test){ + var parsed = po2json.parse(this.po); + test.deepEqual(parsed, this.json); + test.done(); + } +} + +module.exports["parse with Jed format"] = { + setUp: function(callback){ + this.po = fs.readFileSync(__dirname + "/fixtures/pl.po"); + this.json = JSON.parse(fs.readFileSync(__dirname + "/fixtures/pl-jed.json", "utf-8")); + callback(); + }, + + parse: function(test){ + var parsed = po2json.parse(this.po, { format: 'jed' }); + test.deepEqual(parsed, this.json); + test.doesNotThrow(function() { new Jed(parsed) }, Error) + test.done(); + } +}; + +module.exports["parse with Jed1.x format"] = { + setUp: function(callback){ + this.po = fs.readFileSync(__dirname + "/fixtures/pl.po"); + this.json = JSON.parse(fs.readFileSync(__dirname + "/fixtures/pl-jed1.x.json", "utf-8")); + callback(); + }, + + parse: function(test){ + var parsed = po2json.parse(this.po, { format: 'jed1.x' }); + test.deepEqual(parsed, this.json); + test.doesNotThrow(function() { new Jed(parsed) }, Error) + test.done(); + } +}; + +module.exports["parse with MessageFormatter format"] = { + setUp: function(callback){ + this.po = fs.readFileSync(__dirname + "/fixtures/pl-mf.po"); + this.json = JSON.parse(fs.readFileSync(__dirname + "/fixtures/pl-mf.json", "utf-8")); + callback(); + }, + + parse: function(test){ + var parsed = po2json.parse(this.po, { format: 'mf' }); + test.deepEqual(parsed, this.json); + test.done(); + } +} + +module.exports["parse with MessageFormatter format + fallback-to-msgid"] = { + setUp: function(callback){ + this.po = fs.readFileSync(__dirname + "/fixtures/en-empty.po"); + this.json = JSON.parse(fs.readFileSync(__dirname + "/fixtures/en-mf-fallback-to-msgid.json", "utf-8")); + callback(); + }, + + parse: function(test){ + var parsed = po2json.parse(this.po, { format: 'mf', 'fallback-to-msgid': true }); + test.deepEqual(parsed, this.json); + test.done(); + } +} + +module.exports["parse with fallback-to-msgid"] = { + setUp: function(callback){ + this.po = fs.readFileSync(__dirname + "/fixtures/en-empty.po"); + this.json = JSON.parse(fs.readFileSync(__dirname + "/fixtures/en-empty.json", "utf-8")); + callback(); + }, + + parse: function(test){ + var parsed = po2json.parse(this.po, { 'fallback-to-msgid': true }); + test.deepEqual(parsed, this.json); + test.done(); + } +} +module.exports["parseFile"] = { + setUp: function(callback){ + this.json = JSON.parse(fs.readFileSync(__dirname + "/fixtures/pl.json", "utf-8")); + callback(); + }, + + parseFile: function(test){ + var self = this; + po2json.parseFile(__dirname + "/fixtures/pl.po", null, function (err, parsed) { + test.deepEqual(parsed, self.json); + test.done(); + }); + } +} + +module.exports["parseFileSync"] = { + setUp: function(callback){ + this.json = JSON.parse(fs.readFileSync(__dirname + "/fixtures/pl.json", "utf-8")); + callback(); + }, + + parseFileSync: function(test){ + var parsed = po2json.parseFileSync(__dirname + "/fixtures/pl.po"); + test.deepEqual(parsed, this.json); + test.done(); + } +} + +module.exports["parse with Plural-Forms == nplurals=1; plural=0;"] = { + setUp: function(callback){ + this.po = fs.readFileSync(__dirname + "/fixtures/ja.po"); + this.json = JSON.parse(fs.readFileSync(__dirname + "/fixtures/ja.json", "utf-8")); + callback(); + }, + + parse: function(test){ + var parsed = po2json.parse(this.po); + test.deepEqual(parsed, this.json); + test.done(); + } +} + +module.exports["parse with no headers"] ={ + setUp: function(callback){ + this.po = fs.readFileSync(__dirname + "/fixtures/en-no-header.po"); + this.json = JSON.parse(fs.readFileSync(__dirname + "/fixtures/en-no-header.json", "utf-8")); + callback(); + }, + + parse: function(test){ + var parsed = po2json.parse(this.po); + test.deepEqual(parsed, this.json); + test.done(); + } +} -- cgit v1.2.3