Guest User

Untitled

a guest
Jun 23rd, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.92 KB | None | 0 0
  1. import React from 'react'
  2. import ReactDOM from 'react-dom'
  3.  
  4. // TODO : I tried to make enzyme work here, but the menu attaches two
  5. // event handlers on keyup and mouseup to tell when the user has
  6. // clicked off or pressed escape and submenus need to be closed.
  7. // When running from Enzyme mount(), document didn't see to exist?
  8. // import {mount} from 'enzyme'
  9.  
  10. import ZukeeperApp from '../src/zuKeeperApp'
  11. import {mockTestData, removeAllTestDataMocks} from './lib/helpers'
  12.  
  13. const Adapter = require('enzyme-adapter-react-16')
  14. const Enzyme = require('enzyme')
  15. Enzyme.configure({adapter: new Adapter()})
  16.  
  17. // <div id='testBody/> is added to the DOM by testRunner.js
  18. const testBodyEl = document.getElementById('testBody')
  19.  
  20.  
  21. describe('with application context data', () => {
  22.  
  23. describe('and rendered with functional child', () => {
  24. // eslint-disable-next-line
  25. let wrapper = null // it is used in tests when enzyme is used
  26.  
  27. before(done => {
  28. mockTestData('get', '/applicationContext/getApplicationContext', 'applicationContext.json')
  29. mockTestData('get', '/mainMenu/menu.json', 'zuKeeperMenu.json')
  30. mockTestData('get', /\/workflow\/tasks.*/, 'workflowTasks.json')
  31. // wrapper = mount(
  32. wrapper = ReactDOM.render(
  33. <ZukeeperApp onUserAuthenticated={done}>
  34. {
  35. (applicationContext, currentUser) => {
  36. return (
  37. <h5>Hi {currentUser.fullName}, I am your next life changing zuKeeper App!</h5>
  38. )
  39. }
  40. }
  41. </ZukeeperApp>,
  42. testBodyEl,
  43. )
  44. })
  45.  
  46. it('renders a functional child', () => {
  47. expect(testBodyEl.innerHTML).to.contain('zuKeeper App')
  48. })
  49.  
  50. it('should have rendered the user name', () => {
  51. // see test/data/applicationContext.json
  52. expect(testBodyEl.innerHTML).to.contain('Zaphod')
  53. })
  54.  
  55. after(() => {
  56. removeAllTestDataMocks()
  57. })
  58. }) // and rendered...
  59.  
  60. }) // with context...
Add Comment
Please, Sign In to add comment