aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorKevin Serrano <kevgagser@gmail.com>2016-12-08 06:34:15 +0800
committerDan Finlay <dan@danfinlay.com>2016-12-17 02:44:52 +0800
commit8819475a2ed2ee7c34e983ebb5ab12661be1a961 (patch)
tree6d410c35aca5bae541481d96cb492597d7470826 /test
parentd5569781ba2668df78ab7cf0f20ac93f84cafadb (diff)
downloadtangerine-wallet-browser-8819475a2ed2ee7c34e983ebb5ab12661be1a961.tar
tangerine-wallet-browser-8819475a2ed2ee7c34e983ebb5ab12661be1a961.tar.gz
tangerine-wallet-browser-8819475a2ed2ee7c34e983ebb5ab12661be1a961.tar.bz2
tangerine-wallet-browser-8819475a2ed2ee7c34e983ebb5ab12661be1a961.tar.lz
tangerine-wallet-browser-8819475a2ed2ee7c34e983ebb5ab12661be1a961.tar.xz
tangerine-wallet-browser-8819475a2ed2ee7c34e983ebb5ab12661be1a961.tar.zst
tangerine-wallet-browser-8819475a2ed2ee7c34e983ebb5ab12661be1a961.zip
Add ability to show notices to user & get confirmation.
Implement generation of markdown for notice files. Create npm command. Enhance notice generation. Add test files to test multiple notices. Add basic markdown support to notices. Interval checks for updates. Add extensionizer and linker Add terms and conditions state file Add link support to disclaimer. Changelog addition.
Diffstat (limited to 'test')
-rw-r--r--test/unit/config-manager-test.js95
1 files changed, 95 insertions, 0 deletions
diff --git a/test/unit/config-manager-test.js b/test/unit/config-manager-test.js
index 6aa7146f0..4283c516c 100644
--- a/test/unit/config-manager-test.js
+++ b/test/unit/config-manager-test.js
@@ -3,6 +3,7 @@ const extend = require('xtend')
const STORAGE_KEY = 'metamask-persistance-key'
var configManagerGen = require('../lib/mock-config-manager')
var configManager
+var testList
const rp = require('request-promise')
const nock = require('nock')
@@ -13,6 +14,100 @@ describe('config-manager', function() {
configManager = configManagerGen()
})
+ describe('notices', function() {
+ describe('#getNoticesList', function() {
+ it('should return an empty array when new', function() {
+ var testList = [{
+ id:0,
+ read:false,
+ title:"Futuristic Notice"
+ }]
+ var result = configManager.getNoticesList()
+ assert.equal(result.length, 0)
+ })
+ })
+
+ describe('#setNoticesList', function() {
+ it('should set data appropriately', function () {
+ var testList = [{
+ id:0,
+ read:false,
+ title:"Futuristic Notice"
+ }]
+ configManager.setNoticesList(testList)
+ var testListId = configManager.getNoticesList()[0].id
+ assert.equal(testListId, 0)
+ })
+ })
+
+ describe('#updateNoticeslist', function() {
+ it('should integrate the latest changes from the source', function() {
+ var testList = [{
+ id:55,
+ read:false,
+ title:"Futuristic Notice"
+ }]
+ configManager.setNoticesList(testList)
+ configManager.updateNoticesList().then(() => {
+ var newList = configManager.getNoticesList()
+ assert.ok(newList[0].id === 55)
+ assert.ok(newList[1])
+ })
+ })
+ it('should not overwrite any existing fields', function () {
+ var testList = [{
+ id:0,
+ read:false,
+ title:"Futuristic Notice"
+ }]
+ configManager.setNoticesList(testList)
+ configManager.updateNoticesList().then(() => {
+ var newList = configManager.getNoticesList()
+ assert.equal(newList[0].id, 0)
+ assert.equal(newList[0].title, "Futuristic Notice")
+ assert.equal(newList.length, 1)
+ })
+ })
+ })
+
+ describe('#markNoticeRead', function () {
+ it('should mark a notice as read', function () {
+ var testList = [{
+ id:0,
+ read:false,
+ title:"Futuristic Notice"
+ }]
+ configManager.setNoticesList(testList)
+ configManager.markNoticeRead(testList[0])
+ var newList = configManager.getNoticesList()
+ assert.ok(newList[0].read)
+ })
+ })
+
+ describe('#getLatestUnreadNotice', function () {
+ it('should retrieve the latest unread notice', function () {
+ var testList = [
+ {id:0,read:true,title:"Past Notice"},
+ {id:1,read:false,title:"Current Notice"},
+ {id:2,read:false,title:"Future Notice"},
+ ]
+ configManager.setNoticesList(testList)
+ var latestUnread = configManager.getLatestUnreadNotice()
+ assert.equal(latestUnread.id, 2)
+ })
+ it('should return undefined if no unread notices exist.', function () {
+ var testList = [
+ {id:0,read:true,title:"Past Notice"},
+ {id:1,read:true,title:"Current Notice"},
+ {id:2,read:true,title:"Future Notice"},
+ ]
+ configManager.setNoticesList(testList)
+ var latestUnread = configManager.getLatestUnreadNotice()
+ assert.ok(!latestUnread)
+ })
+ })
+ })
+
describe('currency conversions', function() {
describe('#getCurrentFiat', function() {