This commit is contained in:
Jeffrey Morgan 2015-02-09 21:24:12 -08:00
Родитель 60fa865bc6
Коммит cb437f1d89
26 изменённых файлов: 143 добавлений и 4049 удалений

3
.gitignore поставляемый
Просмотреть файл

@ -14,3 +14,6 @@ resources/boot2docker*
cache
resources/settings*
# Tests
.test

Просмотреть файл

@ -23,7 +23,9 @@
"camelcase": false,
"jasmine": true,
"globals": {
"define": true
"define": true,
"jest": true,
"pit": true
},
"predef": [ "-Promise" ]
}

Просмотреть файл

@ -0,0 +1,37 @@
jest.dontMock('../src/Boot2Docker');
var boot2docker = require('../src/Boot2Docker');
var fs = require('fs');
var util = require('../src/Util');
var Promise = require('bluebird');
describe('Boot2Docker', () => {
pit('cli version is parsed correctly', function () {
util.exec.mockReturnValueOnce(Promise.resolve('Boot2Docker-cli version: v1.4.1\nGit commit: 43241cb'));
return boot2docker.cliversion().then(version => {
expect(util.exec).toBeCalledWith([boot2docker.command(), 'version']);
expect(version).toBe('1.4.1');
});
});
it('iso version parsed correctly', function () {
fs.readFileSync.mockReturnValueOnce('9adjaldijaslkjd123Boot2Docker-v1.4.1aisudhha82jj123');
expect(boot2docker.isoversion()).toBe('1.4.1');
});
pit('should exist if status command succeeds', function () {
util.exec.mockReturnValueOnce(Promise.resolve(true));
return boot2docker.exists().then(exists => {
expect(util.exec).toBeCalledWith([boot2docker.command(), 'status']);
expect(exists).toBe(true);
});
});
pit('should not exist if status command fails', function () {
util.exec.mockReturnValueOnce(Promise.reject(false));
return boot2docker.exists().then(exists => {
expect(util.exec).toBeCalledWith([boot2docker.command(), 'status']);
expect(exists).toBe(false);
});
});
});

Просмотреть файл

@ -0,0 +1,21 @@
jest.dontMock('../src/Virtualbox');
var virtualbox = require('../src/Virtualbox');
var util = require('../src/Util');
var Promise = require('bluebird');
describe('Virtualbox', function () {
it('returns the right command', function () {
expect(virtualbox.command()).toBe('/usr/bin/VBoxManage');
});
describe('version 4.3.20r96996', function () {
pit('correctly parses virtualbox version', function () {
util.exec.mockImplementation(function () {
return Promise.resolve('4.3.20r96996');
});
return virtualbox.version().then(function (version) {
expect(version).toBe('4.3.20');
});
});
});
});

Просмотреть файл

