added tests for ui

This commit is contained in:
Clemens 2016-06-16 13:25:58 +02:00 committed by Maximilian Hils
parent 44abb4caea
commit 37475217bf
4 changed files with 41 additions and 6 deletions

View file

@ -53,6 +53,7 @@
"gulp-sourcemaps": "^1.6.0",
"gulp-util": "^3.0.7",
"jest": "^12.1.1",
"react-addons-test-utils": "^15.1.0",
"uglifyify": "^3.0.1",
"vinyl-buffer": "^1.0.0",
"vinyl-source-stream": "^1.1.0",

View file

@ -0,0 +1,34 @@
jest.unmock("../../ducks/ui");
import reducer, {setActiveMenu, SELECT_FLOW} from '../../ducks/ui';
describe("ui reducer", () => {
it("should return the initial state", () => {
expect(reducer(undefined, {})).toEqual({ activeMenu: 'Start'})
}),
it("should return the state for view", () => {
expect(reducer(undefined, setActiveMenu('View'))).toEqual({ activeMenu: 'View'})
}),
it("should change the state to Start", () => {
expect(reducer({activeMenu: 'Flow'},
{ type: SELECT_FLOW,
currentSelection: '1',
flowId : undefined
})).toEqual({ activeMenu: 'Start'})
}),
it("should change the state to Flow", () => {
expect(reducer({activeMenu: 'Start'},
{ type: SELECT_FLOW,
currentSelection: undefined,
flowId : '1'
})).toEqual({ activeMenu: 'Flow'})
}),
it("should not change the state", () => {
expect(reducer({activeMenu: 'Options'},
{ type: SELECT_FLOW,
currentSelection: '1',
flowId : '2'
})).toEqual({ activeMenu: 'Options'})
})
});

View file

@ -1,9 +1,9 @@
jest.unmock("../utils.js");
jest.unmock("../utils");
import {formatSize} from "../utils.js"
import {formatSize} from "../utils"
describe("utils", function () {
it("formatSize", function(){
describe("utils", () => {
it("formatSize", () => {
expect(formatSize(1024)).toEqual("1kb");
expect(formatSize(0)).toEqual("0");
expect(formatSize(10)).toEqual("10b");

View file

@ -1,5 +1,5 @@
import { SELECT_FLOW } from './flows'
const SET_ACTIVE_MENU = 'SET_ACTIVE_MENU'
export const SELECT_FLOW = "SELECT_FLOW"
export const SET_ACTIVE_MENU = 'SET_ACTIVE_MENU'
const defaultState = {