2021-06-29 19:58:29 +00:00
|
|
|
// Copyright 2021 Signal Messenger, LLC
|
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
|
|
|
import { assert } from 'chai';
|
|
|
|
import { actions } from '../../../state/ducks/audioPlayer';
|
|
|
|
import { noopAction } from '../../../state/ducks/noop';
|
|
|
|
import { isPaused } from '../../../state/selectors/audioPlayer';
|
2021-10-26 19:15:33 +00:00
|
|
|
import type { StateType } from '../../../state/reducer';
|
|
|
|
import { reducer as rootReducer } from '../../../state/reducer';
|
2021-06-29 19:58:29 +00:00
|
|
|
|
|
|
|
describe('state/selectors/audioPlayer', () => {
|
|
|
|
const getEmptyRootState = (): StateType => {
|
|
|
|
return rootReducer(undefined, noopAction());
|
|
|
|
};
|
|
|
|
|
|
|
|
describe('isPaused', () => {
|
|
|
|
it('returns true if state.audioPlayer.activeAudioID is undefined', () => {
|
|
|
|
const state = getEmptyRootState();
|
|
|
|
assert.isTrue(isPaused(state));
|
|
|
|
});
|
|
|
|
|
|
|
|
it('returns false if state.audioPlayer.activeAudioID is not undefined', () => {
|
|
|
|
const state = getEmptyRootState();
|
|
|
|
|
|
|
|
const updated = rootReducer(
|
|
|
|
state,
|
|
|
|
actions.setActiveAudioID('id', 'context')
|
|
|
|
);
|
|
|
|
|
|
|
|
assert.isFalse(isPaused(updated));
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|