Add some tests to make sure we're packaging up the npm properly
This commit is contained in:
+6
-3
@@ -37,10 +37,13 @@ module.exports = function(grunt) {
|
|||||||
grunt.registerTask("execSpecsInNode",
|
grunt.registerTask("execSpecsInNode",
|
||||||
"Run Jasmine core specs in Node.js",
|
"Run Jasmine core specs in Node.js",
|
||||||
function() {
|
function() {
|
||||||
var exitInfo = require("shelljs").exec("node_modules/.bin/jasmine");
|
var done = this.async();
|
||||||
if (exitInfo.code !== 0) {
|
require("shelljs").exec("node_modules/.bin/jasmine", function(exitCode) {
|
||||||
grunt.fail.fatal("Specs Failed", exitInfo.code);
|
if (exitCode !== 0) {
|
||||||
|
grunt.fail.fatal("Specs Failed", exitCode);
|
||||||
}
|
}
|
||||||
|
done();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
+1
-3
@@ -1,7 +1,6 @@
|
|||||||
module.exports = require("./jasmine-core/jasmine.js");
|
module.exports = require("./jasmine-core/jasmine.js");
|
||||||
module.exports.boot = require('./jasmine-core/node_boot.js');
|
module.exports.boot = require('./jasmine-core/node_boot.js');
|
||||||
|
|
||||||
module.exports.files = (function() {
|
|
||||||
var path = require('path'),
|
var path = require('path'),
|
||||||
fs = require('fs');
|
fs = require('fs');
|
||||||
|
|
||||||
@@ -27,7 +26,7 @@ module.exports.files = (function() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return {
|
module.exports.files = {
|
||||||
path: rootPath,
|
path: rootPath,
|
||||||
bootDir: rootPath,
|
bootDir: rootPath,
|
||||||
bootFiles: bootFiles,
|
bootFiles: bootFiles,
|
||||||
@@ -36,4 +35,3 @@ module.exports.files = (function() {
|
|||||||
jsFiles: ['jasmine.js'].concat(jsFiles),
|
jsFiles: ['jasmine.js'].concat(jsFiles),
|
||||||
imagesDir: path.join(__dirname, '../images')
|
imagesDir: path.join(__dirname, '../images')
|
||||||
};
|
};
|
||||||
}());
|
|
||||||
|
|||||||
@@ -0,0 +1,103 @@
|
|||||||
|
describe('npm package', function() {
|
||||||
|
beforeEach(function() {
|
||||||
|
var shell = require('shelljs'),
|
||||||
|
pack = shell.exec('npm pack', { silent: true });
|
||||||
|
|
||||||
|
this.tarball = pack.output.split('\n')[0];
|
||||||
|
this.tmpDir = '/tmp/jasmine-core';
|
||||||
|
|
||||||
|
var path = this.path = require('path');
|
||||||
|
var fs = this.fs = require('fs');
|
||||||
|
|
||||||
|
this.fs.mkdirSync(this.tmpDir);
|
||||||
|
|
||||||
|
var untar = shell.exec('tar -xzf ' + this.tarball + ' -C ' + this.tmpDir, { silent: true });
|
||||||
|
expect(untar.code).toBe(0);
|
||||||
|
|
||||||
|
this.packagedCore = require(this.path.join(this.tmpDir, 'package/lib/jasmine-core.js'));
|
||||||
|
|
||||||
|
jasmine.addMatchers({
|
||||||
|
toExistInPath: function(util, customEquality) {
|
||||||
|
return {
|
||||||
|
compare: function(actual, expected) {
|
||||||
|
var fullPath = path.resolve(expected, actual);
|
||||||
|
return {
|
||||||
|
pass: fs.existsSync(fullPath)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(function() {
|
||||||
|
var path = this.path, fs = this.fs;
|
||||||
|
var cleanup = function (parent, fileOrFolder) {
|
||||||
|
var fullPath = path.join(parent, fileOrFolder);
|
||||||
|
if (fs.statSync(fullPath).isFile()) {
|
||||||
|
fs.unlinkSync(fullPath);
|
||||||
|
} else {
|
||||||
|
fs.readdirSync(fullPath).forEach(cleanup.bind(null, fullPath));
|
||||||
|
fs.rmdirSync(fullPath);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
fs.unlink(this.tarball);
|
||||||
|
fs.readdirSync(this.tmpDir).forEach(cleanup.bind(null, this.tmpDir));
|
||||||
|
fs.rmdirSync(this.tmpDir);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('has a root path', function() {
|
||||||
|
expect(this.packagedCore.files.path).toEqual(this.fs.realpathSync(this.path.resolve(this.tmpDir, 'package/lib/jasmine-core')));
|
||||||
|
});
|
||||||
|
|
||||||
|
it('has a bootDir', function() {
|
||||||
|
expect(this.packagedCore.files.bootDir).toEqual(this.fs.realpathSync(this.path.resolve(this.tmpDir, 'package/lib/jasmine-core')));
|
||||||
|
});
|
||||||
|
|
||||||
|
it('has jsFiles', function() {
|
||||||
|
expect(this.packagedCore.files.jsFiles).toEqual([
|
||||||
|
'jasmine.js',
|
||||||
|
'jasmine-html.js',
|
||||||
|
'json2.js'
|
||||||
|
]);
|
||||||
|
|
||||||
|
var packagedCore = this.packagedCore;
|
||||||
|
this.packagedCore.files.jsFiles.forEach(function(fileName) {
|
||||||
|
expect(fileName).toExistInPath(packagedCore.files.path);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('has cssFiles', function() {
|
||||||
|
expect(this.packagedCore.files.cssFiles).toEqual(['jasmine.css']);
|
||||||
|
|
||||||
|
var packagedCore = this.packagedCore;
|
||||||
|
this.packagedCore.files.cssFiles.forEach(function(fileName) {
|
||||||
|
expect(fileName).toExistInPath(packagedCore.files.path);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('has bootFiles', function() {
|
||||||
|
expect(this.packagedCore.files.bootFiles).toEqual(['boot.js']);
|
||||||
|
expect(this.packagedCore.files.nodeBootFiles).toEqual(['node_boot.js']);
|
||||||
|
|
||||||
|
var packagedCore = this.packagedCore;
|
||||||
|
this.packagedCore.files.bootFiles.forEach(function(fileName) {
|
||||||
|
expect(fileName).toExistInPath(packagedCore.files.bootDir);
|
||||||
|
});
|
||||||
|
|
||||||
|
var packagedCore = this.packagedCore;
|
||||||
|
this.packagedCore.files.nodeBootFiles.forEach(function(fileName) {
|
||||||
|
expect(fileName).toExistInPath(packagedCore.files.bootDir);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('has an imagesDir', function() {
|
||||||
|
expect(this.packagedCore.files.imagesDir).toEqual(this.fs.realpathSync(this.path.resolve(this.tmpDir, 'package/images')));
|
||||||
|
var images = this.fs.readdirSync(this.path.resolve(this.tmpDir, 'package/images'));
|
||||||
|
|
||||||
|
expect(images).toContain('jasmine-horizontal.png');
|
||||||
|
expect(images).toContain('jasmine-horizontal.svg');
|
||||||
|
expect(images).toContain('jasmine_favicon.png');
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -2,7 +2,8 @@
|
|||||||
"spec_dir": "spec",
|
"spec_dir": "spec",
|
||||||
"spec_files": [
|
"spec_files": [
|
||||||
"core/**/*.js",
|
"core/**/*.js",
|
||||||
"console/**/*.js"
|
"console/**/*.js",
|
||||||
|
"npmPackage/**/*.js"
|
||||||
],
|
],
|
||||||
"helpers": [
|
"helpers": [
|
||||||
"helpers/nodeDefineJasmineUnderTest.js"
|
"helpers/nodeDefineJasmineUnderTest.js"
|
||||||
|
|||||||
Reference in New Issue
Block a user