Guest User

Untitled

a guest
Dec 12th, 2017
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.99 KB | None | 0 0
  1. import moment from 'moment-timezone';
  2.  
  3. class TimezoneCityItem extends React.Component {
  4.  
  5. componentDidMount(){
  6. this.setState({
  7. time: moment.tz(this.props.timezone)
  8. })
  9. }
  10.  
  11. render(){
  12. return (
  13. <div>{this.state.time.format('HH:mm')}</div>
  14. )
  15. }
  16. }
  17.  
  18. const timezoneList = [
  19. { name: 'los-angeles', title: 'Los Angeles', timezone: 'America/Los_Angeles' },
  20. { name: 'washington', title: 'Washington', timezone: 'America/New_York' },
  21. { name: 'london', title: 'London', timezone: 'Europe/London' },
  22. { name: 'dubai', title: 'Dubai', timezone: 'Asia/Dubai' },
  23. { name: 'hongkong', title: 'Hongkong', timezone: 'Asia/Hong_Kong' },
  24. ];
  25.  
  26. export default timezoneList;
  27.  
  28. import React from 'react';
  29. import { shallow } from 'enzyme';
  30. import TimezoneCityItem from '../TimezoneCity.item';
  31. import timezoneList from '/lib/timezoneListDummyData'; // It just an array list of timezone
  32.  
  33. describe('<TimezoneCityItem />', () => {
  34. test('Should render TimezoneCityItem correctly', () => {
  35. const wrapper = shallow(<TimezoneCityItem {...timezoneList[0]} />);
  36. expect(wrapper).toMatchSnapshot();
  37. });
  38. });
  39.  
  40. "moment": "~2.18.1",
  41. "moment-timezone": "~0.5.13",
  42.  
  43. Test suite failed to run
  44. TypeError: Cannot read property 'split' of undefined
  45.  
  46. at node_modules/moment-timezone/moment-timezone.js:36:34
  47. at Object.<anonymous>.moment (node_modules/moment-timezone/moment-timezone.js:14:20)
  48. at Object.<anonymous> (node_modules/moment-timezone/moment-timezone.js:18:2)
  49. at Object.<anonymous> (node_modules/moment-timezone/index.js:1:120)
  50. at Object.<anonymous> (imports/ui/components/mainLayout/TimezoneCity.item.jsx:3:49)
  51. at Object.<anonymous> (imports/ui/components/mainLayout/TimezoneCity.jsx:3:47)
  52. at Object.<anonymous> (imports/ui/components/mainLayout/MainLayout.jsx:6:47)
  53. at Object.<anonymous> (imports/ui/components/mainLayout/__tests__/MainLayout.test.js:3:19)
  54. at Generator.next (<anonymous>)
  55. at new Promise (<anonymous>)
  56. at Generator.next (<anonymous>)
  57. at <anonymous>
Add Comment
Please, Sign In to add comment