feat(pricing,types,utils): Move calculate pricing query to a repository + rule type validation (#5294)

This commit is contained in:
Riqwan Thamir
2023-10-10 15:05:19 +00:00
committed by GitHub
parent b62af612c7
commit 378ca1b36e
16 changed files with 273 additions and 92 deletions
@@ -343,7 +343,7 @@ describe("PricingModule Service - Calculate Price", () => {
)
expect(result).rejects.toThrow(
"currency_code is a required input in the pricing context"
"Method calculatePrices requires currency_code in the pricing context"
)
result = service.calculatePrices(
@@ -352,7 +352,7 @@ describe("PricingModule Service - Calculate Price", () => {
)
expect(result).rejects.toThrow(
"currency_code is a required input in the pricing context"
"Method calculatePrices requires currency_code in the pricing context"
)
})
@@ -251,5 +251,24 @@ describe("RuleType Service", () => {
})
)
})
it("should throw an error when using one of the reserved keywords", async () => {
let error
try {
await service.create([
{
name: "Test Rule",
rule_attribute: "currency_code",
},
])
} catch (e) {
error = e
}
expect(error.message).toEqual(
"Can't create rule_attribute with reserved keywords [quantity, currency_code, price_list_id] - currency_code"
)
})
})
})