MyCrypto/spec/utils/helpers.spec.ts
William O'Beirne 5542791af8 Electron Alpha Prep (#1665)
* Adjust update flow to not auto update, not publish in CI

* Revert "Adjust update flow to not auto update, not publish in CI"

This reverts commit 74fb382ce8d8cd9e227703ccfa8d6310bffd9dda.

* First pass at new app version modal

* Added app alpha notice that either warns you about alpha, or blocks the whole app.

* Improve newer version detection, add unit tests

* Remove native auto update behavior

* Notice once per session

* copy changes per PR review
2018-04-24 22:29:34 -05:00

77 lines
2.1 KiB
TypeScript

import { objectContainsObjectKeys, isNewerVersion } from 'utils/helpers';
describe('objectContainsObjectKeys', () => {
it('should return true when object contains all keys of another object', () => {
const checkingObject = {
a: 1,
b: 2,
c: 3
};
const containingObject = {
a: 1,
b: 2,
c: 3,
d: 4
};
expect(objectContainsObjectKeys(checkingObject, containingObject)).toBeTruthy();
});
it('should return false when object does not contain all keys of another object', () => {
const checkingObject = {
a: 1,
b: 2,
c: 3
};
const containingObject = {
a: 1
};
expect(objectContainsObjectKeys(checkingObject, containingObject)).toBeFalsy();
});
});
describe('isNewerVersion', () => {
it('Should return true for newer major version', () => {
expect(isNewerVersion('1.0.0', '2.0.0')).toBeTruthy();
});
it('Should return true for newer minor version', () => {
expect(isNewerVersion('1.0.0', '1.1.0')).toBeTruthy();
});
it('Should return true for newer patch version', () => {
expect(isNewerVersion('1.0.0', '1.0.1')).toBeTruthy();
});
it('Should return false for same version', () => {
expect(isNewerVersion('1.0.0', '1.0.0')).toBeFalsy();
});
it('Should return false for older version', () => {
expect(isNewerVersion('1.0.1', '1.0.0')).toBeFalsy();
});
it('Should return true for newer release candidate', () => {
expect(isNewerVersion('1.0.0-RC.0', '1.0.0-RC.1')).toBeTruthy();
});
it('Should return false for same release candidate', () => {
expect(isNewerVersion('1.0.0-RC.1', '1.0.0-RC.1')).toBeFalsy();
});
it('Should return false for older release candidate', () => {
expect(isNewerVersion('1.0.0-RC.1', '1.0.0-RC.0')).toBeFalsy();
});
it('Should return true for same version, but no release candidate', () => {
expect(isNewerVersion('1.0.0-RC.999', '1.0.0')).toBeTruthy();
});
it('Should return true for newer non-release candidate', () => {
expect(isNewerVersion('1.0.0-RC.999', '1.0.1')).toBeTruthy();
});
});