mirror of
https://github.com/captbaritone/webamp.git
synced 2026-01-24 02:36:00 +00:00
Fix user input reducer tests
This commit is contained in:
parent
994c725f60
commit
e8aff5c2cd
1 changed files with 25 additions and 8 deletions
|
|
@ -2,26 +2,43 @@ import { userInput } from "./reducers";
|
|||
import { SET_FOCUS, SET_SCRUB_POSITION, UNSET_FOCUS } from "./actionTypes";
|
||||
|
||||
describe("userInput reducer", () => {
|
||||
const state = userInput();
|
||||
const state = userInput(undefined, { type: "@@INIT" });
|
||||
it("has sensible defaults", () => {
|
||||
expect(state).toEqual({ focus: null, scrubPosition: 0 });
|
||||
expect(state).toEqual({ focus: null, scrubPosition: 0, bandFocused: null });
|
||||
});
|
||||
it("can set focus", () => {
|
||||
const newState = userInput(state, { type: SET_FOCUS, input: "foo" });
|
||||
expect(newState).toEqual({ focus: "foo", scrubPosition: 0 });
|
||||
const newState = userInput(state, {
|
||||
type: SET_FOCUS,
|
||||
input: "foo",
|
||||
bandFocused: null
|
||||
});
|
||||
expect(newState).toEqual({
|
||||
focus: "foo",
|
||||
scrubPosition: 0,
|
||||
bandFocused: null
|
||||
});
|
||||
});
|
||||
it("can unset focus", () => {
|
||||
const newState = userInput(
|
||||
{ ...state, focus: "foo" },
|
||||
{ ...state, focus: "foo", bandFocused: null },
|
||||
{ type: UNSET_FOCUS }
|
||||
);
|
||||
expect(newState).toEqual({ focus: null, scrubPosition: 0 });
|
||||
expect(newState).toEqual({
|
||||
focus: null,
|
||||
scrubPosition: 0,
|
||||
bandFocused: null
|
||||
});
|
||||
});
|
||||
it("can set scrub position", () => {
|
||||
const newState = userInput(state, {
|
||||
type: SET_SCRUB_POSITION,
|
||||
position: 5
|
||||
position: 5,
|
||||
bandFocused: null
|
||||
});
|
||||
expect(newState).toEqual({
|
||||
focus: null,
|
||||
scrubPosition: 5,
|
||||
bandFocused: null
|
||||
});
|
||||
expect(newState).toEqual({ focus: null, scrubPosition: 5 });
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue