Skip to content

Commit

Permalink
Small fix for Permissions page and tests
Browse files Browse the repository at this point in the history
The mocha tests were failing (correctly!) due to extra check to
prevent adding blank entries.
  • Loading branch information
benkeen committed May 20, 2015
1 parent 1c6ffe9 commit 5149d52
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
3 changes: 1 addition & 2 deletions app/addons/permissions/components.react.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ function (app, FauxtonAPI, React, Components, Stores, Actions) {
if (!_.isEmpty(value)) {
return false;
}

FauxtonAPI.addNotification({
msg: 'Cannot add an empty value for ' + type + '.',
type: 'warning'
Expand All @@ -76,7 +75,7 @@ function (app, FauxtonAPI, React, Components, Stores, Actions) {

addNames: function (e) {
e.preventDefault();
if (this.isEmptyValue(this.state.newRole, 'names')) {
if (this.isEmptyValue(this.state.newName, 'names')) {
return;
}
this.props.addItem({
Expand Down
20 changes: 16 additions & 4 deletions app/addons/permissions/tests/componentsSpec.react.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,14 @@ define([
});

it('adds user on submit', function () {
var dom = $(el.getDOMNode()).find('.permission-item-form')[0];
TestUtils.Simulate.submit(dom);
var input = $(el.getDOMNode()).find('input')[0];
TestUtils.Simulate.change(input, {
target: {
value: 'newusername'
}
});
var form = $(el.getDOMNode()).find('.permission-item-form')[0];
TestUtils.Simulate.submit(form);

var options = addSpy.args[0][0];
assert.ok(addSpy.calledOnce);
Expand All @@ -95,8 +101,14 @@ define([
});

it('adds role on submit', function () {
var dom = $(el.getDOMNode()).find('.permission-item-form')[1];
TestUtils.Simulate.submit(dom);
var input = $(el.getDOMNode()).find('input')[1];
TestUtils.Simulate.change(input, {
target: {
value: 'newrole'
}
});
var form = $(el.getDOMNode()).find('.permission-item-form')[1];
TestUtils.Simulate.submit(form);

var options = addSpy.args[0][0];
assert.ok(addSpy.calledOnce);
Expand Down

0 comments on commit 5149d52

Please sign in to comment.