Skip to content

Commit

Permalink
Fix issues noted by eslint
Browse files Browse the repository at this point in the history
  • Loading branch information
marc1706 committed Feb 27, 2024
1 parent 4f1abdd commit 4e03bf6
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
10 changes: 5 additions & 5 deletions src/PushApiModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,10 @@ class PushApiModel {
* @returns {void}
*/
expireSubscription(clientHash) {
if (typeof this.subscriptions[clientHash] !== 'undefined') {
this.subscriptions[clientHash].isExpired = true;
} else {
if (typeof this.subscriptions[clientHash] === 'undefined') {
throw new RangeError('Subscription with specified client hash does not exist');
} else {
this.subscriptions[clientHash].isExpired = true;
}
}

Expand Down Expand Up @@ -346,6 +346,6 @@ class PushApiModel {
}

module.exports = {
PushApiModel: PushApiModel,
SubscriptionExpiredError: SubscriptionExpiredError,
PushApiModel,
SubscriptionExpiredError,
};
4 changes: 2 additions & 2 deletions src/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* https://opensource.org/licenses/MIT.
*
*/
const {SubscriptionExpiredError} = require("./PushApiModel");
const {SubscriptionExpiredError} = require('./PushApiModel');

let apiModel = {};

Expand Down Expand Up @@ -134,7 +134,7 @@ class WebPushTestingServer {
res.status(400).send({
error: {
message: err.message,
}
},
});
}

Expand Down
7 changes: 4 additions & 3 deletions test/PushApiModelTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,19 +196,20 @@ describe('Push API Model tests', () => {
assert.isTrue(model.isSubscriptionExpired(subscribeReturn.clientHash));
});

it ('Invalid subscription is properly handled', async () => {
it('Invalid subscription is properly handled', async () => {
const model = new PushApiModel();

assert.isFalse(model.isSubscriptionExpired('doesNotExist'));

try {
model.expireSubscription('doesNotExist');
} catch(err) {
} catch (err) {
assert.instanceOf(err, RangeError);
assert.equal(err.message, 'Subscription with specified client hash does not exist');
}

assert.isFalse(model.isSubscriptionExpired('doesNotExist'));
})
});
});

describe('Validate notification headers', () => {
Expand Down

0 comments on commit 4e03bf6

Please sign in to comment.