1
0
Fork 0
mirror of https://github.com/documize/community.git synced 2025-08-07 22:45:24 +02:00

Added ability to stub session

This commit is contained in:
zinyando 2016-05-13 18:58:46 +02:00
parent e2037958f4
commit 38062eeb82
2 changed files with 21 additions and 2 deletions

View file

@ -10,14 +10,21 @@ export default function(name, options = {}) {
if (options.beforeEach) {
options.beforeEach.apply(this, arguments);
}
this.register = (fullName, Factory) => {
let instance = this.application.__deprecatedInstance__;
let registry = instance.register ? instance : instance.registry;
return registry.register(fullName, Factory);
};
},
afterEach() {
destroyApp(this.application);
if (options.afterEach) {
options.afterEach.apply(this, arguments);
}
destroyApp(this.application);
}
});
}

View file

@ -0,0 +1,12 @@
import Ember from 'ember';
const Session = Ember.Service.extend({
login(credentials) {
// TODO: figure out what to do with credentials
return new Ember.RSVP.resolve();
}
});
export default Ember.Test.registerAsyncHelper('stubSession', function(app, test, attrs={}) {
test.register('service:session', Session.extend(attrs));
});