Skip to content

Commit

Permalink
Update sshkey component tests after enzyme updates.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeff Pihach committed Oct 2, 2018
1 parent bce825b commit 5d21e5e
Show file tree
Hide file tree
Showing 3 changed files with 135 additions and 32 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`DeploymentSSHKey can disable and enable the add 1`] = `
<div
className="deployment-ssh-key"
>
<p
className="deployment-ssh-key__description"
>
Keys will allow you SSH access to the machines provisioned by Juju for this model.
</p>
<div
className="twelve-col no-margin-bottom"
>
<div
className="three-col no-margin-bottom"
>
<InsetSelect
disabled={false}
label="Source"
onChange={[Function]}
options={
Array [
Object {
"label": "GitHub",
"value": "github",
},
Object {
"label": "Manual",
"value": "manual",
},
Object {
"label": "Launchpad",
"value": "launchpad",
},
]
}
/>
</div>
<div
className="deployment-ssh-key__username three-col last-col no-margin-bottom"
>
<GenericInput
autocomplete={true}
key="githubUsername"
label="GitHub username"
multiLine={false}
onKeyUp={[Function]}
required={false}
type="text"
/>
</div>
<div
className="deployment-ssh-key__add-key right"
>
<Button
action={[Function]}
disabled={true}
type="positive"
>
Add keys
</Button>
</div>
</div>
</div>
`;

exports[`DeploymentSSHKey can disable and enable the add 2`] = `
<div
className="deployment-ssh-key"
>
<p
className="deployment-ssh-key__description"
>
Keys will allow you SSH access to the machines provisioned by Juju for this model.
</p>
<div
className="twelve-col no-margin-bottom"
>
<div
className="three-col no-margin-bottom"
>
<InsetSelect
disabled={false}
label="Source"
onChange={[Function]}
options={
Array [
Object {
"label": "GitHub",
"value": "github",
},
Object {
"label": "Manual",
"value": "manual",
},
Object {
"label": "Launchpad",
"value": "launchpad",
},
]
}
/>
</div>
<div
className="deployment-ssh-key__username three-col last-col no-margin-bottom"
>
<GenericInput
autocomplete={true}
key="githubUsername"
label="GitHub username"
multiLine={false}
onKeyUp={[Function]}
required={false}
type="text"
/>
</div>
<div
className="deployment-ssh-key__add-key right"
>
<Button
action={[Function]}
disabled={false}
type="positive"
>
Add keys
</Button>
</div>
</div>
</div>
`;
Original file line number Diff line number Diff line change
Expand Up @@ -425,10 +425,6 @@ class DeploymentSSHKey extends React.Component {
return false;
}

componentDidUpdate() {
this._updateButtonState();
}

render() {
const cloud = this.props.cloud;
if (!cloud) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ describe('DeploymentSSHKey', function() {
launchpadUsername: {getValue: () => 'rose'},
sshSource: {getValue: () => 'launchpad'}
};
instance.componentDidUpdate();
instance._handleSourceChange();
wrapper.update();
const expected = (
Expand Down Expand Up @@ -296,8 +295,7 @@ describe('DeploymentSSHKey', function() {
}
}
};
instance.componentDidUpdate();
wrapper.update();
instance._updateButtonState();
assert.equal(wrapper.find('Button').prop('disabled'), false);
instance._addGithubKeysCallback(null, [
{id: 1, type: 'ssh-rsa', body: 'thekey', text: 'ssh-rsa thekey'}
Expand Down Expand Up @@ -524,33 +522,11 @@ describe('DeploymentSSHKey', function() {

it('can disable and enable the add', () => {
const wrapper = renderComponent();
const instance = wrapper.instance();
let expected = (
<div className="deployment-ssh-key__add-key right">
<Button
action={wrapper.find('Button').prop('action')}
disabled={true}
type="positive">
Add keys
</Button>
</div>
);
assert.compareJSX(wrapper.find('.deployment-ssh-key__add-key'), expected);
instance.setState({
expect(wrapper).toMatchSnapshot();
wrapper.setState({
buttonDisabled: false
});
wrapper.update();
expected = (
<div className="deployment-ssh-key__add-key right">
<Button
action={wrapper.find('Button').prop('action')}
disabled={false}
type="positive">
Add keys
</Button>
</div>
);
assert.compareJSX(wrapper.find('.deployment-ssh-key__add-key'), expected);
expect(wrapper).toMatchSnapshot();
});

});

0 comments on commit 5d21e5e

Please sign in to comment.