<commit_before>import {assert} from 'chai';
import App from '../../app';

describe('Auth', function() {
  let app = App();
  let {parts, store} = app;
  const token = '<KEY>';
  let {actions} = parts.auth;
  let selectState = store => store.getState().auth;
  let isAuthenticated = store => selectState(store).auth.authenticated;
  let getToken = store => selectState(store).auth.token;

  it('setToken', () => {
    assert.isUndefined(getToken(store));
    store.dispatch(actions.setToken(token));
    assert.equal(getToken(store), token);
  });
  it('login', () => {
    store.dispatch(actions.login.ok({token: token}));
    assert.equal(isAuthenticated(store), true);
    assert.equal(getToken(store), token);
  });
  it('logout ok', () => {
    store.dispatch(actions.logout.ok());
    assert.equal(isAuthenticated(store), false);
  });
  it('logout error', () => {
    store.dispatch(actions.login.ok({token: token}));
    store.dispatch(actions.logout.error({status: 401}));
    assert.equal(isAuthenticated(store), false);
    assert.isUndefined(getToken(store));
  });
});<commit_msg>fix unit test due to change in redux-act-async<commit_after>import {assert} from 'chai';
import App from '../../app';

describe('Auth', function() {
  let app = App();
  let {parts, store} = app;
  const token = '<KEY>';
  let {actions} = parts.auth;
  let selectState = store => store.getState().auth;
  let isAuthenticated = store => selectState(store).auth.authenticated;
  let getToken = store => selectState(store).auth.token;

  it('setToken', () => {
    assert.isUndefined(getToken(store));
    store.dispatch(actions.setToken(token));
    assert.equal(getToken(store), token);
  });
  it('login', () => {
    console.log("DISPATCH:", store.getState());

    store.dispatch(actions.login.ok({response: {token: token}}));
    console.log("STORE:", store.getState())
    assert.equal(isAuthenticated(store), true);
    assert.equal(getToken(store), token);
  });
  it('logout ok', () => {
    store.dispatch(actions.logout.ok({response: {}}));
    assert.equal(isAuthenticated(store), false);
  });
  it('logout error', () => {
    store.dispatch(actions.login.ok({response: {token: token}}));
    store.dispatch(actions.logout.error({error: {status: 401}}));
    assert.equal(isAuthenticated(store), false);
    assert.isUndefined(getToken(store));
  });
});
{'fraction_non_alphanumeric': 0.1972846839202376, 'fraction_numerical': 0.002545608824777259, 'mean_word_length': 4.4206896551724135, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1205227', 'n_tokens_mistral': 773, 'n_tokens_neox': 761, 'n_words': 136}