diff --git a/TypeScript/app/a/Assignment.md b/TypeScript/app/a/Assignment.md index 8c90831..886d461 100644 --- a/TypeScript/app/a/Assignment.md +++ b/TypeScript/app/a/Assignment.md @@ -31,3 +31,5 @@ our online shop. The main logic is in `Discount`. * Bring `Discount` under test. Make sure to cover all paths in the core logic. * There is an existing `DiscountTest` with a first test case which might or might not work. * You cannot change `MarketingCampaign` because it is used by other teams as well. + +(This is a copied document - do not edit!) diff --git a/TypeScript/app/a/discount.ts b/TypeScript/app/a/discount.ts index 80ed077..514dfc0 100644 --- a/TypeScript/app/a/discount.ts +++ b/TypeScript/app/a/discount.ts @@ -1,9 +1,9 @@ -import {Money} from "./money"; -import {MarketingCampaign} from "./marketing-campaign"; +import { Money } from "./money"; +import { MarketingCampaign } from "./marketing-campaign"; export class Discount { - marketingCampaign: MarketingCampaign; + private marketingCampaign: MarketingCampaign; constructor() { this.marketingCampaign = new MarketingCampaign(); diff --git a/TypeScript/app/a/marketing-campaign.ts b/TypeScript/app/a/marketing-campaign.ts index 226160e..3e0c0a6 100644 --- a/TypeScript/app/a/marketing-campaign.ts +++ b/TypeScript/app/a/marketing-campaign.ts @@ -1,13 +1,11 @@ export class MarketingCampaign { public isActive(): boolean { - let now: Date = new Date(); - return now.getMilliseconds() % 2 == 0; + return new Date().getMilliseconds() % 2 == 0; } public isCrazySalesDay(): boolean { - let now: Date = new Date(); - return now.getDay() === 5; + return new Date().getDay() === 5; // Friday corresponds to day number 5 } } diff --git a/TypeScript/app/a/money.ts b/TypeScript/app/a/money.ts index 673be77..cf0fea4 100644 --- a/TypeScript/app/a/money.ts +++ b/TypeScript/app/a/money.ts @@ -14,7 +14,6 @@ export class Money { } reduceBy(p: number): Money { - // value.multiply(new BigDecimal(100 - p)).divide(new BigDecimal(100)) return new Money((this.value * (100 - p) / 100).toFixed(2)); } diff --git a/TypeScript/test/a/discount.test.ts b/TypeScript/test/a/discount.test.ts index fccc4b7..ba85d57 100644 --- a/TypeScript/test/a/discount.test.ts +++ b/TypeScript/test/a/discount.test.ts @@ -1,16 +1,16 @@ -import {Discount} from "../../app/a/discount"; -import {Money} from "../../app/a/money"; -import {expect} from "chai"; +import { Discount } from "../../app/a/discount"; +import { Money } from "../../app/a/money"; +import { expect } from "chai"; -describe('Discount Test', () => { +describe('Discount', () => { - it('test in a', () => { - let discount = new Discount(); + it('test 1', () => { + const discount = new Discount(); - let net = new Money(1002); - let total = discount.discountFor(net); + const net = new Money(1002); + const total = discount.discountFor(net); expect(total.value).to.be.equal(901.8); }); -}); \ No newline at end of file +});