Commit 27485df4 authored by Jaden DIEFENBAUGH's avatar Jaden DIEFENBAUGH
Browse files

[js] add basic test for ParameterCreate

parent 72608a5c
Pipeline #24221 failed with stages
in 28 minutes and 40 seconds
// @flow
import React from 'react';
import { expect } from 'chai';
import { mount } from 'enzyme';
import sinon from 'sinon';
import { spies } from '@test';
import C from './ParameterCreate.jsx';
describe.only('<ParameterCreate />', () => {
let wrapper;
const name = 'parameter';
// shortcut for a func to update just the parameter obj, not the name
const _updateParameter = (name, p, oldName) => {
wrapper.setProps({
param: p,
});
};
const params = [];
afterEach(() => {
if(wrapper && wrapper.unmount)
wrapper.unmount();
});
it(`saves the default value of a boolean parameter`, () => {
let param = {
type: '',
default: '',
description: '',
};
const updateParameter = sinon.spy(_updateParameter);
wrapper = mount(
<C
name={name}
param={param}
params={params}
updateParameter={updateParameter}
/>
);
// sanity checks
expect(wrapper.find('TypedField')).to.have.prop('name', name);
wrapper.find('Input.custom-select').prop('onChange')( { target: { value: 'bool' }});
wrapper.update();
console.log(wrapper.props().param);
expect(wrapper.props().param).to.deep.equal(
{
type: 'bool',
default: '',
description: '',
}
);
// wrapper.find('input[type="radio"]').at(0).simulate('change', { target: { checked: 'true' }});;
wrapper.find('input[type="radio"]').at(0).simulate('change', { target: { value: 'true' }});;
wrapper.update();
expect(updateParameter.args[0]).to.deep.equal([
name,
{
type: 'bool',
default: 'true',
description: '',
}
]);
});
});
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