forked from mainmatter/ember-simple-auth
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup-session-test.js
63 lines (51 loc) · 1.68 KB
/
setup-session-test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import Ember from 'ember';
import {
describe,
beforeEach,
afterEach,
it
} from 'mocha';
import { expect } from 'chai';
import sinon from 'sinon';
import setupSession from 'ember-simple-auth/initializers/setup-session';
import Ephemeral from 'ember-simple-auth/session-stores/ephemeral';
import InternalSession from 'ember-simple-auth/internal-session';
describe('setupSession', () => {
let registry;
beforeEach(function() {
registry = {
register() {},
injection() {}
};
});
it('registers the session', function() {
sinon.spy(registry, 'register');
setupSession(registry);
expect(registry.register).to.have.been.calledWith('session:main', InternalSession);
});
describe('when Ember.testing is true', function() {
it('registers the test session store', function() {
sinon.spy(registry, 'register');
setupSession(registry);
expect(registry.register).to.have.been.calledWith('session-store:test', Ephemeral);
});
it('injects the test session store into the session', function() {
sinon.spy(registry, 'injection');
setupSession(registry);
expect(registry.injection).to.have.been.calledWith('session:main', 'store', 'session-store:test');
});
});
describe('when Ember.testing is false', function() {
beforeEach(function() {
Ember.testing = false;
});
afterEach(function() {
Ember.testing = true;
});
it('injects the application session store into the session', function() {
sinon.spy(registry, 'injection');
setupSession(registry);
expect(registry.injection).to.have.been.calledWith('session:main', 'store', 'session-store:application');
});
});
});