2
0
Fork 0

Upped versions and fixed lint warnings

This commit is contained in:
Willem 2015-06-28 17:44:01 +02:00
parent 7217f8617a
commit f1e8e001d9
6 changed files with 52 additions and 34 deletions

View file

@ -7,10 +7,10 @@
"start": "node example.js" "start": "node example.js"
}, },
"dependencies": { "dependencies": {
"async": "~0.9.0", "async": "1.2.x",
"bootstrap": "^3.3.2", "bootstrap": "3.3.x",
"express": "~4.11.0", "express": "4.11.x",
"flot": "^0.8.0-alpha", "flot": "0.8.x",
"ejs": "^2.3.1" "ejs": "2.3.x"
} }
} }

View file

@ -1,7 +1,7 @@
{ {
"name": "node-ff-assets", "name": "node-ff-assets",
"version": "0.2.5", "version": "0.2.5",
"description": "Site assets local/remote aggregation with minify.", "description": "Website assets aggregation and minification",
"main": "lib/node-ff-assets.js", "main": "lib/node-ff-assets.js",
"scripts": { "scripts": {
"test": "npm run-script test-clean;npm run-script test-mocha", "test": "npm run-script test-clean;npm run-script test-mocha",
@ -9,21 +9,30 @@
"test-mocha": "export JUNIT_REPORT_PATH=test/data/report.xml;export JUNIT_REPORT_STACK=1;node_modules/mocha/bin/mocha --reporter mocha-jenkins-reporter" "test-mocha": "export JUNIT_REPORT_PATH=test/data/report.xml;export JUNIT_REPORT_STACK=1;node_modules/mocha/bin/mocha --reporter mocha-jenkins-reporter"
}, },
"author": "Willem <willem.git.2015@forwardfire.net> (http://forwardfire.net/)", "author": "Willem <willem.git.2015@forwardfire.net> (http://forwardfire.net/)",
"keywords": [
"website",
"assets",
"aggregation",
"minification",
"javascript",
"css",
"minify"
],
"license": "BSD-2-Clause", "license": "BSD-2-Clause",
"repository": { "repository": {
"type": "git", "type": "git",
"url": "https://bitbucket.org/im_ik/node-ff-assets.git" "url": "https://bitbucket.org/im_ik/node-ff-assets.git"
}, },
"dependencies": { "dependencies": {
"debug": "^2.2.0", "debug": "2.2.x",
"fetch": "^0.3.6", "fetch": "0.3.x",
"fs-extra": "^0.16.3", "fs-extra": "0.20.x",
"minify": "^1.4.8", "minify": "1.4.x",
"underscore": "^1.8.2" "underscore": "1.8.x"
}, },
"devDependencies": { "devDependencies": {
"mocha": "^2.1.0", "mocha": "2.2.x",
"mocha-jenkins-reporter": "^0.1.4", "mocha-jenkins-reporter": "0.1.x",
"mocha-jshint": "0.0.9" "mocha-jshint": "2.2.x"
} }
} }

View file

