Skip to content

Commit

Permalink
feat(action): changeUserIdentity(anonymous or not)
Browse files Browse the repository at this point in the history
  • Loading branch information
abalone0204 committed Jun 9, 2016
1 parent 1a8b50f commit 92659e1
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 2 deletions.
7 changes: 7 additions & 0 deletions front-end/app/actions/changeUserIdentity.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export const CHANGE_USER_IDENTITY = 'CHANGE_USER_IDENTITY'

export function changeUserIdentity() {
return {
type: CHANGE_USER_IDENTITY
}
}
17 changes: 17 additions & 0 deletions tests/front-end/actions/changeUserIdentity.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import {
assert
} from 'chai'
import {
CHANGE_USER_IDENTITY,
changeUserIdentity
} from 'actions/changeUserIdentity.js'

describe('Actions/ changeUserIdentity', function () {
it('should return action of changeUserIdentity', () => {
const expected = {
type: CHANGE_USER_IDENTITY
}
const actual = changeUserIdentity()
assert.deepEqual(expected, actual)
})
});
26 changes: 24 additions & 2 deletions tests/front-end/reducers/user.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,22 @@ import {
SUCCESS_LOGIN
} from 'actions/login.js'

import {
CHANGE_USER_IDENTITY
} from 'actions/changeUserIdentity.js'

describe('Reducers/ User', () => {
const getInitState = () => {
status: 'init'
return {
status: 'init',
anonymous: false
}
}

it('should handle initial state', () => {
const expected = {
status: 'init'
status: 'init',
anonymous: false
}
const actual = user(getInitState(), {})
assert.deepEqual(expected, actual)
Expand All @@ -25,6 +33,7 @@ describe('Reducers/ User', () => {
const access_token = 'mock_token'
const expected = {
status: 'loading',
anonymous: false,
access_token
}
const actual = user(getInitState(), {
Expand All @@ -41,6 +50,7 @@ describe('Reducers/ User', () => {
}
const expected = {
status: 'complete',
anonymous: false,
info: mockUser
}
const actual = user(getInitState(), {
Expand All @@ -56,6 +66,7 @@ describe('Reducers/ User', () => {
}
const expected = {
status: 'failed',
anonymous: false,
error
}
const actual = user(getInitState(), {
Expand All @@ -65,4 +76,15 @@ describe('Reducers/ User', () => {
assert.deepEqual(expected, actual)
})

it('should handle chnage user identity', () => {
const expected = {
status: 'init',
anonymous: true
}
const actual = user(getInitState(), {
type: CHANGE_USER_IDENTITY
})
assert.deepEqual(expected, actual)
})

})

0 comments on commit 92659e1

Please sign in to comment.