@ -28,10 +28,9 @@ var options = {
};
gulp.task('js', function () {
gulp.src('src/**/*.js')
return gulp.src('src/**/*.js')
.pipe(plumber(function(error) {
gutil.log(gutil.colors.red('Error (' + error.plugin + '): ' + error.message));
// emit the end event, to properly end the task
this.emit('end');
}))
.pipe(gulpif(options.dev || options.test, sourcemaps.init()))
@ -42,23 +41,6 @@ gulp.task('js', function () {
.pipe(gulpif(options.dev, livereload()));
});
gulp.task('tests', function () {
gulp.src('tests/*.js')
.pipe(plumber(function(error) {
gutil.log(gutil.colors.red('Error (' + error.plugin + '): ' + error.message));
// emit the end event, to properly end the task
this.emit('end');
}))
.pipe(sourcemaps.init())
.pipe(react())
.pipe(to5())
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest('./build'));
gulp.src('./tests/tests.html').pipe(gulp.dest('./build'));
gulp.src('./tests/jasmine-2.1.3/*').pipe(gulp.dest('./build/jasmine-2.1.3'));
});
gulp.task('images', function() {
return gulp.src('images/*')
.pipe(gulp.dest(options.dev ? './build' : './dist/osx/' + options.filename + '/Contents/Resources/app/build'))
@ -165,20 +147,6 @@ gulp.task('release', function () {
runSequence('download', 'dist', ['copy', 'images', 'js', 'styles'], 'sign', 'zip');
});
gulp.task('test', ['download', 'copy', 'js', 'tests'], function () {
var env = process.env;
env.NODE_ENV = 'test';
if (options.integration) {
gulp.src('').pipe(shell(['./cache/Atom.app/Contents/MacOS/Atom . --test --integration'], {
env: env
}));
} else {
gulp.src('').pipe(shell(['./cache/Atom.app/Contents/MacOS/Atom . --test'], {
env: env
}));
}
});
gulp.task('default', ['download', 'copy', 'js', 'images', 'styles'], function () {
gulp.watch('src/**/*.js', ['js']);
gulp.watch('index.html', ['copy']);

Просмотреть файл

@ -1 +0,0 @@
jsxhint src/**/* && jsxhint browser/**/*

Просмотреть файл

@ -12,13 +12,11 @@
"bugs": "https://github.com/kitematic/kitematic/issues",
"scripts": {
"start": "gulp",
"test": "gulp test",
"test:integration": "gulp test --integration",
"test:all": "npm test && npm run test:integration",
"test": "jest",
"release": "gulp release",
"release:beta": "gulp release --beta",
"preinstall": "./deps",
"lint": "jsxhint src/"
"lint": "jsxhint src/**/* && jsxhint browser/**/*"
},
"licenses": [
{
@ -27,16 +25,19 @@
}
],
"jest": {
"scriptPreprocessor": "preprocessor.js",
"unmockedModulePathPatterns": [
"dockerode",
"react",
"debug"
"node_modules/request",
"node_modules/react",
"node_modules/bluebird",
"node_modules/6to5"
]
},
"boot2docker-version": "1.4.1",
"atom-shell-version": "0.21.1",
"virtualbox-version": "4.3.20",
"virtualbox-filename": "VirtualBox-4.3.20-96996-OSX.dmg",
"virtualbox-filename": "VirtualBox-4.3.20.pkg",
"virtualbox-checksum": "89edac4cc7298c8a04fd4bb646ff2197e7673137c6566c7757f0e9cd6265d0c5",
"virtualbox-required-version": "4.3.18",
"dependencies": {
"ansi-to-html": "0.2.0",
@ -63,6 +64,9 @@
"underscore": "^1.7.0"
},
"devDependencies": {
"6to5": "^3.4.1",
"6to5-core": "^3.4.1",
"6to5-jest": "^3.0.0",
"browserify": "^6.2.0",
"ecstatic": "^0.5.8",
"glob": "^4.0.6",
@ -85,11 +89,14 @@
"gulp-uglify": "^0.3.1",
"gulp-uglifyjs": "^0.5.0",
"gulp-util": "^3.0.0",
"jest-cli": "^0.2.2",
"merge-stream": "^0.1.7",
"react-tools": "^0.12.2",
"reactify": "^0.15.2",
"regenerator": "^0.8.9",
"run-sequence": "^1.0.2",
"time-require": "^0.1.2",
"vinyl-source-stream": "^0.1.1",
"watchify": "^2.1.1",
"zombie": "^2.5.1"
"watchify": "^2.1.1"
}
}

14
preprocessor.js Normal file
Просмотреть файл

@ -0,0 +1,14 @@
var ReactTools = require('react-tools');
module.exports = {
process: function(src, filename) {
if (filename.indexOf('node_modules') === -1) {
var res = ReactTools.transform(require('6to5').transform(src).code);
if (filename.indexOf('-test') !== -1) {
res = 'require(\'6to5/polyfill\');' + res;
}
return res;
}
return src;
}
};

Просмотреть файл

@ -2,12 +2,19 @@ var _ = require('underscore');
var path = require('path');
var Promise = require('bluebird');
var _ = require('underscore');
var fs = Promise.promisifyAll(require('fs'));
var fs = require('fs');
var util = require('./Util');
var Boot2Docker = {
command: function () {
return path.join(process.cwd(), 'resources', 'boot2docker-' + this.version());
},
version: function () {
return JSON.parse(fs.readFileSync(path.join(__dirname, '..', 'package.json'), 'utf8'))['boot2docker-version'];
try {
return JSON.parse(fs.readFileSync(path.join(__dirname, '..', 'package.json'), 'utf8'))['boot2docker-version'];
} catch (err) {
return null;
}
},
cliversion: function () {
return util.exec([Boot2Docker.command(), 'version']).then(stdout => {
@ -22,17 +29,17 @@ var Boot2Docker = {
});
},
isoversion: function () {
return fs.readFileAsync(path.join(util.home(), '.boot2docker', 'boot2docker.iso'), 'utf8').then(data => {
try {
var data = fs.readFileSync(path.join(util.home(), '.boot2docker', 'boot2docker.iso'), 'utf8');
var match = data.match(/Boot2Docker-v(\d+\.\d+\.\d+)/);
if (match) {
return Promise.resolve(match[1]);
return match[1];
} else {
return Promise.resolve(null);
return null;
}
});
},
command: function () {
return path.join(process.cwd(), 'resources', 'boot2docker-' + this.version());
} catch (err) {
return null;
}
},
exists: function () {
return util.exec([Boot2Docker.command(), 'status']).then(() => {

Просмотреть файл

@ -16,9 +16,10 @@ var ContainerHome = require('./ContainerHome.react');
var RetinaImage = require('react-retina-image');
var Radial = require('./Radial.react');
var _oldHeight = 0;
var ContainerDetails = React.createClass({
mixins: [Router.State, Router.Navigation],
_oldHeight: 0,
PAGE_HOME: 'home',
PAGE_LOGS: 'logs',
PAGE_SETTINGS: 'settings',
@ -31,8 +32,8 @@ var ContainerDetails = React.createClass({
env: {},
pendingEnv: {},
ports: {},
defaultPort: null,
volumes: {}
volumes: {},
defaultPort: null
};
},
componentWillReceiveProps: function () {
@ -51,11 +52,11 @@ var ContainerDetails = React.createClass({
// Scroll logs to bottom
var parent = $('.details-logs');
if (parent.length) {
if (parent.scrollTop() >= this._oldHeight) {
if (parent.scrollTop() >= _oldHeight) {
parent.stop();
parent.scrollTop(parent[0].scrollHeight - parent.height());
}
this._oldHeight = parent[0].scrollHeight - parent.height();
_oldHeight = parent[0].scrollHeight - parent.height();
}
},
init: function () {

Просмотреть файл

@ -13,8 +13,8 @@ var _percent = 0;
var _currentStep = null;
var _error = null;
var VIRTUALBOX_FILE = `http://download.virtualbox.org/virtualbox/${packagejson['virtualbox-version']}/${packagejson['virtualbox-filename']}`;
var SUDO_PROMPT = 'Kitematic requires administrative privileges to install VirtualBox and copy itself to the Applications folder.';
var VIRTUALBOX_FILE = `https://github.com/kitematic/virtualbox/releases/download/${packagejson['virtualbox-version']}/${packagejson['virtualbox-filename']}`;
var SUDO_PROMPT = 'Kitematic requires administrative privileges to install VirtualBox.';
var SetupStore = assign(EventEmitter.prototype, {
PROGRESS_EVENT: 'setup_progress',
@ -27,8 +27,7 @@ var SetupStore = assign(EventEmitter.prototype, {
return;
}
}
var checksum = yield setupUtil.virtualboxSHA256(packagejson['virtualbox-version'], packagejson['virtualbox-filename']);
yield setupUtil.download(VIRTUALBOX_FILE, path.join(setupUtil.supportDir(), packagejson['virtualbox-filename']), checksum, percent => {
yield setupUtil.download(VIRTUALBOX_FILE, path.join(setupUtil.supportDir(), packagejson['virtualbox-filename']), packagejson.checksum, percent => {
_percent = percent;
SetupStore.emit(SetupStore.PROGRESS_EVENT);
});
@ -39,15 +38,13 @@ var SetupStore = assign(EventEmitter.prototype, {
if (setupUtil.compareVersions(version, packagejson['virtualbox-required-version']) >= 0) {
return;
}
yield virtualbox.kill();
yield virtualbox.killall();
}
yield util.exec(['hdiutil', 'attach', path.join(setupUtil.supportDir(), packagejson['virtualbox-filename'])]);
var isSudo = yield setupUtil.isSudo();
var iconPath = path.join(setupUtil.resourceDir(), 'kitematic.icns');
var sudoCmd = isSudo ? ['sudo'] : [path.join(setupUtil.resourceDir(), 'cocoasudo'), '--icon=' + iconPath, `--prompt=${SUDO_PROMPT}`];
sudoCmd.push.apply(sudoCmd, ['installer', '-pkg', '/Volumes/VirtualBox/VirtualBox.pkg', '-target', '/']);
sudoCmd.push.apply(sudoCmd, ['installer', '-pkg', path.join(setupUtil.supportDir(), packagejson['virtualbox-filename']), '-target', '/']);
yield util.exec(sudoCmd);
yield util.exec(['hdiutil', 'detach', '/Volumes/VirtualBox']);
}),
cleanupKitematicStep: function () {
return virtualbox.vmdestroy('kitematic-vm');
@ -60,10 +57,10 @@ var SetupStore = assign(EventEmitter.prototype, {
}
if (!boot2docker.haskeys()) {
throw new Error('Boot2Docker SSH key doesn\'t exist. Fix by removing the existing Boot2Docker VM and re-run the installer. This usually occurs because an old version of Boot2Docker is installed.');
throw new Error('Boot2Docker SSH keys do not exist. Fix this by removing the existing Boot2Docker VM setup and re-run the installer. This usually occurs because an old version of Boot2Docker is installed.');
}
var isoversion = yield boot2docker.isoversion();
var isoversion = boot2docker.isoversion();
if (!isoversion || setupUtil.compareVersions(isoversion, boot2docker.version()) < 0) {
yield boot2docker.stop();
yield boot2docker.upgrade();
@ -116,6 +113,7 @@ var SetupStore = assign(EventEmitter.prototype, {
try {
yield step.run();
} catch (err) {
console.log(err);
_error = err;
this.emit(this.ERROR_EVENT);
throw err;

Просмотреть файл

@ -4,7 +4,6 @@ var path = require('path');
var crypto = require('crypto');
var fs = require('fs');
var exec = require('exec');
var rp = require('request-promise');
var Promise = require('bluebird');
var SetupUtil = {
@ -44,7 +43,9 @@ var SetupUtil = {
}
progress(request({ uri: url, rejectUnauthorized: false }), { throttle: 250 }).on('progress', state => {
percentCallback(state.percent);
if (percentCallback) {
percentCallback(state.percent);
}
}).on('error', err => {
reject(err);
}).pipe(fs.createWriteStream(filename)).on('error', err => {
@ -57,17 +58,6 @@ var SetupUtil = {
});
});
},
virtualboxSHA256: function (version, filename) {
return rp(`http://dlc-cdn.sun.com/virtualbox/${version}/SHA256SUMS`).then((body) => {
var checksums = body.split('\n').map(line => {
return line.split(' *');
}).reduce((obj, pair) => {
obj[pair[1]] = pair[0];
return obj;
}, {});
return Promise.resolve(checksums[filename]);
});
},
compareVersions: function (v1, v2, options) {
var lexicographical = options && options.lexicographical,
zeroExtend = options && options.zeroExtend,

Просмотреть файл

@ -7,12 +7,9 @@ var VirtualBox = {
return '/usr/bin/VBoxManage';
},
installed: function () {
return fs.existsSync('/usr/bin/VBoxManage') && fs.existsSync('/Applications/VirtualBox.app/Contents/MacOS/VirtualBox');
return fs.existsSync('/usr/bin/VBoxManage') && fs.existsSync('/Applications/VirtualBox.app');
},
version: function () {
if (!this.installed()) {
return Promise.reject('VirtualBox not installed.');
}
return new Promise((resolve, reject) => {
util.exec([this.command(), '-v']).then(stdout => {
var match = stdout.match(/(\d+\.\d+\.\d+).*/);
@ -29,7 +26,7 @@ var VirtualBox = {
}
return util.exec(this.command() + ' list runningvms | sed -E \'s/.*\\{(.*)\\}/\\1/\' | xargs -L1 -I {} ' + this.command() + ' controlvm {} poweroff');
},
kill: function () {
killall: function () {
if (!this.installed()) {
return Promise.reject('VirtualBox not installed.');
}
@ -51,16 +48,18 @@ var VirtualBox = {
});
},
vmdestroy: function (name) {
if (!this.installed()) {
throw Promise.reject('VirtualBox not installed.');
}
return util.exec([this.command(), 'controlvm', name, 'poweroff']).then(() => {
return util.exec([this.command(), 'unregistervm', name, '--delete']).then(() => {
return true;
});
}).catch(() => {
return false;
});
return Promise.coroutine(function* () {
if (!this.installed()) {
return Promise.reject('VirtualBox not installed.');
}
try {
var state = yield this.vmstate(name);
if (state === 'running') {
yield util.exec([this.command(), 'controlvm', name, 'poweroff']);
}
yield util.exec([this.command(), 'unregistervm', name, '--delete']);
} catch (err) {}
}.bind(this))();
}
};

Просмотреть файл

@ -1,57 +0,0 @@
var boot2docker = require('../build/Boot2Docker');
var path = require('path');
var fs = require('fs');
var packagejson = JSON.parse(fs.readFileSync(path.join(__dirname, '..', 'package.json'), 'utf8'));
describe('Boot2Docker', () => {
it('cli version is correct', done => {
boot2docker.cliversion().then(version => {
expect(version).toBe(packagejson['boot2docker-version']);
done();
});
});
describe('with an existing & running boot2docker vm', () => {
beforeAll(done => {
boot2docker.init().then(boot2docker.start).then(() => {
done();
});
});
it('creates a vm', done => {
boot2docker.exists().then(exists => {
expect(exists).toBe(true);
done();
});
});
it('detects the correct state of running vm', done => {
boot2docker.status().then(status => {
expect(status).toBe('running');
done();
});
});
it('detects ssh keys', () => {
expect(boot2docker.haskeys()).toBe(true);
});
it('receives an ip address from the vm', done => {
boot2docker.ip().then(ip => {
expect(ip).toMatch(/\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b/);
done();
});
});
it('reads a version from the boot2docker iso file', done => {
boot2docker.isoversion().then(version => {
expect(version).toMatch(/\d+\.\d+\.\d+/);
done();
});
});
afterAll(done => {
boot2docker.destroy().finally(done);
});
});
});

Просмотреть файл

@ -1,91 +0,0 @@
var virtualbox = require('../build/Virtualbox');
var SetupStore = require('../build/SetupStore');
var setupUtil = require('../build/SetupUtil');
var path = require('path');
var fs = require('fs');
var Promise = require('bluebird');
var packagejson = JSON.parse(fs.readFileSync(path.join(__dirname, '..', 'package.json'), 'utf8'));
jasmine.DEFAULT_TIMEOUT_INTERVAL = 300000; // 5 minutes for integration tests
describe('Setup', function () {
describe('with virtualbox installed', function () {
// Before each teardown the boot2docker VM, keys and anything else
describe('and with a kitematic vm', function () {
});
describe('and without a boot2docker vm', function () {
});
describe('and with an old boot2docker vm', function () {
});
describe('and with a very old boot2docker vm', function () {
});
describe('and with a boot2docker vm running', function () {
});
describe('and with a boot2docker vm but with no ssh keys', function () {
});
describe('and with a boot2docker vm being powered off', function () {
});
describe('and with a boot2docker vm being removed', function () {
});
describe('and with a boot2docker vm initialized but not running', function () {
});
});
/*describe('with virtualbox downloaded', function () {
beforeEach(function (done) {
Promise.coroutine(SetupStore.downloadVirtualboxStep)().finally(function () {
if (virtualbox.installed()) {
virtualbox.kill().finally(function () {
done();
});
} else {
done();
}
});
});
it('install virtualbox succeeds', function (done) {
Promise.coroutine(SetupStore.installVirtualboxStep)().finally(function () {
expect(virtualbox.installed()).toBe(true);
done();
});
});
});*/
/*describe('without virtualbox installed or downloaded', function () {
var virtualboxFile = path.join(setupUtil.supportDir(), packagejson['virtualbox-filename']);
beforeEach(function () {
if (fs.existsSync(virtualboxFile)) {
fs.unlinkSync(virtualboxFile);
}
spyOn(virtualbox, 'installed').and.returnValue(false);
});
it('downloads virtualbox from the official website', function (done) {
Promise.coroutine(SetupStore.downloadVirtualboxStep)().finally(function () {
expect(fs.existsSync(virtualboxFile)).toBe(true);
done();
});
});
});*/
});

Просмотреть файл

@ -1,10 +0,0 @@
var setupUtil = require('../build/SetupUtil');
describe('SetupUtils', function() {
it('returns live sha256 checksum for a given virtualbox version & filename', function (done) {
setupUtil.virtualboxSHA256('4.3.20', 'VirtualBox-4.3.20-96996-OSX.dmg').then(function (checksum) {
expect(checksum).toBe('744e77119a640a5974160213c9912568a3d88dbd06a2fc6b6970070941732705');
done();
});
});
});

Просмотреть файл

@ -1,56 +0,0 @@
var virtualbox = require('../build/Virtualbox');
var util = require('../build/Util');
describe('Virtualbox', function () {
beforeAll(function () {
// Make sure VirtualBox is installed
});
describe('with a running VM', function () {
beforeEach(function (done) {
return util.exec([virtualbox.command(), 'createvm', '--name', 'km-test', '--register']).finally(function () {
return util.exec([virtualbox.command(), 'startvm', 'km-test', '--type', 'headless']);
}).then(function() {
done();
}).catch(function () {
done();
});
});
it('powers off all vms', function (done) {
virtualbox.poweroffall().then(function () {
return virtualbox.vmstate('km-test');
}).then(function (state) {
expect(state).toBe('poweroff');
done();
}).catch(function (err) {
expect(err).toBeFalsy();
done();
});
});
it('destroys a vm', function (done) {
virtualbox.vmdestroy('km-test').then(function () {
return util.exec([virtualbox.command(), 'showvminfo', 'km-test']).then(function () {
done();
}).catch(function (err) {
expect(err).toBeTruthy();
done();
});
}).catch(function (err) {
console.log(err);
done();
});
});
afterEach(function (done) {
util.exec([virtualbox.command(), 'controlvm', 'km-test', 'poweroff']).finally(function () {
return util.exec([virtualbox.command(), 'unregistervm', 'km-test', '--delete']);
}).then(function () {
done();
}).catch(function () {
done();
});
});
});
});

Просмотреть файл

@ -1,21 +0,0 @@
var virtualbox = require('../build/Virtualbox');
var util = require('../build/Util');
var Promise = require('bluebird');
describe('Virtualbox', function () {
it('returns the right command', function () {
expect(virtualbox.command()).toBe('/usr/bin/VBoxManage');
});
describe('version 4.3.20r96996', function () {
beforeEach(function () {
spyOn(util, 'exec').and.returnValue(Promise.resolve('4.3.20r96996'));
});
it('correctly parses virtualbox version', function (done) {
virtualbox.version().then(function (version) {
expect(version).toBe('4.3.20');
done();
});
});
});
});

Просмотреть файл

@ -1,120 +0,0 @@
/**
Starting with version 2.0, this file "boots" Jasmine, performing all of the necessary initialization before executing the loaded environment and all of a project's specs. This file should be loaded after `jasmine.js` and `jasmine_html.js`, but before any project source files or spec files are loaded. Thus this file can also be used to customize Jasmine for a project.
If a project is using Jasmine via the standalone distribution, this file can be customized directly. If a project is using Jasmine via the [Ruby gem][jasmine-gem], this file can be copied into the support directory via `jasmine copy_boot_js`. Other environments (e.g., Python) will have different mechanisms.
The location of `boot.js` can be specified and/or overridden in `jasmine.yml`.
[jasmine-gem]: http://github.com/pivotal/jasmine-gem
*/
(function() {
/**
* ## Require &amp; Instantiate
*
* Require Jasmine's core files. Specifically, this requires and attaches all of Jasmine's code to the `jasmine` reference.
*/
window.jasmine = jasmineRequire.core(jasmineRequire);
/**
* Since this is being run in a browser and the results should populate to an HTML page, require the HTML-specific Jasmine code, injecting the same reference.
*/
jasmineRequire.html(jasmine);
/**
* Create the Jasmine environment. This is used to run all specs in a project.
*/
var env = jasmine.getEnv();
/**
* ## The Global Interface
*
* Build up the functions that will be exposed as the Jasmine public interface. A project can customize, rename or alias any of these functions as desired, provided the implementation remains unchanged.
*/
var jasmineInterface = jasmineRequire.interface(jasmine, env);
/**
* Add all of the Jasmine global/public interface to the proper global, so a project can use the public interface directly. For example, calling `describe` in specs instead of `jasmine.getEnv().describe`.
*/
if (typeof window == "undefined" && typeof exports == "object") {
extend(exports, jasmineInterface);
} else {
extend(window, jasmineInterface);
}
/**
* ## Runner Parameters
*
* More browser specific code - wrap the query string in an object and to allow for getting/setting parameters from the runner user interface.
*/
var queryString = new jasmine.QueryString({
getWindowLocation: function() { return window.location; }
});
var catchingExceptions = queryString.getParam("catch");
env.catchExceptions(typeof catchingExceptions === "undefined" ? true : catchingExceptions);
/**
* ## Reporters
* The `HtmlReporter` builds all of the HTML UI for the runner page. This reporter paints the dots, stars, and x's for specs, as well as all spec names and all failures (if any).
*/
var htmlReporter = new jasmine.HtmlReporter({
env: env,
onRaiseExceptionsClick: function() { queryString.setParam("catch", !env.catchingExceptions()); },
getContainer: function() { return document.body; },
createElement: function() { return document.createElement.apply(document, arguments); },
createTextNode: function() { return document.createTextNode.apply(document, arguments); },
timer: new jasmine.Timer()
});
/**
* The `jsApiReporter` also receives spec results, and is used by any environment that needs to extract the results from JavaScript.
*/
env.addReporter(jasmineInterface.jsApiReporter);
env.addReporter(htmlReporter);
/**
* Filter which specs will be run by matching the start of the full name against the `spec` query param.
*/
var specFilter = new jasmine.HtmlSpecFilter({
filterString: function() { return queryString.getParam("spec"); }
});
env.specFilter = function(spec) {
return specFilter.matches(spec.getFullName());
};
/**
* Setting up timing functions to be able to be overridden. Certain browsers (Safari, IE 8, phantomjs) require this hack.
*/
window.setTimeout = window.setTimeout;
window.setInterval = window.setInterval;
window.clearTimeout = window.clearTimeout;
window.clearInterval = window.clearInterval;
/**
* ## Execution
*
* Replace the browser window's `onload`, ensure it's called, and then run all of the loaded specs. This includes initializing the `HtmlReporter` instance and then executing the loaded Jasmine environment. All of this will happen after all of the specs are loaded.
*/
var currentWindowOnload = window.onload;
window.onload = function() {
if (currentWindowOnload) {
currentWindowOnload();
}
htmlReporter.initialize();
env.execute();
};
/**
* Helper function for readability above.
*/
function extend(destination, source) {
for (var property in source) destination[property] = source[property];
return destination;
}
}());

Просмотреть файл

@ -1,188 +0,0 @@
/*
Copyright (c) 2008-2014 Pivotal Labs
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
function getJasmineRequireObj() {
if (typeof module !== 'undefined' && module.exports) {
return exports;
} else {
window.jasmineRequire = window.jasmineRequire || {};
return window.jasmineRequire;
}
}
getJasmineRequireObj().console = function(jRequire, j$) {
j$.ConsoleReporter = jRequire.ConsoleReporter();
};
getJasmineRequireObj().ConsoleReporter = function() {
var noopTimer = {
start: function(){},
elapsed: function(){ return 0; }
};
function ConsoleReporter(options) {
var print = options.print,
showColors = options.showColors || false,
onComplete = options.onComplete || function() {},
timer = options.timer || noopTimer,
specCount,
failureCount,
failedSpecs = [],
pendingCount,
ansi = {
green: '\x1B[32m',
red: '\x1B[31m',
yellow: '\x1B[33m',
none: '\x1B[0m'
},
failedSuites = [];
this.jasmineStarted = function() {
specCount = 0;
failureCount = 0;
pendingCount = 0;
print('Started');
printNewline();
timer.start();
};
this.jasmineDone = function() {
printNewline();
for (var i = 0; i < failedSpecs.length; i++) {
specFailureDetails(failedSpecs[i]);
}
if(specCount > 0) {
printNewline();
var specCounts = specCount + ' ' + plural('spec', specCount) + ', ' +
failureCount + ' ' + plural('failure', failureCount);
if (pendingCount) {
specCounts += ', ' + pendingCount + ' pending ' + plural('spec', pendingCount);
}
print(specCounts);
} else {
print('No specs found');
}
printNewline();
var seconds = timer.elapsed() / 1000;
print('Finished in ' + seconds + ' ' + plural('second', seconds));
printNewline();
for(i = 0; i < failedSuites.length; i++) {
suiteFailureDetails(failedSuites[i]);
}
onComplete(failureCount === 0);
};
this.specDone = function(result) {
specCount++;
if (result.status == 'pending') {
pendingCount++;
print(colored('yellow', '*'));
return;
}
if (result.status == 'passed') {
print(colored('green', '.'));
return;
}
if (result.status == 'failed') {
failureCount++;
failedSpecs.push(result);
print(colored('red', 'F'));
}
};
this.suiteDone = function(result) {
if (result.failedExpectations && result.failedExpectations.length > 0) {
failureCount++;
failedSuites.push(result);
}
};
return this;
function printNewline() {
print('\n');
}
function colored(color, str) {
return showColors ? (ansi[color] + str + ansi.none) : str;
}
function plural(str, count) {
return count == 1 ? str : str + 's';
}
function repeat(thing, times) {
var arr = [];
for (var i = 0; i < times; i++) {
arr.push(thing);
}
return arr;
}
function indent(str, spaces) {
var lines = (str || '').split('\n');
var newArr = [];
for (var i = 0; i < lines.length; i++) {
newArr.push(repeat(' ', spaces).join('') + lines[i]);
}
return newArr.join('\n');
}
function specFailureDetails(result) {
printNewline();
print(result.fullName);
for (var i = 0; i < result.failedExpectations.length; i++) {
var failedExpectation = result.failedExpectations[i];
printNewline();
print(indent(failedExpectation.message, 2));
print(indent(failedExpectation.stack, 2));
}
printNewline();
}
function suiteFailureDetails(result) {
for (var i = 0; i < result.failedExpectations.length; i++) {
printNewline();
print(colored('red', 'An error was thrown in an afterAll'));
printNewline();
print(colored('red', 'AfterAll ' + result.failedExpectations[i].message));
}
printNewline();
}
}
return ConsoleReporter;
};

Просмотреть файл

@ -1,404 +0,0 @@
/*
Copyright (c) 2008-2014 Pivotal Labs
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
jasmineRequire.html = function(j$) {
j$.ResultsNode = jasmineRequire.ResultsNode();
j$.HtmlReporter = jasmineRequire.HtmlReporter(j$);
j$.QueryString = jasmineRequire.QueryString();
j$.HtmlSpecFilter = jasmineRequire.HtmlSpecFilter();
};
jasmineRequire.HtmlReporter = function(j$) {
var noopTimer = {
start: function() {},
elapsed: function() { return 0; }
};
function HtmlReporter(options) {
var env = options.env || {},
getContainer = options.getContainer,
createElement = options.createElement,
createTextNode = options.createTextNode,
onRaiseExceptionsClick = options.onRaiseExceptionsClick || function() {},
timer = options.timer || noopTimer,
results = [],
specsExecuted = 0,
failureCount = 0,
pendingSpecCount = 0,
htmlReporterMain,
symbols,
failedSuites = [];
this.initialize = function() {
clearPrior();
htmlReporterMain = createDom('div', {className: 'jasmine_html-reporter'},
createDom('div', {className: 'banner'},
createDom('a', {className: 'title', href: 'http://jasmine.github.io/', target: '_blank'}),
createDom('span', {className: 'version'}, j$.version)
),
createDom('ul', {className: 'symbol-summary'}),
createDom('div', {className: 'alert'}),
createDom('div', {className: 'results'},
createDom('div', {className: 'failures'})
)
);
getContainer().appendChild(htmlReporterMain);
symbols = find('.symbol-summary');
};
var totalSpecsDefined;
this.jasmineStarted = function(options) {
totalSpecsDefined = options.totalSpecsDefined || 0;
timer.start();
};
var summary = createDom('div', {className: 'summary'});
var topResults = new j$.ResultsNode({}, '', null),
currentParent = topResults;
this.suiteStarted = function(result) {
currentParent.addChild(result, 'suite');
currentParent = currentParent.last();
};
this.suiteDone = function(result) {
if (result.status == 'failed') {
failedSuites.push(result);
}
if (currentParent == topResults) {
return;
}
currentParent = currentParent.parent;
};
this.specStarted = function(result) {
currentParent.addChild(result, 'spec');
};
var failures = [];
this.specDone = function(result) {
if(noExpectations(result) && typeof console !== 'undefined' && typeof console.error !== 'undefined') {
console.error('Spec \'' + result.fullName + '\' has no expectations.');
}
if (result.status != 'disabled') {
specsExecuted++;
}
symbols.appendChild(createDom('li', {
className: noExpectations(result) ? 'empty' : result.status,
id: 'spec_' + result.id,
title: result.fullName
}
));
if (result.status == 'failed') {
failureCount++;
var failure =
createDom('div', {className: 'spec-detail failed'},
createDom('div', {className: 'description'},
createDom('a', {title: result.fullName, href: specHref(result)}, result.fullName)
),
createDom('div', {className: 'messages'})
);
var messages = failure.childNodes[1];
for (var i = 0; i < result.failedExpectations.length; i++) {
var expectation = result.failedExpectations[i];
messages.appendChild(createDom('div', {className: 'result-message'}, expectation.message));
messages.appendChild(createDom('div', {className: 'stack-trace'}, expectation.stack));
}
failures.push(failure);
}
if (result.status == 'pending') {
pendingSpecCount++;
}
};
this.jasmineDone = function() {
var banner = find('.banner');
banner.appendChild(createDom('span', {className: 'duration'}, 'finished in ' + timer.elapsed() / 1000 + 's'));
var alert = find('.alert');
alert.appendChild(createDom('span', { className: 'exceptions' },
createDom('label', { className: 'label', 'for': 'raise-exceptions' }, 'raise exceptions'),
createDom('input', {
className: 'raise',
id: 'raise-exceptions',
type: 'checkbox'
})
));
var checkbox = find('#raise-exceptions');
checkbox.checked = !env.catchingExceptions();
checkbox.onclick = onRaiseExceptionsClick;
if (specsExecuted < totalSpecsDefined) {
var skippedMessage = 'Ran ' + specsExecuted + ' of ' + totalSpecsDefined + ' specs - run all';
alert.appendChild(
createDom('span', {className: 'bar skipped'},
createDom('a', {href: '?', title: 'Run all specs'}, skippedMessage)
)
);
}
var statusBarMessage = '';
var statusBarClassName = 'bar ';
if (totalSpecsDefined > 0) {
statusBarMessage += pluralize('spec', specsExecuted) + ', ' + pluralize('failure', failureCount);
if (pendingSpecCount) { statusBarMessage += ', ' + pluralize('pending spec', pendingSpecCount); }
statusBarClassName += (failureCount > 0) ? 'failed' : 'passed';
} else {
statusBarClassName += 'skipped';
statusBarMessage += 'No specs found';
}
alert.appendChild(createDom('span', {className: statusBarClassName}, statusBarMessage));
for(i = 0; i < failedSuites.length; i++) {
var failedSuite = failedSuites[i];
for(var j = 0; j < failedSuite.failedExpectations.length; j++) {
var errorBarMessage = 'AfterAll ' + failedSuite.failedExpectations[j].message;
var errorBarClassName = 'bar errored';
alert.appendChild(createDom('span', {className: errorBarClassName}, errorBarMessage));
}
}
var results = find('.results');
results.appendChild(summary);
summaryList(topResults, summary);
function summaryList(resultsTree, domParent) {
var specListNode;
for (var i = 0; i < resultsTree.children.length; i++) {
var resultNode = resultsTree.children[i];
if (resultNode.type == 'suite') {
var suiteListNode = createDom('ul', {className: 'suite', id: 'suite-' + resultNode.result.id},
createDom('li', {className: 'suite-detail'},
createDom('a', {href: specHref(resultNode.result)}, resultNode.result.description)
)
);
summaryList(resultNode, suiteListNode);
domParent.appendChild(suiteListNode);
}
if (resultNode.type == 'spec') {
if (domParent.getAttribute('class') != 'specs') {
specListNode = createDom('ul', {className: 'specs'});
domParent.appendChild(specListNode);
}
var specDescription = resultNode.result.description;
if(noExpectations(resultNode.result)) {
specDescription = 'SPEC HAS NO EXPECTATIONS ' + specDescription;
}
specListNode.appendChild(
createDom('li', {
className: resultNode.result.status,
id: 'spec-' + resultNode.result.id
},
createDom('a', {href: specHref(resultNode.result)}, specDescription)
)
);
}
}
}
if (failures.length) {
alert.appendChild(
createDom('span', {className: 'menu bar spec-list'},
createDom('span', {}, 'Spec List | '),
createDom('a', {className: 'failures-menu', href: '#'}, 'Failures')));
alert.appendChild(
createDom('span', {className: 'menu bar failure-list'},
createDom('a', {className: 'spec-list-menu', href: '#'}, 'Spec List'),
createDom('span', {}, ' | Failures ')));
find('.failures-menu').onclick = function() {
setMenuModeTo('failure-list');
};
find('.spec-list-menu').onclick = function() {
setMenuModeTo('spec-list');
};
setMenuModeTo('failure-list');
var failureNode = find('.failures');
for (var i = 0; i < failures.length; i++) {
failureNode.appendChild(failures[i]);
}
}
};
return this;
function find(selector) {
return getContainer().querySelector('.jasmine_html-reporter ' + selector);
}
function clearPrior() {
// return the reporter
var oldReporter = find('');
if(oldReporter) {
getContainer().removeChild(oldReporter);
}
}
function createDom(type, attrs, childrenVarArgs) {
var el = createElement(type);
for (var i = 2; i < arguments.length; i++) {
var child = arguments[i];
if (typeof child === 'string') {
el.appendChild(createTextNode(child));
} else {
if (child) {
el.appendChild(child);
}
}
}
for (var attr in attrs) {
if (attr == 'className') {
el[attr] = attrs[attr];
} else {
el.setAttribute(attr, attrs[attr]);
}
}
return el;
}
function pluralize(singular, count) {
var word = (count == 1 ? singular : singular + 's');
return '' + count + ' ' + word;
}
function specHref(result) {
return '?spec=' + encodeURIComponent(result.fullName);
}
function setMenuModeTo(mode) {
htmlReporterMain.setAttribute('class', 'jasmine_html-reporter ' + mode);
}
function noExpectations(result) {
return (result.failedExpectations.length + result.passedExpectations.length) === 0 &&
result.status === 'passed';
}
}
return HtmlReporter;
};
jasmineRequire.HtmlSpecFilter = function() {
function HtmlSpecFilter(options) {
var filterString = options && options.filterString() && options.filterString().replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&');
var filterPattern = new RegExp(filterString);
this.matches = function(specName) {
return filterPattern.test(specName);
};
}
return HtmlSpecFilter;
};
jasmineRequire.ResultsNode = function() {
function ResultsNode(result, type, parent) {
this.result = result;
this.type = type;
this.parent = parent;
this.children = [];
this.addChild = function(result, type) {
this.children.push(new ResultsNode(result, type, this));
};
this.last = function() {
return this.children[this.children.length - 1];
};
}
return ResultsNode;
};
jasmineRequire.QueryString = function() {
function QueryString(options) {
this.setParam = function(key, value) {
var paramMap = queryStringToParamMap();
paramMap[key] = value;
options.getWindowLocation().search = toQueryString(paramMap);
};
this.getParam = function(key) {
return queryStringToParamMap()[key];
};
return this;
function toQueryString(paramMap) {
var qStrPairs = [];
for (var prop in paramMap) {
qStrPairs.push(encodeURIComponent(prop) + '=' + encodeURIComponent(paramMap[prop]));
}
return '?' + qStrPairs.join('&');
}
function queryStringToParamMap() {
var paramStr = options.getWindowLocation().search.substring(1),
params = [],
paramMap = {};
if (paramStr.length > 0) {
params = paramStr.split('&');
for (var i = 0; i < params.length; i++) {
var p = params[i].split('=');
var value = decodeURIComponent(p[1]);
if (value === 'true' || value === 'false') {
value = JSON.parse(value);
}
paramMap[decodeURIComponent(p[0])] = value;
}
}
return paramMap;
}
}
return QueryString;
};

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Двоичные данные
tests/jasmine-2.1.3/jasmine_favicon.png

Двоичный файл не отображается.

До

Ширина:  |  Высота:  |  Размер: 1.5 KiB

Просмотреть файл

@ -1,9 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="jasmine-2.1.3/jasmine.css"/>
</head>
<body>
<script src="tests.js"></script>
</body>
</html>

Просмотреть файл

@ -1,26 +0,0 @@
window.jasmineRequire = require('./jasmine-2.1.3/jasmine');
require('./jasmine-2.1.3/jasmine-html');
require('./jasmine-2.1.3/boot');
var consoleReporter = require('./jasmine-2.1.3/console');
var app = require('remote').require('app');
jasmine.getEnv().addReporter(new consoleReporter.ConsoleReporter()({
showColors: true,
timer: new jasmine.Timer(),
verbose: true,
print: function() {
process.stdout.write.apply(process.stdout, arguments);
},
onComplete: function () {
app.quit();
}
}));
var fs = require('fs');
var tests = fs.readdirSync('./tests').filter(function (f) {
return f.indexOf('-' + process.env.TEST_TYPE) !== -1;
});
tests.forEach(function (t) {
require('./' + t);
});