Created
June 23, 2020 15:36
-
-
Save ihorkatkov/a217ab1dd1781dd27c7863d1cb5c72af to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
test "invalidates some quotes when parcel dimensions cannot be handled by a vehicle type", %{ | |
bypass: bypass | |
} do | |
Bypass.expect(bypass, "POST", "/v1/commercial-api/get-a-quote", fn conn -> | |
Conn.resp(conn, 200, Jason.encode!(Fixtures.Gophr.quotes_success_response(40))) | |
end) | |
pending_quotes = | |
[:bicycle, :bicycle_cargo, :motorcycle, :car, :van_small, :van] | |
|> Enum.map(&generate_quote/1) | |
parcel_dimensions = %{ | |
"height_cm" => 60, | |
"length_cm" => 50, | |
"width_cm" => 50, | |
"weight_kg" => 10 | |
} | |
route = | |
Factory.build(:route, | |
parcel_dimensions: parcel_dimensions, | |
schedule: :urgent | |
) | |
assert {valid_quotes, invalid_quotes} = QuotesValidator.validate(pending_quotes, route) | |
assert [:van_small, :van] = Enum.map(valid_quotes, &Map.get(&1, :transport_type)) | |
assert [:bicycle, :bicycle_cargo, :motorcycle, :car] = | |
Enum.map(invalid_quotes, &Map.get(&1, :transport_type)) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment