mirror of
https://github.com/captbaritone/webamp.git
synced 2026-07-21 09:09:01 +00:00
Add more playlist test cases
This commit is contained in:
parent
6d0152cf70
commit
56a5388cdf
1 changed files with 51 additions and 1 deletions
|
|
@ -1,7 +1,57 @@
|
|||
import reducer from "./playlist";
|
||||
import { SHIFT_CLICKED_TRACK } from "../actionTypes";
|
||||
import {
|
||||
SHIFT_CLICKED_TRACK,
|
||||
CLICKED_TRACK,
|
||||
CTRL_CLICKED_TRACK
|
||||
} from "../actionTypes";
|
||||
|
||||
describe("playlist reducer", () => {
|
||||
it("can handle clicking a track", () => {
|
||||
const initialState = {
|
||||
tracks: {
|
||||
2: { selected: false },
|
||||
3: { selected: false }
|
||||
},
|
||||
trackOrder: [3, 2],
|
||||
lastSelectedIndex: 0
|
||||
};
|
||||
|
||||
const nextState = reducer(initialState, {
|
||||
type: CLICKED_TRACK,
|
||||
index: 1
|
||||
});
|
||||
expect(nextState).toEqual({
|
||||
tracks: {
|
||||
2: { selected: true },
|
||||
3: { selected: false }
|
||||
},
|
||||
trackOrder: [3, 2],
|
||||
lastSelectedIndex: 1
|
||||
});
|
||||
});
|
||||
it("can handle ctrl-clicking a track", () => {
|
||||
const initialState = {
|
||||
tracks: {
|
||||
2: { selected: true },
|
||||
3: { selected: false }
|
||||
},
|
||||
trackOrder: [3, 2],
|
||||
lastSelectedIndex: 1
|
||||
};
|
||||
|
||||
const nextState = reducer(initialState, {
|
||||
type: CTRL_CLICKED_TRACK,
|
||||
index: 0
|
||||
});
|
||||
expect(nextState).toEqual({
|
||||
tracks: {
|
||||
2: { selected: true },
|
||||
3: { selected: true }
|
||||
},
|
||||
trackOrder: [3, 2],
|
||||
lastSelectedIndex: 0
|
||||
});
|
||||
});
|
||||
it("can handle shift-click", () => {
|
||||
const initialState = {
|
||||
tracks: {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue