|
|
@@ -1,5 +1,4 @@
|
|
|
import { Test } from '@nestjs/testing';
|
|
|
-import { ConfigArgType } from '@vendure/common/lib/generated-types';
|
|
|
import { Omit } from '@vendure/common/lib/omit';
|
|
|
import { Connection } from 'typeorm';
|
|
|
|
|
|
@@ -138,7 +137,7 @@ describe('OrderCalculator', () => {
|
|
|
});
|
|
|
|
|
|
const orderTotalCondition = new PromotionCondition({
|
|
|
- args: { minimum: ConfigArgType.MONEY },
|
|
|
+ args: { minimum: { type: 'int' } },
|
|
|
code: 'order_total_condition',
|
|
|
description: '',
|
|
|
check(order, args) {
|
|
|
@@ -190,7 +189,7 @@ describe('OrderCalculator', () => {
|
|
|
conditions: [
|
|
|
{
|
|
|
code: orderTotalCondition.code,
|
|
|
- args: [{ name: 'minimum', type: ConfigArgType.MONEY, value: '100' }],
|
|
|
+ args: [{ name: 'minimum', type: 'int', value: '100' }],
|
|
|
},
|
|
|
],
|
|
|
promotionConditions: [orderTotalCondition],
|
|
|
@@ -222,7 +221,7 @@ describe('OrderCalculator', () => {
|
|
|
|
|
|
it('interaction between promotions', async () => {
|
|
|
const orderQuantityCondition = new PromotionCondition({
|
|
|
- args: { minimum: ConfigArgType.INT },
|
|
|
+ args: { minimum: { type: 'int' } },
|
|
|
code: 'order_quantity_condition',
|
|
|
description: 'Passes if any order line has at least the minimum quantity',
|
|
|
check(_order, args) {
|
|
|
@@ -237,7 +236,7 @@ describe('OrderCalculator', () => {
|
|
|
|
|
|
const orderPercentageDiscount = new PromotionOrderAction({
|
|
|
code: 'order_percentage_discount',
|
|
|
- args: { discount: ConfigArgType.PERCENTAGE },
|
|
|
+ args: { discount: { type: 'int' } },
|
|
|
execute(_order, args) {
|
|
|
return -_order.subTotal * (args.discount / 100);
|
|
|
},
|
|
|
@@ -250,14 +249,14 @@ describe('OrderCalculator', () => {
|
|
|
conditions: [
|
|
|
{
|
|
|
code: orderQuantityCondition.code,
|
|
|
- args: [{ name: 'minimum', type: ConfigArgType.INT, value: '3' }],
|
|
|
+ args: [{ name: 'minimum', type: 'int', value: '3' }],
|
|
|
},
|
|
|
],
|
|
|
promotionConditions: [orderQuantityCondition],
|
|
|
actions: [
|
|
|
{
|
|
|
code: orderPercentageDiscount.code,
|
|
|
- args: [{ name: 'discount', type: ConfigArgType.PERCENTAGE, value: '50' }],
|
|
|
+ args: [{ name: 'discount', type: 'int', value: '50' }],
|
|
|
},
|
|
|
],
|
|
|
promotionActions: [orderPercentageDiscount],
|
|
|
@@ -269,14 +268,14 @@ describe('OrderCalculator', () => {
|
|
|
conditions: [
|
|
|
{
|
|
|
code: orderTotalCondition.code,
|
|
|
- args: [{ name: 'minimum', type: ConfigArgType.MONEY, value: '100' }],
|
|
|
+ args: [{ name: 'minimum', type: 'int', value: '100' }],
|
|
|
},
|
|
|
],
|
|
|
promotionConditions: [orderTotalCondition],
|
|
|
actions: [
|
|
|
{
|
|
|
code: orderPercentageDiscount.code,
|
|
|
- args: [{ name: 'discount', type: ConfigArgType.PERCENTAGE, value: '10' }],
|
|
|
+ args: [{ name: 'discount', type: 'int', value: '10' }],
|
|
|
},
|
|
|
],
|
|
|
promotionActions: [orderPercentageDiscount],
|