-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathonInstalled.test.ts
More file actions
48 lines (40 loc) · 1.47 KB
/
onInstalled.test.ts
File metadata and controls
48 lines (40 loc) · 1.47 KB
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
import { expect } from 'chai'
import { createMocks } from './mocks'
import { authenticateViaTwitter } from './steps/authenticate-via-twitter'
import { mountPopup } from './steps/mount-popup'
import { onInstalled } from './steps/onInstalled'
import { runBackground } from './steps/run-background'
describe('noop when onInstalled reason is update', () => {
const mocks = createMocks()
runBackground(mocks)
onInstalled(mocks, { reason: 'update' })
})
describe('authenticated when popup not mounted in between onInstalled when reason is install', () => {
const mocks = createMocks()
runBackground(mocks)
onInstalled(mocks, { reason: 'install' })
authenticateViaTwitter(mocks)
describe('after authentication', () => {
it('is now authenicated', () => {
expect(mocks.getState().auth.state).to.equal('authenticated')
})
})
})
describe('authenticated when popup mounted in between onInstalled when reason is install', () => {
const mocks = createMocks()
runBackground(mocks)
onInstalled(mocks, { reason: 'install' })
mountPopup(mocks, { handle: 'fetched' })
describe('first detectLogin', () => {
it('is now in a not_authed state', () => {
expect(mocks.getState().auth.state).to.equal('not_authed')
})
after(() => mocks.popupWindow().close())
})
authenticateViaTwitter(mocks)
describe('after authentication', () => {
it('is now authenicated', () => {
expect(mocks.getState().auth.state).to.equal('authenticated')
})
})
})