Skip to content

Commit

Permalink
refactor(services): change parameters from complete state to uuid and…
Browse files Browse the repository at this point in the history
… coordinates
  • Loading branch information
tuliooassis committed Jun 30, 2020
1 parent 2c6f5b8 commit 0960594
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
6 changes: 6 additions & 0 deletions src/services/__mocks__/parkings.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,9 @@ export const createParkingReport = (parkingReportState, version = 1) =>
(resolve) => resolve(resolvedValue),
(reject) => reject(rejectedValue)
)

export const completeParkingReport = (parkingReportState, version = 1) =>
new Promise(
(resolve) => resolve(resolvedValue),
(reject) => reject(rejectedValue)
)
6 changes: 3 additions & 3 deletions src/services/parkings.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ export const createParkingReport = (parkingReportState, version = 1) => {
return Api().post(`/v${version}/parkings/`, formData)
}

export const completeParkingReport = (parkingReportState, version = 1) => {
export const completeParkingReport = (uuid, coordinates, version = 1) => {
const request = {
uuid: parkingReportState["uuid"],
coordinates: parkingReportState["currentPosition"],
uuid,
coordinates,
}

return Api().patch(`/v${version}/parkings/`, request)
Expand Down
13 changes: 4 additions & 9 deletions src/services/parkings.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,20 +47,15 @@ describe("Parkings API", () => {

it("should call parkings API patch with the coordinates", () => {
const uuid = "uuid"
const currentPosition = "-LAT,+LNG"
const coordinates = "-LAT,+LNG"

const parkingReportState = {
uuid,
currentPosition,
}

completeParkingReport(parkingReportState, version)
completeParkingReport(uuid, coordinates, version)

expect(Api().patch).toHaveBeenCalledWith(
`/v${version}/parkings/`,
expect.objectContaining({
uuid: uuid,
coordinates: currentPosition,
uuid,
coordinates,
})
)
})
Expand Down

0 comments on commit 0960594

Please sign in to comment.