ToolchainEditor.spec.jsx 2.04 KB
Newer Older
Jaden DIEFENBAUGH's avatar
Jaden DIEFENBAUGH committed
1
2
3
4
5
// @flow
import React from 'react';
import { expect } from 'chai';
import { mount } from 'enzyme';
import sinon from 'sinon';
6
import { Provider } from 'react-redux';
Jaden DIEFENBAUGH's avatar
Jaden DIEFENBAUGH committed
7
8
import { spies } from '@test';

9
import { getValidToolchainObj as getValidObj, getValidDatabaseObj, getValidAlgorithmObj } from '@helpers/beat';
Jaden DIEFENBAUGH's avatar
Jaden DIEFENBAUGH committed
10
import { ToolchainEditor as C } from '.';
11
12
13
import * as Selectors from '@store/selectors';
import createStoreFunc from '@store/store';
import reducer from '@store/reducers';
Jaden DIEFENBAUGH's avatar
Jaden DIEFENBAUGH committed
14
15

import testTcs from '@test/test_tcs.json';
16
17
import testDbs from '@test/test_dbs.json';
import testAlgs from '@test/test_algs.json';
Jaden DIEFENBAUGH's avatar
Jaden DIEFENBAUGH committed
18

19
describe('<ToolchainEditor />', () => {
Jaden DIEFENBAUGH's avatar
Jaden DIEFENBAUGH committed
20
21
22
23
24
25
26
27
	let wrapper;

	afterEach(() => {
		if(wrapper && wrapper.unmount)
			wrapper.unmount();
	});

	describe('accepts', () => {
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
		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);
Jaden DIEFENBAUGH's avatar
Jaden DIEFENBAUGH committed
43
44
45

		tcs.forEach(function(tc){
			const saveFunc = () => {};
46
			const updateFunc = () => {};
Jaden DIEFENBAUGH's avatar
Jaden DIEFENBAUGH committed
47
48
			it(`${ tc.name }`, () => {
				wrapper = mount(
49
50
51
52
53
54
55
56
57
58
59
60
					<Provider store={store}>
						<C
							data={tc}
							sets={sets}
							toolchains={state.toolchain}
							databases={state.database}
							normalAlgorithms={normalAlgorithms}
							analyzerAlgorithms={analyzerAlgorithms}
							saveFunc={saveFunc}
							updateFunc={updateFunc}
						/>
					</Provider>
Jaden DIEFENBAUGH's avatar
Jaden DIEFENBAUGH committed
61
62
				);

63
64
				expect(wrapper.find(C)).to.have.props(
					['data', 'toolchains', 'databases', 'normalAlgorithms', 'analyzerAlgorithms', 'saveFunc', 'updateFunc']
Jaden DIEFENBAUGH's avatar
Jaden DIEFENBAUGH committed
65
				).deep.equal(
66
					[tc, tcs, state.database, normalAlgorithms, analyzerAlgorithms, saveFunc, updateFunc]
Jaden DIEFENBAUGH's avatar
Jaden DIEFENBAUGH committed
67
68
69
70
71
72
73
74
75
				);
			});
		});
	});

	describe('creates', () => {

	});
});