Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

added node-tap tests for build-i18n.js, and fixed a bug in html-to-i1…

…8n.js.
  • Loading branch information...
commit 1205d4f4a2e675eea74cda289efc9a870117f4a4 1 parent bb889da
@toolness authored
View
11 bin/build-i18n.js
@@ -3,10 +3,12 @@
var MODULE_FILTER = process.argv.slice(2);
var fs = require('fs');
+var resolve = require('path').resolve;
var buildRequire = require('./build-require');
var rootDir = buildRequire.rootDir;
+var templateDir = resolve(rootDir, '..', 'templates');
var requirejs = require('requirejs');
-var bundles = {};
+var bundles = exports.bundles = {};
var config = buildRequire.generateConfig();
function findNlsPaths(root, subdir) {
@@ -48,11 +50,11 @@ findNlsPaths(rootDir).forEach(function(path) {
// Parse all inline l10n strings out of all templates and fill them into
// the fc/nls/ui bundle.
-fs.readdirSync('templates').forEach(function(filename) {
+fs.readdirSync(templateDir).forEach(function(filename) {
var InlineL10n = requirejs('inline-l10n');
var root = bundles['fc/nls/ui'].root;
var metadata = bundles['fc/nls/ui'].metadata;
- var content = fs.readFileSync('templates/' + filename, 'utf8');
+ var content = fs.readFileSync(templateDir + '/' + filename, 'utf8');
var defaultValues = InlineL10n.parse(content);
for (var key in defaultValues) {
var value = defaultValues[key];
@@ -67,4 +69,5 @@ fs.readdirSync('templates').forEach(function(filename) {
}
});
-require('sys').puts(JSON.stringify(bundles, null, 2));
+if (!module.parent)
+ require('sys').puts(JSON.stringify(bundles, null, 2));
View
1  bin/build-require.js
@@ -44,6 +44,7 @@ var generateConfig = exports.generateConfig = function() {
Object.keys(requireConfig).forEach(function(name) {
config[name] = requireConfig[name];
});
+ config.baseUrl = rootDir;
return config;
}
View
2  js/slowparse-errors/html-to-i18n.js
@@ -22,7 +22,7 @@ define(["text"], function(text) {
var template;
if (config.isBuild) {
buildMap[name] = htmlToI18nBundle(config.makeDocument(), html);
- onLoad();
+ onLoad(buildMap[name]);
} else {
onLoad(htmlToI18nBundle(document, html));
}
View
6 package.json
@@ -6,9 +6,11 @@
"main": "build-require.js",
"dependencies": {
"requirejs": "2.1.x",
- "jsdom": "0.2.19"
+ "jsdom": "0.2.19",
+ "tap": "0.3.x"
},
"scripts": {
- "start": "node build-require.js"
+ "optimize": "node bin/build-require.js",
+ "test": "tap ./test/node-tap"
}
}
View
18 test/node-tap/test-build-i18n.js
@@ -0,0 +1,18 @@
+var test = require("tap").test;
+var rootDir = require('path').resolve(__dirname, '..', '..');
+var bundles = require(rootDir + '/bin/build-i18n').bundles;
+
+test("ensure bundles contain inline-l10n strings", function(t) {
+ t.equal(bundles['fc/nls/ui'].root['Yes'], 'Yes');
+ t.end();
+});
+
+test("ensure bundles contain HTML help", function(t) {
+ t.ok('body' in bundles["fc/nls/html-element-docs"].root);
+ t.end();
+});
+
+test("ensure bundles contain slowparse errors", function(t) {
+ t.ok('UNEXPECTED_CLOSE_TAG' in bundles['slowparse-errors/nls/base'].root);
+ t.end();
+});
Please sign in to comment.
Something went wrong with that request. Please try again.