Skip to content

Commit

Permalink
test: refactored
Browse files Browse the repository at this point in the history
  • Loading branch information
AbleKSaju committed Nov 28, 2024
1 parent ede6f3f commit 527a383
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 38 deletions.
2 changes: 1 addition & 1 deletion models/baseModels/tests/testCouponCodes.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ test('disabled coupon codes is not applied', async (t) => {

await sinv.runFormulas();

t.equal(sinv.pricingRuleDetail?.length, undefined);
t.equal(sinv.pricingRuleDetail?.length, 0);
});

test('Coupon code not created: coupons min amount must be lesser than coupons max.', async (t) => {
Expand Down
46 changes: 9 additions & 37 deletions models/baseModels/tests/testPricingRule.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ test('pricing rule is not applied when item qty is < min qty', async (t) => {
await sinv.append('items', { item: itemMap.Jacket.name, quantity: 3 });
await sinv.runFormulas();

t.equal(sinv.pricingRuleDetail?.length, undefined);
t.equal(sinv.pricingRuleDetail?.length, 0);
});

test('pricing rule is not applied when item qty is > max qty', async (t) => {
Expand All @@ -158,7 +158,7 @@ test('pricing rule is not applied when item qty is > max qty', async (t) => {
await sinv.append('items', { item: itemMap.Jacket.name, quantity: 10 });
await sinv.runFormulas();

t.equal(sinv.pricingRuleDetail?.length, undefined);
t.equal(sinv.pricingRuleDetail?.length, 0);
});

test('pricing rule is applied when filtered by min and max amount', async (t) => {
Expand Down Expand Up @@ -200,11 +200,7 @@ test('Pricing Rule is not applied when item amount is < min amount', async (t)
});
await sinv.runFormulas();

t.equal(
sinv.pricingRuleDetail?.length,
undefined,
'Pricing Rule is not applied'
);
t.equal(sinv.pricingRuleDetail?.length, 0, 'Pricing Rule is not applied');
});

test('Pricing Rule is not applied when item amount is > max amount', async (t) => {
Expand All @@ -220,11 +216,7 @@ test('Pricing Rule is not applied when item amount is > max amount', async (t) =
});
await sinv.runFormulas();

t.equal(
sinv.pricingRuleDetail?.length,
undefined,
'Pricing Rule is not applied'
);
t.equal(sinv.pricingRuleDetail?.length, 0, 'Pricing Rule is not applied');
});

test('Pricing Rule is not applied when sinvDate < validFrom date', async (t) => {
Expand All @@ -240,11 +232,7 @@ test('Pricing Rule is not applied when sinvDate < validFrom date', async (t) =>
});
await sinv.runFormulas();

t.equal(
sinv.pricingRuleDetail?.length,
undefined,
'Pricing Rule is not applied'
);
t.equal(sinv.pricingRuleDetail?.length, 0, 'Pricing Rule is not applied');
});

test('Pricing Rule is not applied when sinvDate > validFrom date', async (t) => {
Expand All @@ -260,11 +248,7 @@ test('Pricing Rule is not applied when sinvDate > validFrom date', async (t) =>
});
await sinv.runFormulas();

t.equal(
sinv.pricingRuleDetail?.length,
undefined,
'Pricing Rule is not applied'
);
t.equal(sinv.pricingRuleDetail?.length, 0, 'Pricing Rule is not applied');
});

test('Pricing Rule is applied when filtered by qty, amount and dates', async (t) => {
Expand Down Expand Up @@ -320,11 +304,7 @@ test('Pricing Rule is not applied when qty condition is false, rest is true', as
});
await sinv.runFormulas();

t.equal(
sinv.pricingRuleDetail?.length,
undefined,
'Pricing Rule is not applied'
);
t.equal(sinv.pricingRuleDetail?.length, 0, 'Pricing Rule is not applied');
});

test('Pricing Rule is not applied when amount condition is false, rest is true', async (t) => {
Expand All @@ -340,11 +320,7 @@ test('Pricing Rule is not applied when amount condition is false, rest is true',
});
await sinv.runFormulas();

t.equal(
sinv.pricingRuleDetail?.length,
undefined,
'Pricing Rule is not applied'
);
t.equal(sinv.pricingRuleDetail?.length, 0, 'Pricing Rule is not applied');
});

test('Pricing Rule is not applied when validity condition is false, rest is true', async (t) => {
Expand All @@ -360,11 +336,7 @@ test('Pricing Rule is not applied when validity condition is false, rest is true
});
await sinv.runFormulas();

t.equal(
sinv.pricingRuleDetail?.length,
undefined,
'Pricing Rule is not applied'
);
t.equal(sinv.pricingRuleDetail?.length, 0, 'Pricing Rule is not applied');
});

test('create two pricing rules, Highest priority pricing rule is applied', async (t) => {
Expand Down

0 comments on commit 527a383

Please sign in to comment.