-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2fca9e7
commit 191b9b5
Showing
1 changed file
with
29 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import {getFilteredCars} from './getFilteredCars'; | ||
|
||
test("Passes a car successfully", () => { | ||
const payload = [{mileage: 10, rentalPrice: "20$"}]; | ||
const filter = {minMileage: 5, maxMileage: 15, price: 40}; | ||
expect(getFilteredCars(payload, filter)) | ||
.toEqual(payload); | ||
}); | ||
|
||
test("Handle undefined mileage as no limit", () => { | ||
const payload = [{mileage: 10, rentalPrice: "20$"}]; | ||
const filter = {price: 40}; | ||
expect(getFilteredCars(payload, filter)) | ||
.toEqual(payload); | ||
}); | ||
|
||
test("Handle null mileage as no limit", () => { | ||
const payload = [{mileage: 10, rentalPrice: "20$"}]; | ||
const filter = {minMileage: null, maxMileage: null, price: 40}; | ||
expect(getFilteredCars(payload, filter)) | ||
.toEqual(payload); | ||
}); | ||
|
||
test("Divert a car with non-conforming mileage", () => { | ||
const payload = [{mileage: 10, rentalPrice: "20$"}]; | ||
const filter = {minMileage: 15, maxMileage: 40, price: 40}; | ||
expect(getFilteredCars(payload, filter)) | ||
.toEqual([]); | ||
}); |