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:
parent
e2037958f4
commit
38062eeb82
2 changed files with 21 additions and 2 deletions
|
@ -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);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
12
app/tests/helpers/stub-session.js
Normal file
12
app/tests/helpers/stub-session.js
Normal 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));
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue