Advertisement
Guest User

Untitled

a guest
May 26th, 2015
213
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. //__tests__/user-list-test.js
  2. import React, {addons} from 'react/addons'
  3. import UserList from '../user-list'
  4. const tu = addons.TestUtils
  5.  
  6. const fakeUsers = [
  7. {
  8. id: 1,
  9. name: 'user 1'
  10. },
  11. {
  12. id: 2,
  13. name: 'user 2'
  14. },
  15. {
  16. id: 3,
  17. name: 'user 3'
  18. },
  19. {
  20. id: 4,
  21. name: 'user 4'
  22. }
  23. ]
  24.  
  25. jest.dontMock('../user-list.js')
  26. jest.dontMock('../user.js')
  27.  
  28. describe('user-list-test', () => {
  29. it('should generate valid user list', () => {
  30. const fakeQueryParams = {
  31. currentId: 1,
  32. error: {
  33. message: ''
  34. }
  35. }
  36. const userList = tu.renderIntoDocument(
  37. <UserList users={fakeUsers} queryParams={fakeQueryParams}/>
  38. )
  39. expect(document.querySelector('.user-name-1').textContext).toEqual('user 1');
  40. })
  41. })
  42.  
  43. /*
  44. 1. Without dom emulation: how to provide fakeQueryParams and reproduce state of UserList without rendering into document (componentWillMount not called)
  45. 2. With dom emulation: Mocking fetch in UserList is right way ?
  46. 3. How to change UserList state without fetching new users. We don't use setState, only setQueryParams ?
  47. 4. How to do onUserDelete action right way in relay paradigm, without flux actions/stores
  48. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement