Skip to content

Commit

Permalink
Hit a wall with mounting the component for testing: enzymejs/enzyme#1436
Browse files Browse the repository at this point in the history


Looks like it can be done...but I'll end the rabbit hole here.
  • Loading branch information
acrabb committed Mar 19, 2019
1 parent e12b589 commit a3d4e10
Show file tree
Hide file tree
Showing 3 changed files with 448 additions and 37 deletions.
33 changes: 21 additions & 12 deletions __tests__/CreateReservation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,18 @@
* @lint-ignore-every XPLATJSCOPYRIGHT1
*/

import { configure, mount, shallow } from "enzyme"
import Adapter from "enzyme-adapter-react-16"
import React from "react"
import "react-native"
import CreateReservation from "../src/reservations/screens/CreateReservation"

describe("showing the date picker", () => {
it("renders", () => {
shallow(<CreateReservation />)
})
})

describe("createReservation", () => {
let createScreen: CreateReservation
beforeEach(() => {
Expand Down Expand Up @@ -75,25 +85,24 @@ describe("createReservation", () => {
})

describe("showing the date picker", () => {
let createScreen: CreateReservation
beforeEach(() => {
createScreen = new CreateReservation({})
})
configure({ adapter: new Adapter() })

it("toggles the date picker flag", () => {
createScreen.state = {
clientName: "",
let createScreen = mount<CreateReservation>(<CreateReservation />)

it("toggles the date picker flag", done => {
createScreen.setState(() => ({
clientName: "Paris",
hotelName: "Hilton Hi",
arrivalDate: new Date(),
departureDate: new Date(),
isDateTimePickerVisible: false,
focusedDate: "arrival",
errors: [3],
}
}))

createScreen._showDateTimePicker("departure")
expect(createScreen.state.isDateTimePickerVisible).toBeTruthy()
expect(createScreen.state.focusedDate).toEqual("departure")
expect(createScreen.state.errors).toHaveLength(0)
createScreen.instance()._showDateTimePicker("departure")
expect(createScreen.state().isDateTimePickerVisible).toBeTruthy()
expect(createScreen.state().focusedDate).toEqual("departure")
expect(createScreen.state().errors).toHaveLength(0)
})
})
Loading

0 comments on commit a3d4e10

Please sign in to comment.