-
Notifications
You must be signed in to change notification settings - Fork 119
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests for subscription expiring message
- Loading branch information
Showing
6 changed files
with
108 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,13 @@ | ||
(function(api, condition) { | ||
// Show message only if within 1 week of expiring. | ||
let weekBeforeExpireMSecs = api.subscriptionData.expiresOn - 1000 * 60 * 60 * 24; | ||
const weekBeforeExpireMSecs = api.subscriptionData.expiresOn - 1000 * 60 * 60 * 24 * 7; | ||
const subscriptionExpiry = api.subscriptionData.expiresOn; | ||
const now = Date.now(); | ||
|
||
if (Date.now() < api.subscriptionData.expiresOn && | ||
Date.now() >= weekBeforeExpireMSecs) { | ||
if (now < subscriptionExpiry && now >= weekBeforeExpireMSecs) { | ||
api.addon.date = weekBeforeExpireMSecs; | ||
condition.enable(); | ||
} else { | ||
condition.disable(); | ||
} | ||
}) | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters