diff --git a/static_src/actions/service_actions.js b/static_src/actions/service_actions.js
index 2d43a55c..042abe73 100644
--- a/static_src/actions/service_actions.js
+++ b/static_src/actions/service_actions.js
@@ -119,8 +119,6 @@ const serviceActions = {
serviceGuid,
servicePlanGuid: planGuid
});
-
- return Promise.resolve();
});
},
diff --git a/static_src/components/create_service_instance.jsx b/static_src/components/create_service_instance.jsx
index 489d9dee..94afa20f 100644
--- a/static_src/components/create_service_instance.jsx
+++ b/static_src/components/create_service_instance.jsx
@@ -18,6 +18,7 @@ import { validateString } from '../util/validators';
const CREATE_SERVICE_INSTANCE_FORM_GUID = 'create-service-form';
const propTypes = {
+ error: PropTypes.object,
service: PropTypes.object,
servicePlan: PropTypes.object.isRequired
};
@@ -28,7 +29,6 @@ const defaultProps = {
function stateSetter() {
return {
- createError: ServiceInstanceStore.createError,
createLoading: ServiceInstanceStore.createLoading,
createdTempNotification: ServiceInstanceStore.createdTempNotification,
spaces: SpaceStore.getAll()
@@ -41,8 +41,7 @@ export default class CreateServiceInstance extends React.Component {
this.state = {
errs: [],
- spaces: SpaceStore.getAll(),
- createError: ServiceInstanceStore.createError
+ spaces: SpaceStore.getAll()
};
this.validateString = validateString().bind(this);
diff --git a/static_src/stores/service_instance_store.js b/static_src/stores/service_instance_store.js
index c461ecac..da3f7055 100644
--- a/static_src/stores/service_instance_store.js
+++ b/static_src/stores/service_instance_store.js
@@ -223,7 +223,7 @@ export class ServiceInstanceStore extends BaseStore {
}
case serviceActionTypes.SERVICE_INSTANCE_CREATE_ERROR: {
- this._createInstanceForm = Object.assign({}, this._createInstanceForm, {
+ this._createInstanceForm = Object.assign({}, this._createInstanceForm || {}, {
error: {
description: getFriendlyError(action.error, SERVICE_INSTANCE_CREATE_ERROR_MAP)
}
diff --git a/static_src/test/unit/actions/service_actions.spec.js b/static_src/test/unit/actions/service_actions.spec.js
index cf5a1aa2..093ccf97 100644
--- a/static_src/test/unit/actions/service_actions.spec.js
+++ b/static_src/test/unit/actions/service_actions.spec.js
@@ -258,23 +258,36 @@ describe('serviceActions', function() {
});
});
- describe('createInstanceForm()', function() {
- it(`should dispatch a view event of type create instance form with the
- service guid and service plan guid`, function() {
- var expectedServiceGuid = 'wqphjhajkajkhadjhfd',
- expectedServicePlanGuid = 'fp2ajkdsfadgh32fasd';
+ describe('createInstanceForm()', () => {
+ const expectedServiceGuid = 'wqphjhajkajkhadjhfd';
+ const expectedServicePlanGuid = 'fp2ajkdsfadgh32fasd';
- let expectedParams = {
- servicePlanGuid: expectedServicePlanGuid,
- serviceGuid: expectedServiceGuid
- };
- let spy = setupViewSpy(sandbox);
+ const expectedParams = {
+ servicePlanGuid: expectedServicePlanGuid,
+ serviceGuid: expectedServiceGuid
+ };
+
+ it('should dispatch a form cancel action', (done) => {
+ let uiSpy = setupUISpy(sandbox);
serviceActions.createInstanceForm(expectedServiceGuid,
- expectedServicePlanGuid);
+ expectedServicePlanGuid).then(() => {
+ assertAction(uiSpy, serviceActionTypes.SERVICE_INSTANCE_CREATE_FORM_CANCEL);
+ done();
+ }, done.fail);
+ });
- assertAction(spy, serviceActionTypes.SERVICE_INSTANCE_CREATE_FORM,
- expectedParams);
+ it('should dispatch a form create action', (done) => {
+ let viewSpy = setupViewSpy(sandbox);
+
+ sandbox.stub(serviceActions, 'createInstanceFormCancel').returns(Promise.resolve());
+
+ serviceActions.createInstanceForm(expectedServiceGuid,
+ expectedServicePlanGuid).then(() => {
+ assertAction(viewSpy, serviceActionTypes.SERVICE_INSTANCE_CREATE_FORM,
+ expectedParams);
+ done();
+ }, done.fail);
});
});
diff --git a/static_src/test/unit/components/create_service_instance.spec.jsx b/static_src/test/unit/components/create_service_instance.spec.jsx
index 1cc4af4f..c9027593 100644
--- a/static_src/test/unit/components/create_service_instance.spec.jsx
+++ b/static_src/test/unit/components/create_service_instance.spec.jsx
@@ -3,25 +3,13 @@ import '../../global_setup';
import React from 'react';
import CreateServiceInstance from '../../../components/create_service_instance.jsx';
import FormError from '../../../components/form/form_error.jsx';
-import Immutable from 'immutable';
-import SpaceStore from '../../../stores/space_store';
-import ServiceInstanceStore from '../../../stores/service_instance_store';
import serviceActions from '../../../actions/service_actions';
import { shallow } from 'enzyme';
describe('', () => {
- beforeEach(() => {
- ServiceInstanceStore._createError = { description: 'Bad stuff everyone' };
- });
-
- afterEach(() => {
- ServiceInstanceStore._createError = null;
- });
-
it('displays an error message when ServiceInstanceStore has one', () => {
- SpaceStore._data = Immutable.fromJS([]);
-
- const wrapper = shallow();
+ const error = { description: 'Bad stuff everyone' };
+ const wrapper = shallow();
expect(wrapper.find(FormError).length).toBe(1);
});
diff --git a/static_src/test/unit/stores/service_instance_store.spec.js b/static_src/test/unit/stores/service_instance_store.spec.js
index 795abc54..2d0b6281 100644
--- a/static_src/test/unit/stores/service_instance_store.spec.js
+++ b/static_src/test/unit/stores/service_instance_store.spec.js
@@ -245,22 +245,23 @@ describe('ServiceInstanceStore', function() {
});
});
- describe('on service instance create ui', function() {
- it('should set createInstanceForm to object with service and plan from stores',
- function() {
- var expectedService = { guid: 'adsf3232222a' },
- expectedServicePlan = { guid: 'zxvczvqe' };
+ describe('on service instance create ui', () => {
+ it('should set createInstanceForm to object with service and plan from stores', (done) => {
+ const expectedService = { guid: 'adsf3232222a' };
+ const expectedServicePlan = { guid: 'zxvczvqe' };
sandbox.stub(ServiceStore, 'get').returns(expectedService);
sandbox.stub(ServicePlanStore, 'get').returns(expectedServicePlan);
+ sandbox.stub(serviceActions, 'createInstanceFormCancel').returns(Promise.resolve());
- serviceActions.createInstanceForm('adfkjvnzxczv', 'aldsfjalqwe');
-
- let actual = ServiceInstanceStore.createInstanceForm;
+ serviceActions.createInstanceForm('adfkjvnzxczv', 'aldsfjalqwe').then(() => {
+ const actual = ServiceInstanceStore.createInstanceForm;
- expect(actual).toBeTruthy();
- expect(actual.service).toEqual(expectedService);
- expect(actual.servicePlan).toEqual(expectedServicePlan);
+ expect(actual).toBeTruthy();
+ expect(actual.service).toEqual(expectedService);
+ expect(actual.servicePlan).toEqual(expectedServicePlan);
+ done();
+ }, done);
});
it('should emit a change event', function() {
@@ -295,7 +296,7 @@ describe('ServiceInstanceStore', function() {
return { response: { data: { error_code: code } } };
};
- it('should set `createError` based on error received', () => {
+ it('should set error props of instance form based on error received', () => {
const serverError = { code: 500 };
const argumentError = serviceInstanceError('CF-MessageParseError');
const spaceError = serviceInstanceError('CF-ServiceInstanceInvalid');
@@ -307,35 +308,35 @@ describe('ServiceInstanceStore', function() {
let actual;
serviceActions.errorCreateInstance(serverError);
- actual = ServiceInstanceStore.createError;
+ actual = ServiceInstanceStore._createInstanceForm.error;
expect(actual).toEqual({
description: serverErrorMsg
});
serviceActions.errorCreateInstance(argumentError);
- actual = ServiceInstanceStore.createError;
+ actual = ServiceInstanceStore._createInstanceForm.error;
expect(actual).toEqual({
description: SERVICE_INSTANCE_CREATE_ERROR_MAP['CF-MessageParseError']
});
serviceActions.errorCreateInstance(spaceError);
- actual = ServiceInstanceStore.createError;
+ actual = ServiceInstanceStore._createInstanceForm.error;
expect(actual).toEqual({
description: SERVICE_INSTANCE_CREATE_ERROR_MAP['CF-ServiceInstanceInvalid']
});
serviceActions.errorCreateInstance(configError);
- actual = ServiceInstanceStore.createError;
+ actual = ServiceInstanceStore._createInstanceForm.error;
expect(actual).toEqual({
description: SERVICE_INSTANCE_CREATE_ERROR_MAP['CF-ServiceBrokerBadResponse']
});
serviceActions.errorCreateInstance(dupeNameError);
- actual = ServiceInstanceStore.createError;
+ actual = ServiceInstanceStore._createInstanceForm.error;
expect(actual).toEqual({
description: SERVICE_INSTANCE_CREATE_ERROR_MAP['CF-ServiceInstanceNameTaken']