Skip to content
Snippets Groups Projects
Commit 6340fcfd authored by Jaden DIEFENBAUGH's avatar Jaden DIEFENBAUGH
Browse files

[js] fixed toolchain issue with multiprocessing code! closes #39

parent d11f2d3d
No related branches found
No related tags found
No related merge requests found
Pipeline #
......@@ -3,14 +3,20 @@ import React from 'react';
import { expect } from 'chai';
import { mount } from 'enzyme';
import sinon from 'sinon';
import { Provider } from 'react-redux';
import { spies } from '@test';
import { getValidToolchainObj as getValidObj, getValidDatabaseObj, getValidAlgorithmObj } from '@helpers/beat';
import { ToolchainEditor as C } from '.';
import * as Selectors from '@store/selectors';
import createStoreFunc from '@store/store';
import reducer from '@store/reducers';
import testTcs from '@test/test_tcs.json';
import testDbs from '@test/test_dbs.json';
import testAlgs from '@test/test_algs.json';
// TODO: fix web workers breaking tests
describe.skip('<ToolchainEditor />', () => {
describe('<ToolchainEditor />', () => {
let wrapper;
afterEach(() => {
......@@ -19,24 +25,45 @@ describe.skip('<ToolchainEditor />', () => {
});
describe('accepts', () => {
const tcs = [
].concat(testTcs);
const tcs = testTcs.map(tc => getValidObj(tc));
const dbs = testDbs.map(db => getValidDatabaseObj(db));
const algs = testAlgs.map(alg => getValidAlgorithmObj(alg));
const state = {
...reducer({}, { type: '', payload: {}}),
toolchain: tcs,
database: dbs,
algorithm: algs,
};
const sets = Selectors.flattenedDatabases(state);
const normalAlgorithms = Selectors.normalBlocks(state);
const analyzerAlgorithms = Selectors.analyzerBlocks(state);
const store = createStoreFunc(state);
tcs.forEach(function(tc){
const saveFunc = () => {};
const updateFunc = () => {};
it(`${ tc.name }`, () => {
wrapper = mount(
<C
data={tc}
toolchains={tcs}
saveFunc={saveFunc}
/>
<Provider store={store}>
<C
data={tc}
sets={sets}
toolchains={state.toolchain}
databases={state.database}
normalAlgorithms={normalAlgorithms}
analyzerAlgorithms={analyzerAlgorithms}
saveFunc={saveFunc}
updateFunc={updateFunc}
/>
</Provider>
);
expect(wrapper).to.have.props(
['data', 'toolchains', 'saveFunc']
expect(wrapper.find(C)).to.have.props(
['data', 'toolchains', 'databases', 'normalAlgorithms', 'analyzerAlgorithms', 'saveFunc', 'updateFunc']
).deep.equal(
[tc, tcs, saveFunc]
[tc, tcs, state.database, normalAlgorithms, analyzerAlgorithms, saveFunc, updateFunc]
);
});
});
......
// @flow
// builds the store and fetches the objects
import { createStore, applyMiddleware, compose } from 'redux';
import reducer from './reducers';
import thunk from 'redux-thunk';
import createStore from './store';
import { fetchAllObjects } from './actions.js';
const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;
const preloadedState = {};
const store = createStore(
reducer,
composeEnhancers(
applyMiddleware(
thunk,
),
),
);
const store = createStore();
export default store;
......
// @flow
// builds the store and fetches the objects
import { createStore, applyMiddleware, compose } from 'redux';
import reducer from './reducers';
import type { State } from './reducers';
import thunk from 'redux-thunk';
const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;
const createStoreFunc = (preloadedState?: State) => {
return preloadedState ?
createStore(
reducer,
preloadedState,
composeEnhancers(
applyMiddleware(
thunk,
),
),
)
:
createStore(
reducer,
composeEnhancers(
applyMiddleware(
thunk,
),
),
);
};
export default createStoreFunc;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment