@fyno/node 1.1.4 → 1.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fyno/node",
3
- "version": "1.1.4",
3
+ "version": "1.1.5",
4
4
  "description": "This is the official Node.js module for sending notifications through Fyno.io.",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -1,37 +0,0 @@
1
- # This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
2
- # For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages
3
-
4
- name: Node.js Package
5
-
6
- on:
7
- release:
8
- types: [created]
9
-
10
- jobs:
11
- build:
12
- runs-on: ubuntu-latest
13
- steps:
14
- - uses: actions/checkout@v3
15
- - uses: actions/setup-node@v3
16
- with:
17
- node-version: 16
18
- - run: npm install
19
- - run: npm test
20
- env:
21
- FYNO_WSID: ${{secrets.fyno_wsid}}
22
- FYNO_API_KEY: ${{secrets.fyno_api_key}}
23
- FYNO_VERSION: ${{secrets.fyno_version}}
24
-
25
- publish-npm:
26
- needs: build
27
- runs-on: ubuntu-latest
28
- steps:
29
- - uses: actions/checkout@v3
30
- - uses: actions/setup-node@v3
31
- with:
32
- node-version: 16
33
- registry-url: https://registry.npmjs.org/
34
- - run: npm install
35
- - run: npm publish --access=public
36
- env:
37
- NODE_AUTH_TOKEN: ${{secrets.npm_token}}
@@ -1,208 +0,0 @@
1
- const { Fyno } = require("../src");
2
-
3
- const to = {
4
- sms: "",
5
- whatsapp: "",
6
- email: "",
7
- slack: "ashwin@fyno.io",
8
- discord: "",
9
- teams: "",
10
- push: "",
11
- };
12
-
13
- const data = {
14
- name: "Ashwin",
15
- sdk: "Node.js",
16
- };
17
-
18
- const event_name = "test-cases";
19
-
20
- const success_response = {
21
- request_id: expect.anything(),
22
- received_time: expect.anything(),
23
- event: event_name,
24
- response: {
25
- sms: {
26
- status: "error",
27
- message: expect.anything(),
28
- },
29
- whatsapp: {
30
- status: "error",
31
- message: expect.anything(),
32
- },
33
- email: {
34
- status: "error",
35
- message: expect.anything(),
36
- },
37
- slack: {
38
- status: "ok",
39
- destination: to.slack,
40
- msg_id: expect.anything(),
41
- },
42
- discord: {
43
- status: "error",
44
- message: expect.anything(),
45
- },
46
- teams: {
47
- status: "error",
48
- message: expect.anything(),
49
- },
50
- push: {
51
- status: "error",
52
- message: expect.anything(),
53
- },
54
- },
55
- };
56
-
57
- const success_response_batch = {
58
- request_id: expect.anything(),
59
- received_time: expect.anything(),
60
- event: event_name,
61
- response: [
62
- {
63
- seq: 1,
64
- sms: {
65
- status: "error",
66
- message: expect.anything(),
67
- },
68
- whatsapp: {
69
- status: "error",
70
- message: expect.anything(),
71
- },
72
- email: {
73
- status: "error",
74
- message: expect.anything(),
75
- },
76
- slack: {
77
- status: "ok",
78
- destination: to.slack,
79
- msg_id: expect.anything(),
80
- },
81
- discord: {
82
- status: "error",
83
- message: expect.anything(),
84
- },
85
- teams: {
86
- status: "error",
87
- message: expect.anything(),
88
- },
89
- push: {
90
- status: "error",
91
- message: expect.anything(),
92
- },
93
- },
94
- ],
95
- };
96
-
97
- const failure_response = {
98
- status: "error",
99
- _message: "Invalid API details",
100
- };
101
-
102
- describe("Firing an event", () => {
103
- test("Should fail when WSID supplied is incorrect", async () => {
104
- let response;
105
-
106
- try {
107
- const fyno = new Fyno("12345678910");
108
- response = await fyno.fire(event_name, { to, data });
109
- } catch (e) {
110
- response = e;
111
- }
112
-
113
- expect(response).toMatchObject(failure_response);
114
- });
115
- test("Should fail when WSID supplied is invalid", async () => {
116
- let response;
117
-
118
- try {
119
- const fyno = new Fyno("12345");
120
- } catch (e) {
121
- response = e.message;
122
- }
123
-
124
- expect(response).toBe(`Workspace ID value '12345' is invalid`);
125
- });
126
- test("Should fail when API Key supplied is incorrect", async () => {
127
- let response;
128
-
129
- try {
130
- const fyno = new Fyno(
131
- (wsid = undefined),
132
- (api_key = "ABCDEFG.++HIJKLMNOPQRSTUVWXYZ012345678910")
133
- );
134
- response = await fyno.fire("event_name", { to, data });
135
- } catch (e) {
136
- response = e;
137
- }
138
-
139
- expect(response).toMatchObject(failure_response);
140
- });
141
- test("Should fail when API Key supplied is invalid", async () => {
142
- let response;
143
-
144
- try {
145
- const fyno = new Fyno((wsid = undefined), (api_key = "12345"));
146
- } catch (e) {
147
- response = e.message;
148
- }
149
-
150
- expect(response).toBe(`API Key value '12345' is invalid`);
151
- });
152
- test("Should fail when ENV supplied is invalid (single)", async () => {
153
- let response;
154
- try {
155
- const fyno = new Fyno(undefined, undefined, "random");
156
- } catch (e) {
157
- response = e.message;
158
- }
159
-
160
- expect(response).toBe(
161
- `Environment value 'random' is invalid. It should be either 'test' or 'live'.`
162
- );
163
- });
164
- test("Should succeed when all credentials are correct and supplied through ENV file (single)", async () => {
165
- const fyno = new Fyno();
166
- const response = await fyno.fire(event_name, { to, data });
167
-
168
- expect(response).toMatchObject(success_response);
169
- });
170
- test("Should succeed when all credentials are correct and supplied through ENV file (batch)", async () => {
171
- const fyno = new Fyno();
172
- const response = await fyno.fire(event_name, [{ to, data }]);
173
-
174
- expect(response).toMatchObject(success_response_batch);
175
- });
176
- test("Should succeed when all credentials are correct and supplied manually (single)", async () => {
177
- const fyno = new Fyno(
178
- process.env.FYNO_WSID,
179
- process.env.FYNO_API_KEY,
180
- process.env.FYNO_VERSION
181
- );
182
- const response = await fyno.fire(event_name, { to, data });
183
-
184
- expect(response).toMatchObject(success_response);
185
- });
186
- test("Should succeed when all credentials are correct and supplied manually (batch)", async () => {
187
- const fyno = new Fyno(
188
- process.env.FYNO_WSID,
189
- process.env.FYNO_API_KEY,
190
- process.env.FYNO_VERSION
191
- );
192
- const response = await fyno.fire(event_name, [{ to, data }]);
193
-
194
- expect(response).toMatchObject(success_response_batch);
195
- });
196
- test("Should succeed when all credentals are correct and supplied manually and through ENV files (single)", async () => {
197
- const fyno = new Fyno(process.env.FYNO_WSID);
198
- const response = await fyno.fire(event_name, { to, data });
199
-
200
- expect(response).toMatchObject(success_response);
201
- });
202
- test("Should succeed when all credentals are correct and supplied manually and through ENV files (batch)", async () => {
203
- const fyno = new Fyno(process.env.FYNO_WSID);
204
- const response = await fyno.fire(event_name, [{ to, data }]);
205
-
206
- expect(response).toMatchObject(success_response_batch);
207
- });
208
- });
@@ -1 +0,0 @@
1
- require("./event.test.js");