feat(flight-finder): implement milestone M2 - report workflow and delivery gates
This commit is contained in:
38
skills/flight-finder/tests/price-normalization.test.ts
Normal file
38
skills/flight-finder/tests/price-normalization.test.ts
Normal file
@@ -0,0 +1,38 @@
|
||||
import test from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
|
||||
import { normalizePriceToUsd } from "../src/price-normalization.js";
|
||||
|
||||
test("normalizePriceToUsd passes through USD values", () => {
|
||||
const result = normalizePriceToUsd({
|
||||
amount: 2847,
|
||||
currency: "USD"
|
||||
});
|
||||
|
||||
assert.equal(result.amountUsd, 2847);
|
||||
assert.equal(result.currency, "USD");
|
||||
});
|
||||
|
||||
test("normalizePriceToUsd converts foreign currencies when a rate is supplied", () => {
|
||||
const result = normalizePriceToUsd({
|
||||
amount: 100,
|
||||
currency: "EUR",
|
||||
exchangeRates: {
|
||||
EUR: 1.08
|
||||
}
|
||||
});
|
||||
|
||||
assert.equal(result.amountUsd, 108);
|
||||
assert.match(result.notes.join(" "), /EUR/i);
|
||||
});
|
||||
|
||||
test("normalizePriceToUsd rejects missing exchange rates", () => {
|
||||
assert.throws(
|
||||
() =>
|
||||
normalizePriceToUsd({
|
||||
amount: 100,
|
||||
currency: "EUR"
|
||||
}),
|
||||
/exchange rate/i
|
||||
);
|
||||
});
|
||||
Reference in New Issue
Block a user