diff --git a/src/__tests__/casperjs/command_view_test.js b/src/__tests__/casperjs/command_view_test.js new file mode 100644 index 00000000..4fec2ccf --- /dev/null +++ b/src/__tests__/casperjs/command_view_test.js @@ -0,0 +1,48 @@ +var CasperUtils = require('./casperUtils').CasperUtils; + +casper.start( + CasperUtils.getUrlForCommands([ + 'asd' + ]), + function() { + this.test.assertTitle('Learn Git Branching'); + + casper.waitFor(CasperUtils.waits.jsMount) + .wait(300) + .then(CasperUtils.screenshot.entirePage) + .then(CasperUtils.enterCommand('git checkout C1')) + .wait(800) + .then(CasperUtils.asserts.selectorContainsText( + 'div.modalView.inFront div.toolbar', + 'Select a level' + )) + .then(CasperUtils.asserts.selectorContainsText( + 'div.modalView.inFront div.displayName h3', + 'Introduction Sequence' + )) + .then(CasperUtils.asserts.selectorContainsText( + 'div.modalView.inFront div.seriesView p', + "A nicely paced introduction to the majority of git commands" + )) + .then(function() { + this.page.sendEvent('keypress', this.page.event.key.Right); + }) + .wait(700) + .then(CasperUtils.screenshot.entirePage) + // Now we have selected the first level + .then(CasperUtils.asserts.selectorContainsText( + 'div.modalView.inFront div.seriesView p', + "Introduction to Git Commits" + )) + .then(function() { + this.page.sendEvent('keypress', this.page.event.key.Enter); + }) + .wait(700) + .then(CasperUtils.screenshot.entirePage) + .then(CasperUtils.asserts.selectorContainsText( + 'div.levelNameWrapper', + "Level Introduction to Git Commits" + )) + .then(CasperUtils.testDone); + +}).run(); diff --git a/src/js/models/commandModel.js b/src/js/models/commandModel.js index 39c05a8a..282a55d6 100644 --- a/src/js/models/commandModel.js +++ b/src/js/models/commandModel.js @@ -201,7 +201,6 @@ var Command = Backbone.Model.extend({ }, addWarning: function(msg) { - console.log('this is the warning', msg); this.get('warnings').push(msg); // change numWarnings so the change event fires. This is bizarre -- Backbone can't // detect if an array changes, so adding an element does nothing diff --git a/src/js/react_views/CommandView.jsx b/src/js/react_views/CommandView.jsx index 6b17f516..c101212f 100644 --- a/src/js/react_views/CommandView.jsx +++ b/src/js/react_views/CommandView.jsx @@ -18,11 +18,17 @@ var CommandView = React.createClass({ componentDidMount: function() { this.props.command.on('change', this.updateStateFromModel, this); + this.props.command.on('destroy', this.onModelDestroy, this); this.updateStateFromModel(); }, componentWillUnmount: function() { this.props.command.off('change', this.updateStateFromModel, this); + this.props.command.off('destroy', this.onModelDestroy, this); + }, + + onModelDestroy: function() { + React.unmountComponentAtNode(this.getDOMNode().parentNode); }, updateStateFromModel: function() {