Skip to content
This repository has been archived by the owner on Mar 10, 2022. It is now read-only.

Commit

Permalink
(pC-1573) fixed drag of lat
Browse files Browse the repository at this point in the history
  • Loading branch information
Ledoux committed May 1, 2019
1 parent 237f6de commit a4204dd
Show file tree
Hide file tree
Showing 2 changed files with 88 additions and 7 deletions.
7 changes: 4 additions & 3 deletions src/components/pages/Venue/GeoFields/Address.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,10 @@ class Address extends Component {
onMarkerDragend = () => {
const { onMarkerDragend } = this.props
const {
latitude,
longitude,
lat: latitude,
lng: longitude,
} = this.refmarker.current.leafletElement.getLatLng()

this.setState({
marker: {
latitude,
Expand Down Expand Up @@ -111,7 +112,7 @@ class Address extends Component {
latitude,
longitude,
postalCode,
selectedAddress: address,
selectedAddress: null,
})
return
}
Expand Down
88 changes: 84 additions & 4 deletions src/components/pages/Venue/tests/Venue.spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -325,8 +325,13 @@ describe('src | components | pages | Venue', () => {
)

setTimeout(() => {
// when (offerer request is done, form is now available)
// then (offerer request is done, form is now available)
wrapper.update()
expect(
wrapper.find("textarea[name='comment']").props().required
).toEqual(true)

// when
wrapper
.find("input[name='bookingEmail']")
.simulate('change', { target: { value: BOOKING_EMAIL } })
Expand All @@ -335,6 +340,27 @@ describe('src | components | pages | Venue', () => {
.simulate('change', { target: { value: SIRET } })

setTimeout(() => {
// then
expect(
wrapper.find("textarea[name='comment']").props().required
).toEqual(false)

expect(
wrapper.find("input[name='address']").props().readOnly
).toEqual(true)
expect(wrapper.find("input[name='city']").props().readOnly).toEqual(
true
)
expect(
wrapper.find("input[name='postalCode']").props().readOnly
).toEqual(true)
//expect(wrapper
// .find("input[name='latitude']")
// .props().readOnly).toEqual(true)
//expect(wrapper
// .find("input[name='longitude']")
// .props().readOnly).toEqual(true)

// when (siret has filled other inputs, submit button is not anymore disabled)
wrapper.update()
const submitButton = wrapper.find('button[type="submit"]')
Expand Down Expand Up @@ -370,6 +396,9 @@ describe('src | components | pages | Venue', () => {
})
})

/* TODO */
it.skip('reputs geo fields to not readonly mode when we delete the siret', () => ({}))

it('fills the form with a valid address', done => {
// given
const { store } = configureStore()
Expand Down Expand Up @@ -412,8 +441,22 @@ describe('src | components | pages | Venue', () => {
onSelect(value, item)

setTimeout(() => {
// when (address has filled other inputs, submit button is not anymore disabled)
// then (address has filled other inputs)
wrapper.update()
expect(wrapper.find("input[name='city']").props().readOnly).toEqual(
true
)
expect(
wrapper.find("input[name='postalCode']").props().readOnly
).toEqual(true)
expect(
wrapper.find("input[name='latitude']").props().readOnly
).toEqual(true)
expect(
wrapper.find("input[name='longitude']").props().readOnly
).toEqual(true)

// when
const submitButton = wrapper.find('button[type="submit"]')
expect(submitButton.props().disabled).toEqual(false)
submitButton.simulate('submit')
Expand Down Expand Up @@ -450,6 +493,9 @@ describe('src | components | pages | Venue', () => {
})
})

/* TODO */
it.skip('reputs geo fields to not readonly mode when we delete the address', () => ({}))

it('fills the form with valid coordinates (even if they are negative)', done => {
// given
const { store } = configureStore()
Expand Down Expand Up @@ -487,8 +533,25 @@ describe('src | components | pages | Venue', () => {
.simulate('change', { target: { value: LONGITUDE } })

setTimeout(() => {
// when (address has filled other inputs, submit button is not anymore disabled)
// then (address has filled other inputs, submit button is not anymore disabled)
wrapper.update()
expect(
wrapper.find("input[name='address']").props().readOnly
).toEqual(false)
expect(wrapper.find("input[name='city']").props().readOnly).toEqual(
false
)
expect(
wrapper.find("input[name='postalCode']").props().readOnly
).toEqual(false)
expect(
wrapper.find("input[name='latitude']").props().readOnly
).toEqual(false)
expect(
wrapper.find("input[name='longitude']").props().readOnly
).toEqual(false)

// when
const submitButton = wrapper.find('button[type="submit"]')
expect(submitButton.props().disabled).toEqual(false)
submitButton.simulate('submit')
Expand Down Expand Up @@ -542,8 +605,25 @@ describe('src | components | pages | Venue', () => {
)

setTimeout(() => {
// when (offerer request is done, form is now available)
// then (address has filled other inputs, submit button is not anymore disabled)
wrapper.update()
expect(wrapper.find("input[name='address']").props().readOnly).toEqual(
false
)
expect(wrapper.find("input[name='city']").props().readOnly).toEqual(
false
)
expect(
wrapper.find("input[name='postalCode']").props().readOnly
).toEqual(false)
expect(wrapper.find("input[name='latitude']").props().readOnly).toEqual(
false
)
expect(
wrapper.find("input[name='longitude']").props().readOnly
).toEqual(false)

// when
wrapper
.find("input[name='name']")
.simulate('change', { target: { value: NAME } })
Expand Down

0 comments on commit a4204dd

Please sign in to comment.