89 lines
2.7 KiB
JavaScript
89 lines
2.7 KiB
JavaScript
|
'use strict';
|
||
|
|
||
|
var u = require('underscore');
|
||
|
var fs = require('fs-extra');
|
||
|
var assert = require("assert");
|
||
|
var assets = require("../lib/node-ff-assets");
|
||
|
|
||
|
var testDataCss = function (testName) {
|
||
|
var outputFile = 'test/data/'+testName+'/output.css';
|
||
|
var dataCss0 = 'test/data/'+testName+'/input0.css';
|
||
|
var dataCss1 = 'test/data/'+testName+'/input1.css';
|
||
|
fs.ensureFileSync(dataCss0);
|
||
|
fs.writeFileSync(dataCss0,'');
|
||
|
fs.appendFile(dataCss0,'input__0');
|
||
|
fs.ensureFileSync(dataCss1);
|
||
|
fs.writeFileSync(dataCss1,'');
|
||
|
fs.appendFile(dataCss1,'input__1');
|
||
|
if (fs.existsSync(outputFile)) {
|
||
|
fs.writeFileSync(outputFile,'');
|
||
|
}
|
||
|
return outputFile;
|
||
|
}
|
||
|
|
||
|
var testName = '';
|
||
|
describe('lib/asset-assembler.js', function() {
|
||
|
testName = 'test-aggregate-two';
|
||
|
describe(testName, function() {
|
||
|
this.timeout(10000);
|
||
|
var outputFile = testDataCss(testName);
|
||
|
var assetAssembler = new assets.AssetAssembler({
|
||
|
linkMapping: {'/static-test/': 'test/data/'+testName+'/'},
|
||
|
linkTarget: '/static-test/output.css',
|
||
|
linkSources: [
|
||
|
'/static-test/input0.css',
|
||
|
'/static-test/input1.css',
|
||
|
],
|
||
|
});
|
||
|
it('run builder and check output', function (done) {
|
||
|
assetAssembler.run(function (err) {
|
||
|
try {
|
||
|
assert.ok(true);
|
||
|
assert.equal(true, fs.existsSync(outputFile));
|
||
|
|
||
|
var outputData = ''+fs.readFileSync(outputFile);
|
||
|
assert.equal(true, outputData.indexOf('input__0') > 0);
|
||
|
assert.equal(true, outputData.indexOf('input__1') > 0);
|
||
|
|
||
|
done();
|
||
|
} catch (err) {
|
||
|
done(err);
|
||
|
}
|
||
|
});
|
||
|
});
|
||
|
});
|
||
|
testName = 'test-aggregate-two-and-remote';
|
||
|
describe(testName, function() {
|
||
|
this.timeout(10000);
|
||
|
var outputFile = testDataCss(testName);
|
||
|
var assetAssembler = new assets.AssetAssembler({
|
||
|
linkMapping: {'/static-test/': 'test/data/'+testName+'/'},
|
||
|
linkTarget: '/static-test/output.css',
|
||
|
linkSources: [
|
||
|
'/static-test/input0.css',
|
||
|
'/static-test/input1.css',
|
||
|
'/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) {
|
||
|
assetAssembler.run(function (err) {
|
||
|
try {
|
||
|
assert.ok(true);
|
||
|
assert.equal(true, fs.existsSync(outputFile));
|
||
|
assert.equal(true, fs.existsSync('test/data/'+testName+'/fonts-sans-pro.css'));
|
||
|
|
||
|
var outputData = ''+fs.readFileSync(outputFile);
|
||
|
assert.equal(true, outputData.indexOf('input__0') > 0);
|
||
|
assert.equal(true, outputData.indexOf('input__1') > 0);
|
||
|
assert.equal(true, outputData.indexOf('Source Sans Pro') > 0);
|
||
|
|
||
|
done();
|
||
|
} catch (err) {
|
||
|
done(err);
|
||
|
}
|
||
|
});
|
||
|
});
|
||
|
});
|
||
|
});
|
||
|
|