Advertisement
Guest User

Untitled

a guest
Oct 2nd, 2017
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.38 KB | None | 0 0
  1. import { expect } from 'chai';
  2. import React from 'react';
  3. import AddDeviceForm from '../../../../bundles/Point/components/devices/add/AddDeviceForm';
  4.  
  5. import {
  6. mockStore,
  7. renderComponent
  8. } from '../../../TestHelper';
  9. import { state } from './mockState';
  10.  
  11. describe('<AddDeviceForm />', () => {
  12.  
  13. let component;
  14.  
  15. const submit = (values) => {
  16. const { userId } = this.props;
  17.  
  18. if (values.hwtype === 'ANDROID') {
  19. values.temp_gprs_roaming_block = false;
  20. values.gprs_operator_id = '';
  21. }
  22.  
  23. return this.props.createDevice(
  24. userId,
  25. values,
  26. ).then(
  27. resp => {
  28. if (resp.type === 'DEVICE_CREATED') {
  29. this.context.router.history.goBack();
  30. this.props.addFlashMessage({
  31. type: 'success',
  32. text: 'Device created successfully'
  33. });
  34. } else if (resp.type === 'DEVICE_CREATE_FAILED') {
  35. const error = resp.payload.error[0].detail;
  36. return Promise.reject(new SubmissionError(error));
  37. }
  38. })
  39. };
  40. beforeEach(() => {
  41. const props = {
  42. gprsOperators: [
  43. {
  44. apn: 'Something',
  45. dns_1: 'Dns1',
  46. dns_2: 'Dns2',
  47. id: '1',
  48. name: 'First Operator',
  49. password: 'Hello',
  50. username: 'Hello'
  51. },
  52. {
  53. apn:'Something',
  54. dns_1: 'Dns1',
  55. dns_2: 'Dns2',
  56. id: '2',
  57. name: 'Second Operator',
  58. password: 'Hello',
  59. username: 'Hello'
  60. },
  61. {
  62. apn: 'Something',
  63. dns_1: 'Dns1',
  64. dns_2: 'Dns2',
  65. id: '3',
  66. name: 'Third operator',
  67. password: 'Hello',
  68. username: 'Hello'
  69. }
  70. ],
  71. onSubmit: submit,
  72. initialValues: {
  73. name: 'HELLO',
  74. mptp_id: 'HELLO',
  75. phone_number: 'HELLO',
  76. temp_imei: 'HELLO',
  77. gprs_operator_id: 'HELLO',
  78. temp_gprs_roaming_block: 'HELLO'
  79. }
  80. };
  81.  
  82. component = renderComponent(AddDeviceForm, mockStore(state), props);
  83. });
  84.  
  85. it(`Should be disable 'GPRS operator'`, () => {
  86. expect(component.find('div').at(5).find('select').prop('disabled')).to.eql(true);
  87. });
  88.  
  89. it(`Should be disable 'International Roaming Block'`, () => {
  90. expect(component.find('div').at(6).find('input').prop('disabled')).to.eql(true);
  91. });
  92.  
  93. it(`TEST`, () => {
  94. expect(component.find('div').at(0).find('input').prop('value')).to.eql('lol');
  95. });
  96.  
  97. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement