Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions ios/src/ReactNativePlaidLinkSdkModule.swift
Original file line number Diff line number Diff line change
Expand Up @@ -337,9 +337,9 @@ public class ReactNativePlaidLinkSdkModule: Module {

/// Event names that the module can send to JavaScript.
enum ModuleEventName: String, CaseIterable {
case onSuccess
case onExit
case onEvent
case onSuccess = "PlaidLink.onSuccess"
case onExit = "PlaidLink.onExit"
case onEvent = "PlaidLink.onEvent"
}

/// Function names that the module can call from JavaScript.
Expand Down
6 changes: 3 additions & 3 deletions src/ReactNativePlaidLinkSdk.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,47 +98,47 @@
export class LinkAccountSubtypeCredit implements LinkAccountSubtype {
public static readonly ALL = new LinkAccountSubtypeCredit(
LinkAccountType.CREDIT,
LinkAccountSubtypes.ALL

Check warning on line 101 in src/ReactNativePlaidLinkSdk.types.ts

View workflow job for this annotation

GitHub Actions / install-and-test

Insert `,`
);
public static readonly CREDIT_CARD = new LinkAccountSubtypeCredit(
LinkAccountType.CREDIT,
LinkAccountSubtypes.CREDIT_CARD

Check warning on line 105 in src/ReactNativePlaidLinkSdk.types.ts

View workflow job for this annotation

GitHub Actions / install-and-test

Insert `,`
);
public static readonly PAYPAL = new LinkAccountSubtypeCredit(
LinkAccountType.CREDIT,
LinkAccountSubtypes.PAYPAL

Check warning on line 109 in src/ReactNativePlaidLinkSdk.types.ts

View workflow job for this annotation

GitHub Actions / install-and-test

Insert `,`
);

private constructor(
public readonly type: LinkAccountType,
public readonly subtype: LinkAccountSubtype

Check warning on line 114 in src/ReactNativePlaidLinkSdk.types.ts

View workflow job for this annotation

GitHub Actions / install-and-test

Insert `,`
) {}
}

export class LinkAccountSubtypeDepository implements LinkAccountSubtype {
public static readonly ALL = new LinkAccountSubtypeDepository(
LinkAccountType.DEPOSITORY,
LinkAccountSubtypes.ALL

Check warning on line 121 in src/ReactNativePlaidLinkSdk.types.ts

View workflow job for this annotation

GitHub Actions / install-and-test

Insert `,`
);
public static readonly CASH_MANAGEMENT = new LinkAccountSubtypeDepository(
LinkAccountType.DEPOSITORY,
LinkAccountSubtypes.CASH_MANAGEMENT

Check warning on line 125 in src/ReactNativePlaidLinkSdk.types.ts

View workflow job for this annotation

GitHub Actions / install-and-test

Insert `,`
);
public static readonly CD = new LinkAccountSubtypeDepository(
LinkAccountType.DEPOSITORY,
LinkAccountSubtypes.CD

Check warning on line 129 in src/ReactNativePlaidLinkSdk.types.ts

View workflow job for this annotation

GitHub Actions / install-and-test

Insert `,`
);
public static readonly CHECKING = new LinkAccountSubtypeDepository(
LinkAccountType.DEPOSITORY,
LinkAccountSubtypes.CHECKING

Check warning on line 133 in src/ReactNativePlaidLinkSdk.types.ts

View workflow job for this annotation

GitHub Actions / install-and-test

Insert `,`
);
public static readonly EBT = new LinkAccountSubtypeDepository(
LinkAccountType.DEPOSITORY,
LinkAccountSubtypes.EBT

Check warning on line 137 in src/ReactNativePlaidLinkSdk.types.ts

View workflow job for this annotation

GitHub Actions / install-and-test

Insert `,`
);
public static readonly HSA = new LinkAccountSubtypeDepository(
LinkAccountType.DEPOSITORY,
LinkAccountSubtypes.HSA

Check warning on line 141 in src/ReactNativePlaidLinkSdk.types.ts

View workflow job for this annotation

GitHub Actions / install-and-test

Insert `,`
);
public static readonly MONEY_MARKET = new LinkAccountSubtypeDepository(
LinkAccountType.DEPOSITORY,
Expand Down Expand Up @@ -767,9 +767,9 @@
}

export type ReactNativePlaidLinkSdkModuleEvents = {
onSuccess: (success: LinkSuccess) => void;
onExit: (exit: LinkExit) => void;
onEvent: (event: LinkEvent) => void;
"PlaidLink.onSuccess": (success: LinkSuccess) => void;
"PlaidLink.onExit": (exit: LinkExit) => void;
"PlaidLink.onEvent": (event: LinkEvent) => void;
};

export type LinkSuccessListener = (LinkSuccess: LinkSuccess) => void;
Expand Down
12 changes: 6 additions & 6 deletions src/__mocks__/ReactNativePlaidLinkSdkModule.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const mockListeners: Record<string, Function[]> = {
onSuccess: [],
onExit: [],
onEvent: [],
"PlaidLink.onSuccess": [],
"PlaidLink.onExit": [],
"PlaidLink.onEvent": [],
};

const mockNativeModule = {
Expand Down Expand Up @@ -54,9 +54,9 @@ const mockNativeModule = {
},

__clearListeners: () => {
mockListeners.onSuccess = [];
mockListeners.onExit = [];
mockListeners.onEvent = [];
mockListeners["PlaidLink.onSuccess"] = [];
mockListeners["PlaidLink.onExit"] = [];
mockListeners["PlaidLink.onEvent"] = [];
},

__getListenerCount: (eventName: string) => {
Expand Down
14 changes: 7 additions & 7 deletions src/__tests__/createPlaidHeadlessSession.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ describe("createPlaidHeadlessSession", () => {
},
};

(NativePlaidModule as any).__triggerEvent("onSuccess", mockSuccess);
(NativePlaidModule as any).__triggerEvent("PlaidLink.onSuccess", mockSuccess);
expect(onSuccessMock).toHaveBeenCalledWith(mockSuccess);
});

Expand All @@ -89,7 +89,7 @@ describe("createPlaidHeadlessSession", () => {
},
};

(NativePlaidModule as any).__triggerEvent("onExit", mockExit);
(NativePlaidModule as any).__triggerEvent("PlaidLink.onExit", mockExit);
expect(onExitMock).toHaveBeenCalledWith(mockExit);
});

Expand All @@ -114,7 +114,7 @@ describe("createPlaidHeadlessSession", () => {
},
};

(NativePlaidModule as any).__triggerEvent("onEvent", mockEvent);
(NativePlaidModule as any).__triggerEvent("PlaidLink.onEvent", mockEvent);
expect(onEventMock).toHaveBeenCalledWith(mockEvent);
});

Expand Down Expand Up @@ -166,11 +166,11 @@ describe("createPlaidHeadlessSession", () => {
},
};

(NativePlaidModule as any).__triggerEvent("onSuccess", mockSuccess);
(NativePlaidModule as any).__triggerEvent("PlaidLink.onSuccess", mockSuccess);

expect(onSuccessMock).toHaveBeenCalledWith(mockSuccess);

(NativePlaidModule as any).__triggerEvent("onExit", {});
(NativePlaidModule as any).__triggerEvent("PlaidLink.onExit", {});
expect(onExitMock).not.toHaveBeenCalled();
});

Expand All @@ -194,11 +194,11 @@ describe("createPlaidHeadlessSession", () => {
},
};

(NativePlaidModule as any).__triggerEvent("onExit", mockExit);
(NativePlaidModule as any).__triggerEvent("PlaidLink.onExit", mockExit);

expect(onExitMock).toHaveBeenCalledWith(mockExit);

(NativePlaidModule as any).__triggerEvent("onSuccess", {});
(NativePlaidModule as any).__triggerEvent("PlaidLink.onSuccess", {});
expect(onSuccessMock).not.toHaveBeenCalled();
});

Expand Down
8 changes: 4 additions & 4 deletions src/__tests__/createPlaidLayerSession.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ describe("createPlaidLayerSession", () => {
},
};

(NativePlaidModule as any).__triggerEvent("onExit", mockExit);
(NativePlaidModule as any).__triggerEvent("PlaidLink.onExit", mockExit);
expect(onExitMock).toHaveBeenCalledWith(mockExit);
});

Expand All @@ -78,7 +78,7 @@ describe("createPlaidLayerSession", () => {
},
};

(NativePlaidModule as any).__triggerEvent("onEvent", mockEvent);
(NativePlaidModule as any).__triggerEvent("PlaidLink.onEvent", mockEvent);
expect(onEventMock).toHaveBeenCalledWith(mockEvent);
});

Expand Down Expand Up @@ -145,11 +145,11 @@ describe("createPlaidLayerSession", () => {
},
};

(NativePlaidModule as any).__triggerEvent("onSuccess", mockSuccess);
(NativePlaidModule as any).__triggerEvent("PlaidLink.onSuccess", mockSuccess);

expect(onSuccessMock).toHaveBeenCalledWith(mockSuccess);

(NativePlaidModule as any).__triggerEvent("onExit", {});
(NativePlaidModule as any).__triggerEvent("PlaidLink.onExit", {});
expect(onExitMock).not.toHaveBeenCalled();
});

Expand Down
22 changes: 11 additions & 11 deletions src/__tests__/createPlaidLinkSession.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ describe("createPlaidLinkSession", () => {
expect(typeof session.open).toBe("function");
expect(NativePlaidModule.addListener).toHaveBeenCalledTimes(3);
expect(NativePlaidModule.addListener).toHaveBeenCalledWith(
"onSuccess",
"PlaidLink.onSuccess",
expect.any(Function)
);
expect(NativePlaidModule.addListener).toHaveBeenCalledWith(
"onExit",
"PlaidLink.onExit",
expect.any(Function)
);
expect(NativePlaidModule.addListener).toHaveBeenCalledWith(
"onEvent",
"PlaidLink.onEvent",
expect.any(Function)
);
});
Expand Down Expand Up @@ -128,12 +128,12 @@ describe("createPlaidLinkSession", () => {
},
};

(NativePlaidModule as any).__triggerEvent("onSuccess", mockSuccessData);
(NativePlaidModule as any).__triggerEvent("PlaidLink.onSuccess", mockSuccessData);

expect(onSuccessMock).toHaveBeenCalledWith(mockSuccessData);
expect(onSuccessMock).toHaveBeenCalledTimes(1);

(NativePlaidModule as any).__triggerEvent("onExit", {});
(NativePlaidModule as any).__triggerEvent("PlaidLink.onExit", {});
expect(onExitMock).not.toHaveBeenCalled();
});

Expand All @@ -159,12 +159,12 @@ describe("createPlaidLinkSession", () => {
},
};

(NativePlaidModule as any).__triggerEvent("onExit", mockExitData);
(NativePlaidModule as any).__triggerEvent("PlaidLink.onExit", mockExitData);

expect(onExitMock).toHaveBeenCalledWith(mockExitData);
expect(onExitMock).toHaveBeenCalledTimes(1);

(NativePlaidModule as any).__triggerEvent("onSuccess", {});
(NativePlaidModule as any).__triggerEvent("PlaidLink.onSuccess", {});
expect(onSuccessMock).not.toHaveBeenCalled();
});

Expand Down Expand Up @@ -200,16 +200,16 @@ describe("createPlaidLinkSession", () => {
},
};

(NativePlaidModule as any).__triggerEvent("onEvent", mockEvent1);
(NativePlaidModule as any).__triggerEvent("onEvent", mockEvent2);
(NativePlaidModule as any).__triggerEvent("onEvent", mockEvent1);
(NativePlaidModule as any).__triggerEvent("PlaidLink.onEvent", mockEvent1);
(NativePlaidModule as any).__triggerEvent("PlaidLink.onEvent", mockEvent2);
(NativePlaidModule as any).__triggerEvent("PlaidLink.onEvent", mockEvent1);

expect(onEventMock).toHaveBeenCalledTimes(3);
expect(onEventMock).toHaveBeenCalledWith(mockEvent1);
expect(onEventMock).toHaveBeenCalledWith(mockEvent2);

expect(
(NativePlaidModule as any).__getListenerCount("onEvent")
(NativePlaidModule as any).__getListenerCount("PlaidLink.onEvent")
).toBeGreaterThan(0);
});

Expand Down
46 changes: 23 additions & 23 deletions src/__tests__/listener-lifecycle.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ describe("Listener Lifecycle", () => {
await createPlaidLinkSession(config);

expect(
(NativePlaidModule as any).__getListenerCount("onSuccess")
(NativePlaidModule as any).__getListenerCount("PlaidLink.onSuccess")
).toBeGreaterThan(0);
expect(
(NativePlaidModule as any).__getListenerCount("onExit")
(NativePlaidModule as any).__getListenerCount("PlaidLink.onExit")
).toBeGreaterThan(0);
expect(
(NativePlaidModule as any).__getListenerCount("onEvent")
(NativePlaidModule as any).__getListenerCount("PlaidLink.onEvent")
).toBeGreaterThan(0);

const mockSuccess: LinkSuccess = {
Expand All @@ -43,11 +43,11 @@ describe("Listener Lifecycle", () => {
},
};

(NativePlaidModule as any).__triggerEvent("onSuccess", mockSuccess);
(NativePlaidModule as any).__triggerEvent("PlaidLink.onSuccess", mockSuccess);

expect((NativePlaidModule as any).__getListenerCount("onSuccess")).toBe(0);
expect((NativePlaidModule as any).__getListenerCount("onExit")).toBe(0);
expect((NativePlaidModule as any).__getListenerCount("onEvent")).toBe(0);
expect((NativePlaidModule as any).__getListenerCount("PlaidLink.onSuccess")).toBe(0);
expect((NativePlaidModule as any).__getListenerCount("PlaidLink.onExit")).toBe(0);
expect((NativePlaidModule as any).__getListenerCount("PlaidLink.onEvent")).toBe(0);
});

it("multiple session creations do not stack listeners", async () => {
Expand Down Expand Up @@ -80,7 +80,7 @@ describe("Listener Lifecycle", () => {
},
};

(NativePlaidModule as any).__triggerEvent("onSuccess", mockSuccess);
(NativePlaidModule as any).__triggerEvent("PlaidLink.onSuccess", mockSuccess);

expect(firstSuccess).not.toHaveBeenCalled();
expect(secondSuccess).toHaveBeenCalledTimes(1);
Expand Down Expand Up @@ -111,12 +111,12 @@ describe("Listener Lifecycle", () => {
},
};

(NativePlaidModule as any).__triggerEvent("onSuccess", mockSuccess);
(NativePlaidModule as any).__triggerEvent("PlaidLink.onSuccess", mockSuccess);
}

expect((NativePlaidModule as any).__getListenerCount("onSuccess")).toBe(0);
expect((NativePlaidModule as any).__getListenerCount("onExit")).toBe(0);
expect((NativePlaidModule as any).__getListenerCount("onEvent")).toBe(0);
expect((NativePlaidModule as any).__getListenerCount("PlaidLink.onSuccess")).toBe(0);
expect((NativePlaidModule as any).__getListenerCount("PlaidLink.onExit")).toBe(0);
expect((NativePlaidModule as any).__getListenerCount("PlaidLink.onEvent")).toBe(0);

successCallbacks.forEach((callback, index) => {
expect(callback).toHaveBeenCalledTimes(1);
Expand Down Expand Up @@ -145,7 +145,7 @@ describe("Listener Lifecycle", () => {
},
};

(NativePlaidModule as any).__triggerEvent("onSuccess", mockSuccess);
(NativePlaidModule as any).__triggerEvent("PlaidLink.onSuccess", mockSuccess);

expect(onSuccess).toHaveBeenCalledTimes(1);

Expand All @@ -166,8 +166,8 @@ describe("Listener Lifecycle", () => {
},
};

(NativePlaidModule as any).__triggerEvent("onExit", mockExit);
(NativePlaidModule as any).__triggerEvent("onEvent", mockEvent);
(NativePlaidModule as any).__triggerEvent("PlaidLink.onExit", mockExit);
(NativePlaidModule as any).__triggerEvent("PlaidLink.onEvent", mockEvent);

expect(onExit).not.toHaveBeenCalled();
expect(onEvent).not.toHaveBeenCalled();
Expand All @@ -194,7 +194,7 @@ describe("Listener Lifecycle", () => {
},
};

(NativePlaidModule as any).__triggerEvent("onExit", mockExit);
(NativePlaidModule as any).__triggerEvent("PlaidLink.onExit", mockExit);

expect(onExit).toHaveBeenCalledTimes(1);

Expand All @@ -216,8 +216,8 @@ describe("Listener Lifecycle", () => {
},
};

(NativePlaidModule as any).__triggerEvent("onSuccess", mockSuccess);
(NativePlaidModule as any).__triggerEvent("onEvent", mockEvent);
(NativePlaidModule as any).__triggerEvent("PlaidLink.onSuccess", mockSuccess);
(NativePlaidModule as any).__triggerEvent("PlaidLink.onEvent", mockEvent);

expect(onSuccess).not.toHaveBeenCalled();
expect(onEvent).not.toHaveBeenCalled();
Expand Down Expand Up @@ -284,7 +284,7 @@ describe("Listener Lifecycle", () => {
];

events.forEach((event) => {
(NativePlaidModule as any).__triggerEvent("onEvent", event);
(NativePlaidModule as any).__triggerEvent("PlaidLink.onEvent", event);
});

expect(onEvent).toHaveBeenCalledTimes(5);
Expand All @@ -293,7 +293,7 @@ describe("Listener Lifecycle", () => {
});

expect(
(NativePlaidModule as any).__getListenerCount("onEvent")
(NativePlaidModule as any).__getListenerCount("PlaidLink.onEvent")
).toBeGreaterThan(0);
});

Expand All @@ -319,11 +319,11 @@ describe("Listener Lifecycle", () => {
},
};

(NativePlaidModule as any).__triggerEvent("onSuccess", mockSuccess);
(NativePlaidModule as any).__triggerEvent("PlaidLink.onSuccess", mockSuccess);

expect(onSuccess).toHaveBeenCalledTimes(1);

(NativePlaidModule as any).__triggerEvent("onExit", {});
(NativePlaidModule as any).__triggerEvent("PlaidLink.onExit", {});
expect(onExit).not.toHaveBeenCalled();
});

Expand Down Expand Up @@ -357,7 +357,7 @@ describe("Listener Lifecycle", () => {
},
};

(NativePlaidModule as any).__triggerEvent("onSuccess", mockSuccess);
(NativePlaidModule as any).__triggerEvent("PlaidLink.onSuccess", mockSuccess);

expect(linkSuccess).not.toHaveBeenCalled();
expect(layerSuccess).toHaveBeenCalledTimes(1);
Expand Down
Loading
Loading