Guest User

Untitled

a guest
Feb 15th, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.62 KB | None | 0 0
  1. test("Render Autocomplete Test",async () => {
  2.  
  3. let expectedUnmappedEntityArray = [];
  4.  
  5. let wrapper = shallow(<Map
  6. unmappedArray={[0]}
  7. entity='User'
  8. />);
  9.  
  10. wrapper.instance().state.newMapping[0].selectedEntity = "John Smith(johnS)";
  11. wrapper.instance().state.newMapping[0].permissionsToSave = ['Cashier'];
  12. wrapper.instance().state.newMapping[0].isRemoved = false;
  13.  
  14. wrapper.instance().state.unmappedArray[0] = wrapper.instance().state.newMapping[0];
  15. wrapper.instance().state.unmappedArray[0].selectedEntity = "Will Smith(willS)";
  16.  
  17. wrapper.find('Button').simulate('click'); //Opens the dialog with the autocomplete in it
  18.  
  19. wrapper.find(Dialog).dive().find('Autocomplete').simulate('change',{target:{value:'Will'}});
  20. console.log(wrapper.instance().state.unmappedEntityArray[0].selectedEntity);
  21. wrapper.find(Dialog).dive().find('Autocomplete').simulate('focus');
  22.  
  23.  
  24. });
  25.  
  26. render() {
  27. return (
  28. <div style={{ textAlign: "center" }}>
  29. <br />
  30. <Button primary raised onClick={this.onAddMappingModalShow}>
  31. Add Mapping
  32. </Button>
  33. <br />
  34. <br />
  35. <br />
  36. <Dialog>
  37. <DialogHeader>
  38. Select a {this.state.entity} to map it
  39. </DialogHeader>
  40. <DialogBody scrollable>
  41. <Table>
  42. <thead>
  43. <tr>
  44. <th>{this.state.entity}</th>
  45. <th>Permissions</th>
  46. <th />
  47. </tr>
  48. </thead>
  49. <tbody>
  50. {this.state.addMappingModalOpen &&
  51. this.state.newMapping.map(
  52. (item, index) =>
  53. !item.isRemoved && (
  54. <tr key={"new_mapping_" + index}>
  55. <td>
  56. {this.state.unmappedArray.length > 0 && (
  57. <Autocomplete
  58. label={"Search " + this.state.entity + "..."}
  59. helperText={
  60. <TextFieldHelperText>
  61. Please enter minimum 2 characters
  62. </TextFieldHelperText>
  63. }
  64. minChars={2}
  65. items={this.state.unmappedArray}
  66. value={item.selectedEntity}
  67. onSelected={value => {
  68. console.log('foo');
  69. }}
  70. />
  71. )}
  72. </td>
  73. </tbody>
  74. </Table>
  75. </DialogBody>
  76.  
  77. </span>
  78. </div>
  79. </DialogFooter>
  80. </Dialog>
  81. </div>
  82. );
Add Comment
Please, Sign In to add comment