diff --git a/__tests__/allRequirements.test.ts b/__tests__/allRequirements.test.ts index 0fa23c1e..5f43f490 100644 --- a/__tests__/allRequirements.test.ts +++ b/__tests__/allRequirements.test.ts @@ -8,12 +8,10 @@ import mockCheckPayout from "./__mocks__/mockCheckPayout"; describe("All Requirements Fullfilled", () => { test("Test suite", () => { - const store = new ServiceStore(); const gmail = store.gmail as StateAccount; expect(connectGmail(gmail)).toBe("P100"); - const retailer = store.retailer as StateAccount; expect(connectRetailer(retailer)).toBe("P100"); @@ -21,10 +19,9 @@ describe("All Requirements Fullfilled", () => { expect(fiveReceipts(store.receipt)).toBe(5); - expect( mockCheckPayout( - store.sync.countWeeks(new Date('09/27/2023')), + store.sync.countWeeks(new Date("09/27/2023")), store.receipt.count(), gmail.get().value, retailer.get().value diff --git a/__tests__/lostWeekLoginDoesNotResetState.test.ts b/__tests__/lostWeekLoginDoesNotResetState.test.ts new file mode 100644 index 00000000..1ae67ea3 --- /dev/null +++ b/__tests__/lostWeekLoginDoesNotResetState.test.ts @@ -0,0 +1,38 @@ +import { StateAccount } from "../src/service/store/state/state-account"; +import { ServiceStore } from "../src/service/store"; +import connectGmail from "./__fixtures__/connectGmail"; +import connectRetailer from "./__fixtures__/connectRetailer"; +import fiveReceipts from "./__fixtures__/fiveReceipts"; +import mockCheckPayout from "./__mocks__/mockCheckPayout"; + +describe("User misses a weekly login", () => { + test("test suite", () => { + const store = new ServiceStore(); + const gmail = store.gmail as StateAccount; + const retailer = store.retailer as StateAccount; + + store.sync.add(new Date("09/05/2023")); + store.sync.add(new Date("09/12/2023")); + store.sync.add(new Date("09/24/2023")); + store.sync.add(new Date("10/01/2023")); + const count = store.sync.countWeeks(new Date("10/02/2023")); + + expect(count).toBeLessThan(4); + + expect(connectGmail(gmail)).toBe("P100"); + expect(connectRetailer(retailer)).toBe("P100"); + expect(fiveReceipts(store.receipt)).toBe(5); + expect(gmail.get().value).toBe("P100") + expect(retailer.get().value).toBe("P100") + expect(store.receipt.count()).toBe(5) + + expect( + mockCheckPayout( + count, + store.receipt.count(), + gmail.get().value, + retailer.get().value + ) + ).toBeFalsy(); + }); +}); diff --git a/__tests__/userConnectsOnlyGmail.test.ts b/__tests__/userConnectsOnlyGmail.test.ts index b9db75dd..643a96f0 100644 --- a/__tests__/userConnectsOnlyGmail.test.ts +++ b/__tests__/userConnectsOnlyGmail.test.ts @@ -18,7 +18,6 @@ describe("User connects Gmail but not Retailer Account", () => { expect(fiveReceipts(store.receipt)).toBe(5); - //mock checkPayout expect( mockCheckPayout( store.sync.countWeeks(new Date("09/27/2023")), diff --git a/__tests__/userConnectsOnlyRetailer.test.ts b/__tests__/userConnectsOnlyRetailer.test.ts index c3625e8a..1880d0cf 100644 --- a/__tests__/userConnectsOnlyRetailer.test.ts +++ b/__tests__/userConnectsOnlyRetailer.test.ts @@ -1,6 +1,5 @@ import { StateAccount } from "../src/service/store/state/state-account"; import { ServiceStore } from "../src/service/store"; -import connectGmail from "./__fixtures__/connectGmail"; import fourWeeks from "./__fixtures__/fourWeeks"; import fiveReceipts from "./__fixtures__/fiveReceipts"; import mockCheckPayout from "./__mocks__/mockCheckPayout"; @@ -21,7 +20,6 @@ describe("User Connects Only a Retailer Account", () => { expect(fiveReceipts(store.receipt)).toBe(5); - //mock checkPayout expect( mockCheckPayout( store.sync.countWeeks(new Date("09/27/2023")), diff --git a/__tests__/userDisconnectRetailer.ts b/__tests__/userDisconnectRetailer.ts index 7bd7606e..28bc62af 100644 --- a/__tests__/userDisconnectRetailer.ts +++ b/__tests__/userDisconnectRetailer.ts @@ -7,8 +7,6 @@ import fiveReceipts from "./__fixtures__/fiveReceipts"; import fourWeeks from "./__fixtures__/fourWeeks"; import mockCheckPayout from "./__mocks__/mockCheckPayout"; - - describe('User disconnect Gmail', ()=>{ test("test suite", async ()=>{ const store = new ServiceStore() diff --git a/__tests__/userDoesNotShare5Receipts.test.ts b/__tests__/userDoesNotShare5Receipts.test.ts index 8e95957b..d3413bf4 100644 --- a/__tests__/userDoesNotShare5Receipts.test.ts +++ b/__tests__/userDoesNotShare5Receipts.test.ts @@ -2,39 +2,37 @@ import { StateAccount } from "../src/service/store/state/state-account"; import { ServiceStore } from "../src/service/store"; import connectGmail from "./__fixtures__/connectGmail"; import connectRetailer from "./__fixtures__/connectRetailer"; -import fiveReceipts from "./__fixtures__/fiveReceipts"; import fourWeeks from "./__fixtures__/fourWeeks"; import mockCheckPayout from "./__mocks__/mockCheckPayout"; -describe("User does not share 5 receipts", ()=>{ - test("Test Suite", ()=>{ - const store = new ServiceStore(); - - const gmail = store.gmail as StateAccount; - expect(connectGmail(gmail)).toBe("P100"); - - - const retailer = store.retailer as StateAccount; - expect(connectRetailer(retailer)).toBe("P100"); - - expect(fourWeeks(store.sync)).toBe(4); - - store.receipt.add('receipt1', new Date('09/05/2023')) - store.receipt.add('receipt2', new Date('09/12/2023')) - store.receipt.add('receipt3', new Date('09/12/2023')) - store.receipt.add('receipt4', new Date('09/19/2023')) - - const receiptCount = store.receipt.count() - - expect(receiptCount).toBe(4) - - expect( - mockCheckPayout( - store.sync.countWeeks(new Date('09/27/2023')), - receiptCount, - gmail.get().value, - retailer.get().value - ) - ).toBeFalsy(); - }) -}) \ No newline at end of file +describe("User does not share 5 receipts", () => { + test("Test Suite", () => { + const store = new ServiceStore(); + + const gmail = store.gmail as StateAccount; + expect(connectGmail(gmail)).toBe("P100"); + + const retailer = store.retailer as StateAccount; + expect(connectRetailer(retailer)).toBe("P100"); + + expect(fourWeeks(store.sync)).toBe(4); + + store.receipt.add("receipt1", new Date("09/05/2023")); + store.receipt.add("receipt2", new Date("09/12/2023")); + store.receipt.add("receipt3", new Date("09/12/2023")); + store.receipt.add("receipt4", new Date("09/19/2023")); + + const receiptCount = store.receipt.count(); + + expect(receiptCount).toBe(4); + + expect( + mockCheckPayout( + store.sync.countWeeks(new Date("09/27/2023")), + receiptCount, + gmail.get().value, + retailer.get().value + ) + ).toBeFalsy(); + }); +}); diff --git a/__tests__/weeklyLoginMissed.test.ts b/__tests__/weeklyLoginMissed.test.ts index 4f14651e..73cdab4a 100644 --- a/__tests__/weeklyLoginMissed.test.ts +++ b/__tests__/weeklyLoginMissed.test.ts @@ -11,7 +11,7 @@ describe("User misses a weekly login", () => { const gmail = store.gmail as StateAccount; expect(connectGmail(gmail)).toBe("P100"); - //add a retailer account + const retailer = store.retailer as StateAccount; expect(connectRetailer(retailer)).toBe("P100"); diff --git a/jest.config.js b/jest.config.js index d1c0c099..92cc4d56 100644 --- a/jest.config.js +++ b/jest.config.js @@ -12,4 +12,5 @@ module.exports = { getRandomValues: (arr) => require("crypto").randomBytes(arr.length), }, }, + modulePathIgnorePatterns: ["/__tests__/__mocks__/*", "/__tests__/__fixtures__/*"] } \ No newline at end of file