Skip to content

Instantly share code, notes, and snippets.

@justinvdm
Created September 22, 2015 09:04
Show Gist options
  • Select an option

  • Save justinvdm/c68285d8caeed29f7499 to your computer and use it in GitHub Desktop.

Select an option

Save justinvdm/c68285d8caeed29f7499 to your computer and use it in GitHub Desktop.
go.app = function() {
var vumigo = require('vumigo_v02');
var App = vumigo.App;
var EndState = vumigo.states.EndState;
var GoApp = App.extend(function(self) {
App.call(self, 'states:start');
self.get_big_config = function() {
// if you have a big config you only want to load for certain
// states, you could do something like this
return self.im.sandbox_config.get('big_config', {json: true});
};
self.states.add('states:start', function(name) {
return self.get_big_config()
.then(function(big_config) {
return new EndState(name, {
text: big_config.foo,
next: 'states:start'
});
});
});
});
return {
GoApp: GoApp
};
}();
var vumigo = require('vumigo_v02');
var fixtures = require('./fixtures');
var AppTester = vumigo.AppTester;
describe("app", function() {
describe("GoApp", function() {
var app;
var tester;
beforeEach(function() {
app = new go.app.GoApp();
tester = new AppTester(app);
tester
.setup.config({
big_config: {
foo: 'bar'
}
})
.setup.config.app({
name: 'test_app'
})
.setup(function(api) {
fixtures().forEach(api.http.fixtures.add);
});
});
describe("when the user starts a session", function() {
it("should should them a foo bar", function() {
return tester
.start()
.check.interaction({
state: 'states:start',
reply: 'bar'
})
.run();
});
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment