client/src/reducers/__tests__/authReducer.test.js
author ymh <ymh.work@gmail.com>
Mon, 08 Oct 2018 18:35:47 +0200
changeset 168 ea92f4fe783d
permissions -rw-r--r--
- move SlateEditor and dependencies to its own folder - remove Immutable - remove redux-persist-immutable - remobe redux-immutable - update libraries - added tests on store manipulations (accessor and reducers)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
168
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
     1
import uuidV1 from 'uuid/v1';
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
     2
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
     3
import {
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
     4
  isAuthenticated,
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
     5
  currentUser,
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
     6
  currentGroup,
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
     7
  token,
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
     8
  clientId,
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
     9
  login,
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
    10
  register,
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
    11
  groups,
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
    12
  createGroup,
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
    13
} from '../authReducer';
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
    14
import asyncRequest from '../../constants/asyncRequest';
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
    15
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
    16
import * as types from '../../constants/ActionTypes'
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
    17
import UserRecord from '../../store/userRecord';
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
    18
import GroupRecord from '../../store/groupRecord';
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
    19
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
    20
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
    21
describe('auth reducer isAuthenticated', () => {
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
    22
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
    23
  it('should return the initial state', () => {
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
    24
    expect(
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
    25
      isAuthenticated(undefined, {})
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
    26
    ).toEqual(false)
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
    27
  });
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
    28
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
    29
  it("Handle AUTH_DEAUTHENTICATE true", () => {
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
    30
    expect(
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
    31
      isAuthenticated(true, {
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
    32
        type: types.AUTH_DEAUTHENTICATE
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
    33
      })
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
    34
    ).toEqual(false)
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
    35
  });
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
    36
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
    37
  it("Handle AUTH_DEAUTHENTICATE false", () => {
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
    38
    expect(
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
    39
      isAuthenticated(false, {
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
    40
        type: types.AUTH_DEAUTHENTICATE
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
    41
      })
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
    42
    ).toEqual(false)
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
    43
  });
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
    44
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
    45
  it("Handle AUTH_LOGOUT true", () => {
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
    46
    expect(
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
    47
      isAuthenticated(true, {
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
    48
        type: types.AUTH_LOGOUT
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
    49
      })
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
    50
    ).toEqual(false)
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
    51
  });
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
    52
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
    53
  it("Handle AUTH_LOGOUT false", () => {
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
    54
    expect(
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
    55
      isAuthenticated(false, {
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
    56
        type: types.AUTH_LOGOUT
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
    57
      })
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
    58
    ).toEqual(false)
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
    59
  });
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
    60
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
    61
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
    62
  it("Handle AUTH_LOGIN_SUCCESS false", () => {
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
    63
    expect(
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
    64
      isAuthenticated(false, {
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
    65
        type: types.AUTH_LOGIN_SUCCESS
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
    66
      })
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
    67
    ).toEqual(true)
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
    68
  });
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
    69
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
    70
  it("Handle AUTH_LOGIN_SUCCESS true", () => {
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
    71
    expect(
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
    72
      isAuthenticated(true, {
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
    73
        type: types.AUTH_LOGIN_SUCCESS
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
    74
      })
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
    75
    ).toEqual(true)
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
    76
  });
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
    77
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
    78
});
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
    79
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
    80
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
    81
