@hoepel.app/isomorphic-domain
Advanced tools
Comparing version 0.3.31 to 0.3.32
@@ -22,2 +22,3 @@ import { Price } from '@hoepel.app/types'; | ||
static createAbsoluteDiscount(name: string, price: Price): Discount; | ||
static sorted(discounts: readonly Discount[]): readonly Discount[]; | ||
/** | ||
@@ -24,0 +25,0 @@ * Apply a list of discounts to a price. The discounts will be applied in the array order. |
@@ -33,2 +33,5 @@ "use strict"; | ||
} | ||
static sorted(discounts) { | ||
return [...discounts].sort((a, b) => a.name.localeCompare(b.name)); | ||
} | ||
/** | ||
@@ -35,0 +38,0 @@ * Apply a list of discounts to a price. The discounts will be applied in the array order. |
@@ -84,2 +84,18 @@ "use strict"; | ||
}); | ||
describe('sorted', () => { | ||
it('sorts discounts', () => { | ||
const discounts = [ | ||
relativeDiscount, | ||
absoluteDiscount, | ||
discount_1.Discount.createRelativeDiscount('Test', 0), | ||
discount_1.Discount.createRelativeDiscount('Blah', 0), | ||
]; | ||
expect(discount_1.Discount.sorted(discounts).map((d) => d.name)).toEqual([ | ||
'Blah', | ||
'Kansentarief', | ||
'Test', | ||
'Tweede kind', | ||
]); | ||
}); | ||
}); | ||
describe('isRelativeDiscount', () => { | ||
@@ -86,0 +102,0 @@ it('true for relative discount', () => { |
{ | ||
"name": "@hoepel.app/isomorphic-domain", | ||
"version": "0.3.31", | ||
"version": "0.3.32", | ||
"main": "dist/index.js", | ||
@@ -25,3 +25,3 @@ "license": "GPL-3.0-or-later", | ||
}, | ||
"gitHead": "2873c47cf936e01ca3e896e28c3f757971815130" | ||
"gitHead": "f578235b578c004b8f57bda6fb755d0b68ab1982" | ||
} |
@@ -119,2 +119,20 @@ import { Discount } from './discount' | ||
describe('sorted', () => { | ||
it('sorts discounts', () => { | ||
const discounts = [ | ||
relativeDiscount, | ||
absoluteDiscount, | ||
Discount.createRelativeDiscount('Test', 0), | ||
Discount.createRelativeDiscount('Blah', 0), | ||
] | ||
expect(Discount.sorted(discounts).map((d) => d.name)).toEqual([ | ||
'Blah', | ||
'Kansentarief', | ||
'Test', | ||
'Tweede kind', | ||
]) | ||
}) | ||
}) | ||
describe('isRelativeDiscount', () => { | ||
@@ -121,0 +139,0 @@ it('true for relative discount', () => { |
@@ -51,2 +51,6 @@ import { Price } from '@hoepel.app/types' | ||
static sorted(discounts: readonly Discount[]): readonly Discount[] { | ||
return [...discounts].sort((a, b) => a.name.localeCompare(b.name)) | ||
} | ||
/** | ||
@@ -53,0 +57,0 @@ * Apply a list of discounts to a price. The discounts will be applied in the array order. |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1516827
6139