Commit 10ed3951 authored by Benjamin Bouvier's avatar Benjamin Bouvier
Browse files

Simplify tests;

parent 7d2875c8
import should from 'should';
import semver from 'semver';
import { get } from '../client/store';
import { MIN_WEBOOB_VERSION } from '../client/helpers';
import { normalizeVersion } from '../client/helpers';
import semver from 'semver';
import { MIN_WEBOOB_VERSION, normalizeVersion } from '../client/helpers';
function makeState(installed, version) {
return {
settings: {
map: {
'weboob-installed': `${installed}`,
'weboob-version': version
}
}
};
}
describe('isWeboobInstalled', () => {
describe('should return false when', () => {
it("'weboob-installed' set to false", () => {
let state = { settings: { map : { 'weboob-installed': 'false' } } };
let state = makeState(false, undefined);
get.isWeboobInstalled(state).should.equal(false);
});
it("'weboob-installed' set to true and 'weboob-version' < MIN_WEBOOB_VERSION", () => {
let state = {
settings: {
map : {
'weboob-installed': 'true',
'weboob-version': '1.0.0',
}
}
};
let state = makeState(true, '0.0.1');
get.isWeboobInstalled(state).should.equal(false);
});
it("'weboob-installed' set to true and 'weboob-version' === 0.h", () => {
let state = {
settings: {
map : {
'weboob-installed': 'true',
'weboob-version': '0.h',
}
}
};
let state = makeState(true, '0.h');
get.isWeboobInstalled(state).should.equal(false);
});
});
describe('should return true when', () => {
it("'weboob-installed' set to true and 'weboob-version' === MIN_WEBOOB_VERSION", () => {
let state = {
settings: {
map : {
'weboob-installed': 'true',
'weboob-version': MIN_WEBOOB_VERSION,
}
}
};
let state = makeState(true, MIN_WEBOOB_VERSION);
get.isWeboobInstalled(state).should.equal(true);
});
it("'weboob-installed' set to true and MIN_WEBOOB_VERSION <= 'weboob-version'", () => {
let state = {
settings: {
map : {
'weboob-installed': 'true',
'weboob-version': semver.inc(normalizeVersion(MIN_WEBOOB_VERSION), 'minor'),
}
}
};
it("'weboob-installed' set to true and 'weboob-version' > MIN_WEBOOB_VERSION", () => {
let state = makeState(true, semver.inc(normalizeVersion(MIN_WEBOOB_VERSION), 'minor'));
get.isWeboobInstalled(state).should.equal(true);
});
});
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment