Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //__tests__/user-list-test.js
- import React, {addons} from 'react/addons'
- import UserList from '../user-list'
- const tu = addons.TestUtils
- const fakeUsers = [
- {
- id: 1,
- name: 'user 1'
- },
- {
- id: 2,
- name: 'user 2'
- },
- {
- id: 3,
- name: 'user 3'
- },
- {
- id: 4,
- name: 'user 4'
- }
- ]
- jest.dontMock('../user-list.js')
- jest.dontMock('../user.js')
- describe('user-list-test', () => {
- it('should generate valid user list', () => {
- const fakeQueryParams = {
- currentId: 1,
- error: {
- message: ''
- }
- }
- const userList = tu.renderIntoDocument(
- <UserList users={fakeUsers} queryParams={fakeQueryParams}/>
- )
- expect(document.querySelector('.user-name-1').textContext).toEqual('user 1');
- })
- })
- /*
- 1. Without dom emulation: how to provide fakeQueryParams and reproduce state of UserList without rendering into document (componentWillMount not called)
- 2. With dom emulation: Mocking fetch in UserList is right way ?
- 3. How to change UserList state without fetching new users. We don't use setState, only setQueryParams ?
- 4. How to do onUserDelete action right way in relay paradigm, without flux actions/stores
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement