|
|
@@ -1,10 +1,16 @@
|
|
|
-import { masterSet, playPaused, queuePushed, stateSet } from '../../../../actions';
|
|
|
+import { masterSet, playPaused, queueOrdered, queuePushed, stateSet } from '../../../../actions';
|
|
|
import { ActionKeyPressed, ActionTypeKeyPressed, Keys } from '../../../../hooks/vim';
|
|
|
import { Song } from '../../../../types';
|
|
|
|
|
|
import { CmusUIState, LibraryModeWindow, Overlay, View } from '../types';
|
|
|
|
|
|
-import { stateDifferentView, stateFromMode, stateLibrary, stateWithActiveSong } from './fixtures';
|
|
|
+import {
|
|
|
+ stateDifferentView,
|
|
|
+ stateFromMode,
|
|
|
+ stateLibrary,
|
|
|
+ stateQueue,
|
|
|
+ stateWithActiveSong,
|
|
|
+} from './fixtures';
|
|
|
import { cmusUIReducer, initialCmusUIState } from './reducer';
|
|
|
|
|
|
describe(ActionTypeKeyPressed, () => {
|
|
|
@@ -12,6 +18,7 @@ describe(ActionTypeKeyPressed, () => {
|
|
|
key | toView
|
|
|
${Keys['1']} | ${View.Library}
|
|
|
${Keys['2']} | ${View.ClientList}
|
|
|
+ ${Keys['3']} | ${View.Queue}
|
|
|
`('$key', ({ key, toView }) => {
|
|
|
const action: ActionKeyPressed = { type: ActionTypeKeyPressed, key };
|
|
|
|
|
|
@@ -186,6 +193,14 @@ describe(ActionTypeKeyPressed, () => {
|
|
|
});
|
|
|
});
|
|
|
|
|
|
+ describe('when in queue view', () => {
|
|
|
+ it('should select the next item in the queue', () => {
|
|
|
+ expect.assertions(1);
|
|
|
+ const result = cmusUIReducer(stateQueue, action);
|
|
|
+ expect(result.queue.active).toBe(887);
|
|
|
+ });
|
|
|
+ });
|
|
|
+
|
|
|
describe('when in a different view', () => {
|
|
|
it('should set the scroll delta and increment the serial number', () => {
|
|
|
expect.assertions(1);
|
|
|
@@ -303,6 +318,17 @@ describe(ActionTypeKeyPressed, () => {
|
|
|
});
|
|
|
});
|
|
|
|
|
|
+ describe('when in queue view', () => {
|
|
|
+ it('should select the next item in the queue', () => {
|
|
|
+ expect.assertions(1);
|
|
|
+ const result = cmusUIReducer(
|
|
|
+ { ...stateQueue, queue: { ...stateQueue.queue, active: 189 } },
|
|
|
+ action,
|
|
|
+ );
|
|
|
+ expect(result.queue.active).toBe(75);
|
|
|
+ });
|
|
|
+ });
|
|
|
+
|
|
|
describe('when in a different view', () => {
|
|
|
it('should set the scroll delta and increment the serial number', () => {
|
|
|
expect.assertions(1);
|
|
|
@@ -312,6 +338,36 @@ describe(ActionTypeKeyPressed, () => {
|
|
|
});
|
|
|
});
|
|
|
|
|
|
+ describe(Keys.p, () => {
|
|
|
+ const action: ActionKeyPressed = { type: ActionTypeKeyPressed, key: Keys.p };
|
|
|
+
|
|
|
+ describe('when on the queue view', () => {
|
|
|
+ it('should set a global action to move the song down the queue', () => {
|
|
|
+ expect.assertions(1);
|
|
|
+ const result = cmusUIReducer(
|
|
|
+ { ...stateQueue, queue: { ...stateQueue.queue, active: 75 } },
|
|
|
+ action,
|
|
|
+ );
|
|
|
+ expect(result.globalAction).toStrictEqual(queueOrdered(75, 1));
|
|
|
+ });
|
|
|
+ });
|
|
|
+ });
|
|
|
+
|
|
|
+ describe(Keys.P, () => {
|
|
|
+ const action: ActionKeyPressed = { type: ActionTypeKeyPressed, key: Keys.P };
|
|
|
+
|
|
|
+ describe('when on the queue view', () => {
|
|
|
+ it('should set a global action to move the song up the queue', () => {
|
|
|
+ expect.assertions(1);
|
|
|
+ const result = cmusUIReducer(
|
|
|
+ { ...stateQueue, queue: { ...stateQueue.queue, active: 75 } },
|
|
|
+ action,
|
|
|
+ );
|
|
|
+ expect(result.globalAction).toStrictEqual(queueOrdered(75, -1));
|
|
|
+ });
|
|
|
+ });
|
|
|
+ });
|
|
|
+
|
|
|
describe(Keys.Z, () => {
|
|
|
const action: ActionKeyPressed = { type: ActionTypeKeyPressed, key: Keys.Z };
|
|
|
|
|
|
@@ -579,6 +635,26 @@ describe(ActionTypeKeyPressed, () => {
|
|
|
expect(result.globalAction).toStrictEqual(masterSet('some-active-client'));
|
|
|
});
|
|
|
});
|
|
|
+
|
|
|
+ describe('when on the queue view', () => {
|
|
|
+ it('should set the globalAction to play the active song', () => {
|
|
|
+ expect.assertions(1);
|
|
|
+
|
|
|
+ const result = cmusUIReducer(
|
|
|
+ { ...stateQueue, queue: { ...stateQueue.queue, active: 75 } },
|
|
|
+ action,
|
|
|
+ );
|
|
|
+
|
|
|
+ expect(result.globalAction).toStrictEqual(
|
|
|
+ stateSet({
|
|
|
+ playing: true,
|
|
|
+ songId: 75,
|
|
|
+ currentTime: 0,
|
|
|
+ seekTime: 0,
|
|
|
+ }),
|
|
|
+ );
|
|
|
+ });
|
|
|
+ });
|
|
|
});
|
|
|
|
|
|
describe(Keys.esc, () => {
|