Skip to content

Commit f117b41

Browse files
authored
fix: Update error code and message, and make corresponding changes in the README
1 parent 206f473 commit f117b41

File tree

3 files changed

+18
-17
lines changed

3 files changed

+18
-17
lines changed

README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11

22
<H1>Siren React Inbox</H1>
33

4-
<a name="introduction"></a>
5-
64
## Overview
75

86
The `@siren/react-inbox` sdk is a comprehensive and customizable React UI kit for displaying and managing notifications. This documentation provides comprehensive information on how to install, configure, and use the sdk effectively.
@@ -251,7 +249,7 @@ Given below are all possible error codes thrown by sdk.
251249
| INVALID_RECIPIENT_ID | Invalid recipient id | The recipient id passed in the provider is invalid |
252250
| TOKEN_VERIFICATION_FAILED | This operation requires a valid token | Verification of the given tokens has failed |
253251
| GENERIC_API_ERROR | Api error | Occurrence of an unexpected api error |
254-
| SIREN_OBJECT_NOT_FOUND | Siren Object Not found | Attempting to invoke the functions outside the siren inbox context|
252+
| OUTSIDE_SIREN_CONTEXT | Trying to invoke function outside the siren context | Attempting to invoke the functions outside the siren inbox context|
255253
| MISSING_PARAMETER | Missing Parameter | The required parameter is missing |
256254

257255
### Example

src/utils/constants.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,8 @@ export const MAXIMUM_ITEMS_PER_FETCH = 50;
108108
export const errorMap = {
109109
SIREN_OBJECT_NOT_FOUND: {
110110
Type: "ERROR",
111-
Code: "SIREN_OBJECT_NOT_FOUND",
112-
Message: "Siren Object Not found",
111+
Code: 'OUTSIDE_SIREN_CONTEXT',
112+
Message: 'Trying to invoke function outside the siren context'
113113
},
114114
MISSING_PARAMETER: {
115115
Type: "ERROR",

tests/components/sirenPanel.spec.tsx

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ jest.mock("../../src/styles/loader.css", () => ({}));
1313
jest.mock("../../src/styles/emptyList.css", () => ({}));
1414
jest.mock("../../src/styles/errorWindow.css", () => ({}));
1515
jest.mock("../../src/styles/sirenPanel.css", () => ({}));
16-
jest.mock('../../src/styles/showMore.css', () => ({}));
17-
16+
jest.mock("../../src/styles/showMore.css", () => ({}));
1817

1918
const mockErrorFn = jest.fn();
2019
const style = applyTheme();
@@ -33,7 +32,7 @@ const props = {
3332
noOfNotificationsPerFetch: 10,
3433
fullScreen: false,
3534
setModalVisible: jest.fn(),
36-
darkMode: false
35+
darkMode: false,
3736
};
3837

3938
test("matches snapshot", () => {
@@ -42,9 +41,9 @@ test("matches snapshot", () => {
4241
expect(asFragment()).toMatchSnapshot();
4342
});
4443

45-
it('renders title when provided', () => {
44+
it("renders title when provided", () => {
4645
const { getByText } = render(<SirenPanel {...props} title="Notifications" />);
47-
const title = getByText('Notifications');
46+
const title = getByText("Notifications");
4847

4948
expect(title).toBeTruthy();
5049
});
@@ -68,15 +67,19 @@ it("renders custom header when provided", () => {
6867

6968
it("calls onError callback if an error occurs", async () => {
7069
// Mocking an error response from the server
71-
jest.spyOn(global, 'fetch').mockRejectedValueOnce({
70+
jest.spyOn(global, "fetch").mockRejectedValueOnce({
7271
json: async () => ({
73-
Code: "SIREN_OBJECT_NOT_FOUND",
74-
Message: "Siren Object Not found",
75-
Type: "ERROR"
76-
})
72+
Code: "OUTSIDE_SIREN_CONTEXT",
73+
Message: "Trying to invoke function outside the siren context",
74+
Type: "ERROR",
75+
}),
7776
});
7877
render(<SirenPanel {...props} />);
7978
await waitFor(() => {
80-
expect(mockErrorFn).toHaveBeenCalledWith({"Code": "SIREN_OBJECT_NOT_FOUND", "Message": "Siren Object Not found", "Type": "ERROR"});
79+
expect(mockErrorFn).toHaveBeenCalledWith({
80+
Code: "OUTSIDE_SIREN_CONTEXT",
81+
Message: "Trying to invoke function outside the siren context",
82+
Type: "ERROR",
83+
});
8184
});
82-
});
85+
});

0 commit comments

Comments
 (0)