Skip to content

Commit fe5e4c2

Browse files
committed
Update test imports
1 parent a18a74f commit fe5e4c2

File tree

9 files changed

+20
-54
lines changed

9 files changed

+20
-54
lines changed

test/push-notifications/basic.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import chai from "chai";
44
import dirtyChai from "dirty-chai";
55
import sinonChai from "sinon-chai";
66
import { spy } from "sinon";
7-
import PN from "../../src";
7+
import PN from "../../src/index.js";
88
import {
99
UNKNOWN_METHOD,
1010
WEB_METHOD,

test/push-notifications/regIds.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
import { expect } from "chai";
44
import sinon from "sinon";
5-
import PN from "../../src";
6-
import sendFCM from "../../src/sendFCM";
7-
import sendADM from "../../src/sendADM";
8-
import sendWNS from "../../src/sendWNS";
9-
import sendWeb from "../../src/sendWeb";
5+
import PN from "../../src/index.js";
6+
import sendFCM from "../../src/sendFCM.js";
7+
import sendADM from "../../src/sendADM.js";
8+
import sendWNS from "../../src/sendWNS.js";
9+
import sendWeb from "../../src/sendWeb.js";
1010

1111
const regIds = [
1212
"APA91bFQCD9Ndd8uVggMhj1usfeWsKIfGyBUWMprpZLGciWrMjS-77bIY24IMQNeEHzjidCcddnDxqYo-UEV03xw6ySmtIgQyzTqhSxhPGAi1maf6KDMAQGuUWc6L5Khze8YK9YrL9I_WD1gl49P3f_9hr08ZAS5Tw", // android

test/send/sendADM.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
import { expect } from "chai";
33
import sinon from "sinon";
44
import adm from "node-adm";
5-
import PN from "../../src";
6-
import { testPushSuccess, testPushError, testPushException } from "../util";
5+
import PN from "../../src/index.js";
6+
import { testPushSuccess, testPushError, testPushException } from "../util.js";
77

88
const method = "adm";
99
const regIds = [

test/send/sendAPN.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ import sinonChai from "sinon-chai";
55
import dirtyChai from "dirty-chai";
66

77
import apn from "@parse/node-apn";
8-
import PN from "../../src";
9-
import APN from "../../src/sendAPN";
8+
import PN from "../../src/index.js";
9+
import APN from "../../src/sendAPN.js";
1010

11-
import { testPushSuccess, testPushError, testPushException } from "../util";
11+
import { testPushSuccess, testPushError, testPushException } from "../util.js";
1212

1313
// Mock apn certificate loading to prevent file access
1414
before(() => {

test/send/sendFCM.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
import { expect } from "chai";
33
import sinon from "sinon";
44
import { Messaging as fbMessaging } from "firebase-admin/messaging";
5-
import PN from "../../src";
6-
import { testPushSuccess } from "../util";
5+
import PN from "../../src/index.js";
6+
import { testPushSuccess } from "../util.js";
77

88
const method = "fcm";
99
const regIds = [

test/send/sendWEB.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
import { expect } from "chai";
33
import sinon from "sinon";
44
import webpush from "web-push";
5-
import PN from "../../src";
6-
import { testPushSuccess, testPushError, testPushException } from "../util";
5+
import PN from "../../src/index.js";
6+
import { testPushSuccess, testPushError, testPushException } from "../util.js";
77

88
const method = "webPush";
99
const regIds = [

test/send/sendWNS-accessToken.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
import { expect } from "chai";
33
import sinon from "sinon";
44
import wns from "wns";
5-
import PN from "../../src";
6-
import { testPushSuccess, testPushError, testPushException } from "../util";
5+
import PN from "../../src/index.js";
6+
import { testPushSuccess, testPushError, testPushException } from "../util.js";
77

88
const method = "wns";
99
const regIds = [

test/send/sendWNS.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
import { expect } from "chai";
33
import sinon from "sinon";
44
import wns from "wns";
5-
import PN from "../../src";
6-
import { testPushSuccess, testPushError, testPushException } from "../util";
5+
import PN from "../../src/index.js";
6+
import { testPushSuccess, testPushError, testPushException } from "../util.js";
77

88
const method = "wns";
99
const regIds = [

test/util.js

Lines changed: 1 addition & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import sinon from "sinon";
2-
import gcm from "node-gcm";
32
import { expect } from "chai";
43

54
export const testPushSuccess = (method, regIds) => (err, results, done) => {
@@ -13,10 +12,6 @@ export const testPushSuccess = (method, regIds) => (err, results, done) => {
1312
result.message.forEach((message) => {
1413
expect(message).to.have.property("regId");
1514
expect(regIds).to.include(message.regId);
16-
if (method === "gcm") {
17-
expect(message).to.have.property("originalRegId");
18-
expect(regIds).to.include(message.originalRegId);
19-
}
2015
});
2116
});
2217
done(err);
@@ -60,33 +55,4 @@ export const testPushException = (errMessage) => (err, results, done) => {
6055
}
6156
};
6257

63-
export const sendOkMethodGCM = (regIds, data) =>
64-
sinon.stub(gcm.Sender.prototype, "send", (message, recipients, retries, cb) => {
65-
expect(recipients).to.be.instanceOf(Object);
66-
expect(recipients).to.have.property("registrationTokens");
67-
const { registrationTokens } = recipients;
68-
expect(registrationTokens).to.be.instanceOf(Array);
69-
registrationTokens.forEach((regId) => expect(regIds).to.include(regId));
70-
expect(retries).to.be.a("number");
71-
expect(message).to.be.instanceOf(gcm.Message);
72-
expect(message.params.notification.title).to.eql(data.title);
73-
expect(message.params.notification.body).to.eql(data.body);
74-
expect(message.params.notification.sound).to.eql(data.sound);
75-
expect(message.params.data.sender).to.eql(data.custom.sender);
76-
expect(message.params.priority).to.equal("high");
77-
// This params are duplicated in order to facilitate extraction
78-
// So they are available as `gcm.notification.title` and as `title`
79-
expect(message.params.data.title).to.eql(data.title);
80-
expect(message.params.data.message).to.eql(data.body);
81-
expect(message.params.data.sound).to.eql(data.sound);
82-
cb(null, {
83-
multicast_id: "abc",
84-
success: registrationTokens.length,
85-
failure: 0,
86-
results: registrationTokens.map((token) => ({
87-
message_id: "",
88-
registration_id: token,
89-
error: null,
90-
})),
91-
});
92-
});
58+

0 commit comments

Comments
 (0)