Commit bbd42e2a authored by Jaden DIEFENBAUGH's avatar Jaden DIEFENBAUGH

[js][exp] refactor exp editor and tests

parent 1dbb4ab7
......@@ -7,6 +7,7 @@ import { spies } from '@test';
import * as Selectors from '@store/selectors.js';
import { ExperimentEditor as C } from '.';
import { getValidExperimentObj as getValidObj } from '@helpers/beat';
import testAlgs from '@test/test_algs.json';
import testDbs from '@test/test_dbs.json';
......@@ -40,7 +41,10 @@ describe('<ExperimentEditor />', () => {
].concat(testExps);
exps.forEach(function(exp){
if(exp.name !== 'user/user/single/1/single_add')
return;
const saveFunc = () => {};
const updateFunc = () => {};
const tc = testTcs.find(tc => exp.name.includes(tc.name));
it(`${ exp.name }`, () => {
......@@ -54,11 +58,12 @@ describe('<ExperimentEditor />', () => {
toolchain={tc}
saveFunc={saveFunc}
environments={envs}
updateFunc={updateFunc}
/>
);
expect(wrapper).to.have.props(
['data', 'experiments', 'normalBlocks', 'analyzerBlocks', 'datasets', 'toolchain', 'saveFunc', 'environments']
['data', 'experiments', 'normalBlocks', 'analyzerBlocks', 'datasets', 'toolchain', 'saveFunc', 'environments', 'updateFunc']
);
});
});
......@@ -68,10 +73,14 @@ describe('<ExperimentEditor />', () => {
it(`user/user/single/1/single_add`, () => {
const expName = 'user/user/single/1/single_add';
const saveFunc = sinon.spy();
const _updateFunc = (obj) => {
wrapper.setProps && wrapper.setProps({ data: obj });
};
const updateFunc = sinon.spy(_updateFunc);
const tc = testTcs.find(tc => expName.includes(tc.name));
wrapper = mount(
<C
data={{name: expName, contents: {}}}
data={getValidObj({name: expName, contents: {}}, tc, [normalBlocks, ...analyzerBlocks])}
experiments={[]}
normalBlocks={normalBlocks}
analyzerBlocks={analyzerBlocks}
......@@ -79,17 +88,19 @@ describe('<ExperimentEditor />', () => {
toolchain={tc}
saveFunc={saveFunc}
environments={envs}
updateFunc={updateFunc}
/>
);
//console.log('doing name');
expect(wrapper.state('cache')).to.have.property('name', expName);
expect(wrapper.props().data).to.have.property('name', expName);
//console.log('finished name change, doing dataset');
wrapper.find('div.dataset0 select').simulate('change', { target: { value: 'protocol/set (simple/1)'}});
expect(wrapper.state('cache').contents).to.have.deep.property('datasets', {
expect(updateFunc.callCount).to.equal(1);
expect(wrapper.props().data.contents).to.have.deep.property('datasets', {
'set': {
'set': 'set',
'protocol': 'protocol',
......@@ -102,7 +113,8 @@ describe('<ExperimentEditor />', () => {
wrapper.find('svg #block_echo').simulate('click');
expect(wrapper.find({ name: 'echo', set: 'blocks'}).find('.tcBlockBackground').prop('className')).to.include('highlighted');
wrapper.find('div.block0 div.algorithm select').at(0).simulate('change', { target: { value: 'user/integers_add/1'}});
expect(wrapper.state('cache').contents).to.have.deep.property('blocks', {
expect(updateFunc.callCount).to.equal(2);
expect(wrapper.props().data.contents).to.have.deep.property('blocks', {
'echo': {
'inputs': {
'in_data': 'in'
......@@ -120,7 +132,8 @@ describe('<ExperimentEditor />', () => {
wrapper.find('svg #block_analysis').simulate('click');
expect(wrapper.find({ name: 'analysis', set: 'analyzers'}).find('.tcBlockBackground').prop('className')).to.include('highlighted');
wrapper.find('div.block0 div.algorithm select').at(0).simulate('change', { target: { value: 'user/integers_echo_analyzer/1'}});
expect(wrapper.state('cache').contents).to.have.deep.property('analyzers', {
expect(updateFunc.callCount).to.equal(3);
expect(wrapper.props().data.contents).to.have.deep.property('analyzers', {
'analysis': {
'inputs': {
'in_data': 'in'
......@@ -133,8 +146,10 @@ describe('<ExperimentEditor />', () => {
//console.log('finished analyzer, doing env');
wrapper.find('.globals select.env').simulate('change', { target: { value: 'Scientific Python 2.7 (1.0.0)'}});
expect(updateFunc.callCount).to.equal(4);
wrapper.find('.globals select.queue').simulate('change', { target: { value: 'Default'}});
expect(wrapper.state('cache').contents).to.have.deep.property('globals', {
expect(updateFunc.callCount).to.equal(5);
expect(wrapper.props().data.contents).to.have.deep.property('globals', {
'queue': 'Default',
'environment': {
'version': '1.0.0',
......@@ -147,7 +162,7 @@ describe('<ExperimentEditor />', () => {
//console.log('finished env, doing cache check');
expect(wrapper.state('cache')).to.be.deep.equal({
expect(wrapper.props().data).to.be.deep.equal({
'name': 'user/user/single/1/single_add',
'contents': {
description: '',
......
......@@ -457,6 +457,9 @@
"environment": {
"version": "1.2.0",
"name": "Python 2.7"
},
"user/integers_add/1": {
"offset": 2
}
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment