Signed-off-by: Jeffrey Morgan <jmorganca@gmail.com>
This commit is contained in:
Jeffrey Morgan 2015-10-08 12:43:47 -04:00
Родитель f0be037ec6
Коммит 3f89d47d08
2 изменённых файлов: 0 добавлений и 85 удалений

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

@ -1,69 +0,0 @@
jest.dontMock('../src/stores/SetupStore');
var setupStore = require('../src/stores/SetupStore');
var virtualBox = require('../src/utils/VirtualBoxUtil');
var util = require('../src/utils/Util');
var machine = require('../src/utils/DockerMachineUtil');
var setupUtil = require('../src/utils/SetupUtil');
describe('SetupStore', function () {
describe('download step', function () {
util.packagejson.mockReturnValue({});
pit('downloads virtualbox if it is not installed', function () {
virtualBox.installed.mockReturnValue(false);
setupUtil.download.mockReturnValue(Promise.resolve());
virtualBox.filename.mockReturnValue('');
util.supportDir.mockReturnValue('');
return setupStore.steps().download.run().then(() => {
expect(setupUtil.download).toBeCalled();
});
});
pit('downloads virtualbox if it is installed but has an outdated version', function () {
virtualBox.installed.mockReturnValue(true);
virtualBox.version.mockReturnValue(Promise.resolve('5.0.0'));
util.compareVersions.mockReturnValue(-1);
setupUtil.download.mockReturnValue(Promise.resolve());
virtualBox.filename.mockReturnValue('');
util.supportDir.mockReturnValue('');
return setupStore.steps().download.run().then(() => {
expect(setupUtil.download).toBeCalled();
});
});
});
describe('install step', function () {
util.exec.mockReturnValue(Promise.resolve());
virtualBox.killall.mockReturnValue(Promise.resolve());
setupUtil.installVirtualBoxCmd.mockReturnValue(Promise.resolve());
setupUtil.macSudoCmd.mockImplementation(cmd => 'macsudo ' + cmd);
pit('installs virtualbox if it is not installed', function () {
virtualBox.installed.mockReturnValue(false);
util.exec.mockReturnValue(Promise.resolve());
return setupStore.steps().install.run(() => {}).then(() => {
expect(virtualBox.killall).toBeCalled();
expect(setupUtil.installVirtualBoxCmd).toBeCalled();
});
});
});
describe('init step', function () {
pit('upgrades the vm if it exists and is out of date', function () {
machine.exists.mockReturnValue(Promise.resolve(true));
machine.state.mockReturnValue(Promise.resolve('Stopped'));
machine.isoversion.mockReturnValue('1.0');
machine.stop.mockReturnValue(Promise.resolve());
machine.start.mockReturnValue(Promise.resolve());
machine.upgrade.mockReturnValue(Promise.resolve());
util.compareVersions.mockReturnValue(-1);
machine.create.mockClear();
machine.upgrade.mockClear();
machine.start.mockClear();
return setupStore.steps().init.run(() => {}).then(() => {
expect(machine.create).not.toBeCalled();
expect(machine.upgrade).toBeCalled();
expect(machine.start).toBeCalled();
});
});
});
});

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

@ -1,16 +0,0 @@
jest.dontMock('../src/utils/VirtualBoxUtil');
var virtualBox = require('../src/utils/VirtualBoxUtil');
var util = require('../src/utils/Util');
describe('VirtualBox', function () {
describe('version 5.0.0r101573', function () {
pit('correctly parses virtualbox version', function () {
util.exec.mockImplementation(function () {
return Promise.resolve('5.0.0r101573');
});
return virtualBox.version().then(function (version) {
expect(version).toBe('5.0.0');
});
});
});
});