diff --git a/public/js/__tests__/Menu-test.js b/public/js/__tests__/components/Menu-test.js
similarity index 80%
rename from public/js/__tests__/Menu-test.js
rename to public/js/__tests__/components/Menu-test.js
index deffe6b9c4..59f8024856 100644
--- a/public/js/__tests__/Menu-test.js
+++ b/public/js/__tests__/components/Menu-test.js
@@ -1,8 +1,8 @@
/** @jsx React.DOM */
-jest.dontMock("../components/Menu");
+jest.dontMock("../../components/Menu");
-var Menu = require("../components/Menu");
+var Menu = require("../../components/Menu");
var React = require("react/addons");
var TestUtils = React.addons.TestUtils;
diff --git a/public/js/__tests__/components/feature/FeatureForm-test.js b/public/js/__tests__/components/feature/FeatureForm-test.js
new file mode 100644
index 0000000000..d42a0c9639
--- /dev/null
+++ b/public/js/__tests__/components/feature/FeatureForm-test.js
@@ -0,0 +1,47 @@
+jest.dontMock("../../../components/feature/FeatureForm");
+
+var React = require("react/addons");
+var TestUtils = React.addons.TestUtils;
+var FeatureForm = require("../../../components/feature/FeatureForm");
+var strategyStore = require("../../../stores/StrategyStore");
+
+describe("FeatureForm", function () {
+ var Component;
+ beforeEach(function() {
+ strategyStore.getStrategies.mockImplementation(function() {
+ return {
+ then: function (callback) {
+ return callback({
+ strategies: [
+ { name: "default"}
+ ]
+ });
+ }
+ };
+ });
+ });
+
+ afterEach(function() {
+ React.unmountComponentAtNode(document.body);
+ });
+
+ describe("new", function () {
+ it("should render empty form", function() {
+ Component = TestUtils .renderIntoDocument();
+ var name = Component.getDOMNode().querySelectorAll("input");
+ expect(name[0].value).toEqual(undefined);
+ });
+ });
+
+ describe("edit", function () {
+ var feature = {name: "Test", strategy: "unknown"};
+
+ it("should show unknown strategy as deleted", function () {
+ Component = TestUtils .renderIntoDocument();
+
+ var strategySelect = Component.getDOMNode().querySelector("select");
+ expect(strategySelect.value).toEqual("unknown (deleted)");
+ });
+ });
+
+});
\ No newline at end of file
diff --git a/public/js/components/feature/FeatureForm.jsx b/public/js/components/feature/FeatureForm.jsx
index 17998506d4..26cb524186 100644
--- a/public/js/components/feature/FeatureForm.jsx
+++ b/public/js/components/feature/FeatureForm.jsx
@@ -1,5 +1,5 @@
var React = require('react');
-var TextInput = require('../form/TextInput');
+var TextInput = require('../form/TextInput');
var strategyStore = require('../../stores/StrategyStore');
var FeatureForm = React.createClass({
@@ -36,20 +36,30 @@ var FeatureForm = React.createClass({
},
setSelectedStrategy: function(name) {
- var selected = this.state.strategyOptions.filter(function(strategy) {
+ var selectedStrategy = this.state.strategyOptions.filter(function(strategy) {
return strategy.name === name;
- });
+ })[0];
+ if(selectedStrategy) {
+ if(selectedStrategy.parametersTemplate) {
+ this.setStrategyParams(selectedStrategy);
+ }
+ } else {
+ var updatedStrategyName = name + " (deleted)";
+ this.setState({
+ currentStrategy: updatedStrategyName,
+ strategyOptions: this.state.strategyOptions.concat([{name: updatedStrategyName}])
+ });
+ }
+ },
+
+ setStrategyParams: function(strategy) {
var requiredParams = [];
var key;
-
- if(selected[0] && selected[0].parametersTemplate) {
- for(key in selected[0].parametersTemplate) {
- requiredParams.push({name: key, value: this.getParameterValue(key)});
- }
+ for(key in strategy.parametersTemplate) {
+ requiredParams.push({name: key, value: this.getParameterValue(key)});
}
this.setState({requiredParams: requiredParams});
-
},
render: function() {