@ -1,9 +1,8 @@
'use strict'; 'use strict';
var u = require('underscore');
var fs = require('fs-extra'); var fs = require('fs-extra');
var assert = require("assert"); var assert = require('assert');
var assets = require("../lib/node-ff-assets"); var assets = require('../lib/node-ff-assets');
function createTestAssembler(suite, readFile) { function createTestAssembler(suite, readFile) {
var assetAssembler = new assets.AssetAssembler({ var assetAssembler = new assets.AssetAssembler({
@ -40,7 +39,8 @@ describe('lib/asset-assembler.js', function() {
describe('config-null', function() { describe('config-null', function() {
this.timeout(10000); this.timeout(10000);
try { try {
new assets.AssetAssembler(); var result = new assets.AssetAssembler();
assert.ok(result);
assert.ok(false); assert.ok(false);
} catch (err) { } catch (err) {
assert.ok(err !== undefined); assert.ok(err !== undefined);
@ -53,6 +53,7 @@ describe('lib/asset-assembler.js', function() {
var assetAssembler = createTestAssembler(this); var assetAssembler = createTestAssembler(this);
it('run builder and check output', function (done) { it('run builder and check output', function (done) {
assetAssembler.run(function (err) { assetAssembler.run(function (err) {
assert.ok(err === undefined);
try { try {
assert.ok(true); assert.ok(true);
assert.equal(true, fs.existsSync(outputFile)); assert.equal(true, fs.existsSync(outputFile));
@ -71,13 +72,14 @@ describe('lib/asset-assembler.js', function() {
describe('aggregate-two-and-remote', function() { describe('aggregate-two-and-remote', function() {
this.timeout(10000); this.timeout(10000);
var remoteFile = 'test/data/'+this.title+'/fonts-sans-pro.css' var remoteFile = 'test/data/'+this.title+'/fonts-sans-pro.css';
var outputFile = createTestData(this); var outputFile = createTestData(this);
var assetAssembler = createTestAssembler(this); var assetAssembler = createTestAssembler(this);
assetAssembler.config.linkSources.push('/static-test/fonts-sans-pro.css@http://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700'); assetAssembler.config.linkSources.push('/static-test/fonts-sans-pro.css@http://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700');
it('run builder and check output', function (done) { it('run builder and check output', function (done) {
assetAssembler.run(function (err) { assetAssembler.run(function (err) {
assert.ok(err === undefined);
try { try {
assert.ok(true); assert.ok(true);
assert.equal(true, fs.existsSync(outputFile)); assert.equal(true, fs.existsSync(outputFile));
@ -90,7 +92,7 @@ describe('lib/asset-assembler.js', function() {
done(); done();
} catch (err) { } catch (err) {
console.log('sdf: '+Object.keys(err)); //console.log('sdf: '+Object.keys(err));
done(err); done(err);
} }
}); });
@ -106,8 +108,8 @@ describe('lib/asset-assembler.js', function() {
it('run builder and check output', function (done) { it('run builder and check output', function (done) {
assetAssembler.run(function (err) { assetAssembler.run(function (err) {
try {
assert.ok(err !== undefined); assert.ok(err !== undefined);
try {
assert.equal(true, err.message.indexOf('404') >= 0); assert.equal(true, err.message.indexOf('404') >= 0);
assert.equal(true, fs.existsSync(outputFile)); assert.equal(true, fs.existsSync(outputFile));
assert.equal(true, fs.existsSync(remoteFile)); assert.equal(true, fs.existsSync(remoteFile));
@ -131,7 +133,7 @@ describe('lib/asset-assembler.js', function() {
describe('remote-closed', function() { describe('remote-closed', function() {
this.timeout(10000); this.timeout(10000);
var remoteFile = 'test/data/'+this.title+'/font-closed.css' var remoteFile = 'test/data/'+this.title+'/font-closed.css';
var outputFile = createTestData(this); var outputFile = createTestData(this);
var assetAssembler = createTestAssembler(this); var assetAssembler = createTestAssembler(this);
assetAssembler.config.linkSources.push('/static-test/font-closed.css@http://localhost:12345/closed'); assetAssembler.config.linkSources.push('/static-test/font-closed.css@http://localhost:12345/closed');
@ -166,6 +168,7 @@ describe('lib/asset-assembler.js', function() {
var assetAssembler = createTestAssembler(this,assets.factory.assembler.constructor.readFileRegex()); var assetAssembler = createTestAssembler(this,assets.factory.assembler.constructor.readFileRegex());
it('run builder and check output', function (done) { it('run builder and check output', function (done) {
assetAssembler.run(function (err) { assetAssembler.run(function (err) {
assert.ok(err === undefined);
try { try {
assert.ok(true); assert.ok(true);
assert.equal(true, fs.existsSync(outputFile)); assert.equal(true, fs.existsSync(outputFile));
@ -194,6 +197,7 @@ describe('lib/asset-assembler.js', function() {
assetAssembler.config.assetSeperator = null; assetAssembler.config.assetSeperator = null;
it('run builder and check output', function (done) { it('run builder and check output', function (done) {
assetAssembler.run(function (err) { assetAssembler.run(function (err) {
assert.ok(err === undefined);
try { try {
assert.ok(true); assert.ok(true);
assert.equal(true, fs.existsSync(outputFile)); assert.equal(true, fs.existsSync(outputFile));

View file

@ -1,9 +1,8 @@
'use strict'; 'use strict';
var u = require('underscore');
var fs = require('fs-extra'); var fs = require('fs-extra');
var assert = require("assert"); var assert = require('assert');
var assets = require("../lib/node-ff-assets"); var assets = require('../lib/node-ff-assets');
function createTestConfig(suite,type) { function createTestConfig(suite,type) {
@ -26,13 +25,14 @@ function createTestConfig(suite,type) {
], ],
assetType: type, assetType: type,
}); });
} };
} }
function createTestBuilder(suite) { function createTestBuilder(suite) {
var testConfig = { var testConfig = {
assemblerFill: function (assembler, callback) { assemblerFill: function (assembler, callback) {
var serverResultKey = 'ff_assets_'+assembler.config.assetType; var serverResultKey = 'ff_assets_'+assembler.config.assetType;
assert.ok(serverResultKey);
assembler.on ('log',function (logMessage) { assembler.on ('log',function (logMessage) {
console.log(' ' + ' ' + suite.title + ' assembler ' +logMessage); // == -2 space from asm console.log(' ' + ' ' + suite.title + ' assembler ' +logMessage); // == -2 space from asm
}); });
@ -55,7 +55,8 @@ describe('lib/assets-builder.js', function() {
describe('config-null', function() { describe('config-null', function() {
this.timeout(10000); this.timeout(10000);
try { try {
new assets.AssetsBuilder(); var result = new assets.AssetsBuilder();
assert.ok(result);
assert.ok(false); assert.ok(false);
} catch (err) { } catch (err) {
assert.ok(err !== undefined); assert.ok(err !== undefined);

View file

@ -4,6 +4,12 @@ var u = require('underscore');
var assert = require('assert'); var assert = require('assert');
var asserts = require('../lib/node-ff-assets'); var asserts = require('../lib/node-ff-assets');
var checkResult = function(result) {
return function() {
assert.equal(true, u.isFunction(result));
};
};
var checkFunctionResult = function(node,prefixParent) { var checkFunctionResult = function(node,prefixParent) {
var nodeKeys = Object.keys(node); var nodeKeys = Object.keys(node);
for (var i = 0; i < nodeKeys.length; i++) { for (var i = 0; i < nodeKeys.length; i++) {
@ -17,15 +23,13 @@ var checkFunctionResult = function(node,prefixParent) {
} catch (err) { } catch (err) {
result = function() {}; result = function() {};
} }
it(prefix+' should return function', function() { it(prefix+' should return function', checkResult(result));
assert.equal(true, u.isFunction(result));
});
} else if (u.isObject(nodeValue)) { } else if (u.isObject(nodeValue)) {
checkFunctionResult(nodeValue,prefix); checkFunctionResult(nodeValue,prefix);
} }
} }
} };
describe('lib/factory.js', function() { describe('lib/factory.js', function() {
describe('check function paths', function() { describe('check function paths', function() {

View file

@ -1,7 +1,7 @@
'use strict'; 'use strict';
var assert = require("assert"); var assert = require('assert');
var assets = require("../lib/node-ff-assets"); var assets = require('../lib/node-ff-assets');
describe('lib/node-ff-assets.js', function() { describe('lib/node-ff-assets.js', function() {
describe('check exports', function() { describe('check exports', function() {