Skip to content

Instantly share code, notes, and snippets.

@icodejs
Created July 9, 2019 11:08
Show Gist options
  • Save icodejs/bd5adeec78abe62dd5e097913b70cad0 to your computer and use it in GitHub Desktop.
Save icodejs/bd5adeec78abe62dd5e097913b70cad0 to your computer and use it in GitHub Desktop.
import {
SELECT_MIDI_CONTROLLER,
SELECT_NUMBER_OF_KEYBOARD_OCTAVES,
SET_WEB_MIDI_SUPPORTED,
} from './action-types';
export const selectMidiController = ({ selectedDeviceName }) => ({
type: SELECT_MIDI_CONTROLLER,
selectedDeviceName,
});
export const selectNumberOfKeyboardOctaves = ({
numberOfKeyboardOctaves
}) => ({
type: SELECT_NUMBER_OF_KEYBOARD_OCTAVES,
numberOfKeyboardOctaves,
})
export const setWebMidiSupported = ({
webMidiSupported,
}) => ({
type: SET_WEB_MIDI_SUPPORTED,
webMidiSupported,
});
import * as actions from './actions';
import * as types from './action-types';
describe('actions', () => {
describe('selectMidiController', () => {
it('should select a midi controller available', () => {
const selectedDeviceName = 'fake-controller';
const result = actions.selectMidiController({
selectedDeviceName,
});
const expectedResult = {
type: types.SELECT_MIDI_CONTROLLER,
selectedDeviceName,
}
expect(result).toEqual(expectedResult);
})
});
describe('selectNumberOfKeyboardOctaves', () => {
it('should set the number of keyboard octaves state', () => {
const numberOfKeyboardOctaves = 2;
const result = actions.selectNumberOfKeyboardOctaves({
numberOfKeyboardOctaves,
})
const expectedResult = {
type: types.SELECT_NUMBER_OF_KEYBOARD_OCTAVES,
numberOfKeyboardOctaves,
}
expect(result).toEqual(expectedResult);
})
});
describe("setWebmidiSupport", () => {
it("should set state relating to webmidi support", () => {
const webMidiSupported = 2;
const result = actions.setWebMidiSupported({
webMidiSupported
});
const expectedResult = {
type: types.SET_WEB_MIDI_SUPPORTED,
webMidiSupported
};
expect(result).toEqual(expectedResult);
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment