<commit_before>import fetchMock from 'fetch-mock'
import { fetchUser } from '../effects'
import { setLoading, setUser as setDisplayedUser } from '../reducer'
import User from '../../record'

// Prepare test data
const self = new User({ id: 42, username: 'IamMe' })
const other = new User({ id: 55, username: 'OtherUser' })
fetchMock.get('http://test/users/me', self)
fetchMock.get(`http://test/users/username/${other.username}`, other.toJS())

test('fetch other user', () => {
  const dispatchMock = jest.fn()
  const getStateMock = () => ({})

  fetchMock.reset()
  fetchUser(other.username)(dispatchMock, getStateMock).then(() => {
    // Start by dispatching isLoading
    expect(dispatchMock.mock.calls[0][0]).toEqual(setLoading(true))

    // Set displayed user
    expect(dispatchMock.mock.calls[1][0]).toEqual(setDisplayedUser(other.toJS()))

    // There are no other dispatch
    expect(dispatchMock.mock.calls.length).toEqual(2)
  })
})<commit_msg>deps(react): fix test after update<commit_after>import fetchMock from 'fetch-mock'
import { fetchUser } from '../effects'
import { setLoading, setUser as setDisplayedUser } from '../reducer'
import User from '../../record'

// Prepare test data
const self = new User({ id: 42, username: 'IamMe' })
const other = new User({ id: 55, username: 'OtherUser' })

test('fetch other user', () => {
  const dispatchMock = jest.fn()
  const getStateMock = () => ({})

  fetchMock.get('http://test/users/me', self)
  fetchMock.get(`http://test/users/username/${other.username}`, other.toJS())
  fetchUser(other.username)(dispatchMock, getStateMock).then(() => {
    // Start by dispatching isLoading
    expect(dispatchMock.mock.calls[0][0]).toEqual(setLoading(true))

    // Set displayed user
    expect(dispatchMock.mock.calls[1][0]).toEqual(setDisplayedUser(other.toJS()))

    // There are no other dispatch
    expect(dispatchMock.mock.calls.length).toEqual(2)

    fetchMock.reset()
  })
})
{'fraction_non_alphanumeric': 0.17232510288065844, 'fraction_numerical': 0.009259259259259259, 'mean_word_length': 4.256756756756757, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '3308701', 'n_tokens_mistral': 608, 'n_tokens_neox': 606, 'n_words': 140}