describe('auth reducer currentUser', () => {
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
    82
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
    83
  it('should return the initial state', () => {
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
    84
    expect(
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
    85
      currentUser(undefined, {})
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
    86
    ).toEqual(null)
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
    87
  });
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
    88
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
    89
  it('Handle AUTH_DEAUTHENTICATE', () => {
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
    90
    const initalState = new UserRecord({ first_name: 'John', last_name: 'Doe'});
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
    91
    expect(
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
    92
      currentUser(initalState, {
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
    93
        type: types.AUTH_DEAUTHENTICATE
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
    94
      })
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
    95
    ).toEqual(null)
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
    96
  });
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
    97
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
    98
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
    99
  it('Handle AUTH_LOGOUT', () => {
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   100
    const initalState = new UserRecord({ first_name: 'John', last_name: 'Doe'});
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   101
    expect(
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   102
      currentUser(initalState, {
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   103
        type: types.AUTH_LOGOUT
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   104
      })
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   105
    ).toEqual(null)
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   106
  });
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   107
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   108
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   109
  it('Handle AUTH_LOGIN_SUCCESS', () => {
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   110
    const initalState = null;
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   111
    expect(
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   112
      currentUser(initalState, {
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   113
        type: types.AUTH_LOGIN_SUCCESS,
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   114
        user: { first_name: 'John', last_name: 'Doe'}
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   115
      })
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   116
    ).toEqual(new UserRecord({ first_name: 'John', last_name: 'Doe'}))
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   117
  });
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   118
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   119
  it('Handle USER_UPDATE_SETTINGS', () => {
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   120
    const initalState = new UserRecord({ first_name: 'John', last_name: 'Doe'});
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   121
    expect(
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   122
      currentUser(initalState, {
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   123
        type: types.USER_UPDATE_SETTINGS,
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   124
        firstname: 'Jane',
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   125
        lastname: 'Orwell'
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   126
      })
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   127
    ).toEqual(new UserRecord({ first_name: 'Jane', last_name: 'Orwell'}))
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   128
  });
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   129
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   130
});
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   131
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   132
describe('auth reducer currentGroup', () => {
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   133
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   134
  it('should return the initial state', () => {
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   135
    expect(
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   136
      currentGroup(undefined, {})
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   137
    ).toEqual(null)
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   138
  });
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   139
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   140
  it('Handle AUTH_DEAUTHENTICATE', () => {
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   141
    expect(
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   142
      currentGroup('group1', {
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   143
        type: types.AUTH_DEAUTHENTICATE
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   144
      })
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   145
    ).toEqual(null);
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   146
  });
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   147
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   148
  it('Handle AUTH_LOGOUT', () => {
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   149
    expect(
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   150
      currentGroup('group1', {
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   151
        type: types.AUTH_LOGOUT
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   152
      })
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   153
    ).toEqual(null);
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   154
  });
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   155
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   156
  it('Handle AUTH_LOGIN_SUCCESS', () => {
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   157
    expect(
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   158
      currentGroup(null, {
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   159
        type: types.AUTH_LOGIN_SUCCESS,
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   160
        user: { first_name: 'John', last_name: 'Doe', default_group: 'group1' }
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   161
      })
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   162
    ).toEqual('group1');
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   163
  });
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   164
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   165
  it('Handle GROUP_CREATE_SUCCESS', () => {
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   166
    expect(
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   167
      currentGroup('group1', {
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   168
        type: types.GROUP_CREATE_SUCCESS,
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   169
        group: { name: 'group2' }
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   170
      })
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   171
    ).toEqual('group2');
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   172
  });
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   173
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   174
  it('Handle GROUP_SET_GROUP', () => {
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   175
    expect(
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   176
      currentGroup('group1', {
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   177
        type: types.GROUP_SET_GROUP,
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   178
        group: 'group2'
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   179
      })
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   180
    ).toEqual('group2');
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   181
  });
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   182
});
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   183
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   184
describe('auth reducer token', () => {
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   185
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   186
  it('should return the initial state', () => {
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   187
    expect(
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   188
      token(undefined, {})
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   189
    ).toEqual(null)
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   190
  });
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   191
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   192
  it('Handle AUTH_DEAUTHENTICATE', () => {
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   193
    expect(
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   194
      token('token1', {
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   195
        type: types.AUTH_DEAUTHENTICATE
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   196
      })
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   197
    ).toEqual(null);
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   198
  });
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   199
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   200
  it('Handle AUTH_LOGOUT', () => {
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   201
    expect(
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   202
      token('token1', {
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   203
        type: types.AUTH_LOGOUT
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   204
      })
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   205
    ).toEqual(null);
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   206
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   207
  });
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   208
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   209
  it('Handle AUTH_STORE_TOKEN', () => {
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   210
    expect(
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   211
      token(null, {
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   212
        type: types.AUTH_STORE_TOKEN,
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   213
        token: 'token1'
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   214
      })
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   215
    ).toEqual('token1');
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   216
  });
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   217
});
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   218
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   219
describe('auth reducer clientId', () => {
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   220
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   221
  it('should return the initial state', () => {
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   222
    expect(
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   223
      clientId(undefined, {})
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   224
    ).toEqual(null)
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   225
  });
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   226
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   227
  it('Handle AUTH_DEAUTHENTICATE', () => {
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   228
    expect(
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   229
      clientId(uuidV1(), {
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   230
        type: types.AUTH_DEAUTHENTICATE
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   231
      })
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   232
    ).toEqual(null);
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   233
  });
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   234
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   235
  it('Handle AUTH_LOGOUT', () => {
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   236
    expect(
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   237
      clientId(uuidV1(), {
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   238
        type: types.AUTH_LOGOUT
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   239
      })
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   240
    ).toEqual(null);
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   241
  });
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   242
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   243
  it('Handle AUTH_LOGIN_SUCCESS', () => {
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   244
    expect(
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   245
      clientId(uuidV1(), {
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   246
        type: types.AUTH_LOGIN_SUCCESS
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   247
      })
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   248
    ).toMatch(/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i);
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   249
  });
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   250
});
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   251
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   252
describe('auth reducer login', () => {
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   253
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   254
  it('should return the initial state', () => {
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   255
    expect(
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   256
      login(undefined, {})
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   257
    ).toEqual(asyncRequest)
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   258
  });
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   259
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   260
  it('Handle AUTH_LOGIN_REQUEST', () => {
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   261
    expect(
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   262
      login(asyncRequest, {
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   263
        type: types.AUTH_LOGIN_REQUEST,
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   264
      })
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   265
    ).toEqual({
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   266
      loading: true,
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   267
      success: false,
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   268
      error: false,
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   269
    });
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   270
  });
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   271
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   272
  it('Handle AUTH_LOGIN_SUCCESS', () => {
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   273
    expect(
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   274
      login(asyncRequest, {
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   275
        type: types.AUTH_LOGIN_SUCCESS,
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   276
      })
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   277
    ).toEqual({
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   278
      loading: false,
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   279
      success: true,
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   280
      error: false,
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   281
      errorMessages: {},
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   282
    });
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   283
  });
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   284
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   285
  it('Handle AUTH_LOGIN_ERROR', () => {
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   286
    expect(
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   287
      login(asyncRequest, {
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   288
        type: types.AUTH_LOGIN_ERROR,
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   289
        error: {
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   290
          msg: "Bad credential"
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   291
        }
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   292
      })
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   293
    ).toEqual({
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   294
      loading: false,
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   295
      success: false,
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   296
      error: true,
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   297
      errorMessages: { msg: "Bad credential" },
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   298
    });
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   299
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   300
  });
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   301
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   302
});
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   303
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   304
describe('auth reducer register', () => {
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   305
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   306
  it('should return the initial state', () => {
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   307
    expect(
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   308
      register(undefined, {})
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   309
    ).toEqual(asyncRequest)
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   310
  });
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   311
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   312
  it('Handle AUTH_REGISTER_REQUEST', () => {
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   313
    expect(
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   314
      register(asyncRequest, {
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   315
        type: types.AUTH_REGISTER_REQUEST,
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   316
      })
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   317
    ).toEqual({
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   318
      loading: true,
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   319
      success: false,
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   320
      error: false,
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   321
    });
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   322
  });
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   323
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   324
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   325
  it('Handle AUTH_LOGIN_SUCCESS', () => {
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   326
    expect(
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   327
      register(asyncRequest, {
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   328
        type: types.AUTH_LOGIN_SUCCESS,
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   329
      })
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   330
    ).toEqual({
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   331
      loading: false,
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   332
      success: true,
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   333
      error: false,
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   334
      errorMessages: {}
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   335
    });
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   336
  });
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   337
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   338
  it('Handle AUTH_REGISTER_ERROR', () => {
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   339
    expect(
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   340
      register(asyncRequest, {
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   341
        type: types.AUTH_REGISTER_ERROR,
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   342
        error: {
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   343
          msg: 'error when registering'
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   344
        }
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   345
      })
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   346
    ).toEqual({
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   347
      loading: false,
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   348
      success: false,
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   349
      error: true,
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   350
      errorMessages: { msg: 'error when registering' }
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   351
    });
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   352
  });
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   353
});
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   354
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   355
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   356
describe('auth reducer groups', () => {
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   357
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   358
  it('should return the initial state', () => {
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   359
    expect(
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   360
      groups(undefined, {})
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   361
    ).toEqual([])
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   362
  });
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   363
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   364
  it('Handle GROUP_LOAD_SUCCESS', () => {
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   365
    expect(
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   366
      groups([], {
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   367
        type: types.GROUP_LOAD_SUCCESS,
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   368
        groups: [
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   369
          { name: 'group1', is_personal: false },
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   370
          { name: 'jdoe', is_personal: true }
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   371
        ]
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   372
      })
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   373
    ).toEqual([
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   374
      GroupRecord({ name: 'group1', isPersonal: false }),
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   375
      GroupRecord({ name: 'jdoe', isPersonal: true })
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   376
    ])
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   377
  });
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   378
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   379
  it('Handle GROUP_CREATE_SUCCESS', () => {
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   380
    expect(
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   381
      groups([
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   382
        GroupRecord({ name: 'group1', isPersonal: false }),
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   383
        GroupRecord({ name: 'jdoe', isPersonal: true })
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   384
      ], {
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   385
        type: types.GROUP_CREATE_SUCCESS,
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   386
        group: { name: 'newGroup', is_personal: false },
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   387
      })
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   388
    ).toEqual([
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   389
      GroupRecord({ name: 'group1', isPersonal: false }),
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   390
      GroupRecord({ name: 'jdoe', isPersonal: true }),
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   391
      GroupRecord({ name: 'newGroup', isPersonal: false }),
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   392
    ])
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   393
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   394
  });
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   395
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   396
  it('Handle AUTH_LOGOUT', () => {
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   397
    expect(
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   398
      groups([
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   399
        GroupRecord({ name: 'group1', isPersonal: false }),
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   400
        GroupRecord({ name: 'jdoe', isPersonal: true })
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   401
      ], {
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   402
        type: types.AUTH_LOGOUT,
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   403
      })
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   404
    ).toEqual([])
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   405
  });
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   406
});
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   407
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   408
describe('auth reducer createGroup', () => {
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   409
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   410
  it('should return the initial state', () => {
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   411
    expect(
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   412
      createGroup(undefined, {})
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   413
    ).toEqual(asyncRequest)
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   414
  });
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   415
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   416
  it('Handle GROUP_CREATE_ASYNC', () => {
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   417
  });
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   418
  it('Handle GROUP_CREATE_SUCCESS', () => {
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   419
  });
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   420
  it('Handle GROUP_CREATE_ERROR', () => {
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   421
  });
ea92f4fe783d - move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
diff changeset
   422
});