A Metamask fork with Infura removed and default networks editable
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ciphermask/test/unit/app/controllers/notice-controller-test.js

94 lines
2.7 KiB

const assert = require('assert')
const NoticeController = require('../../../../app/scripts/notice-controller')
8 years ago
describe('notice-controller', function () {
var noticeController
8 years ago
beforeEach(function () {
noticeController = new NoticeController()
})
8 years ago
describe('notices', function () {
8 years ago
describe('#setNoticesList', function () {
it('should set data appropriately', function (done) {
var testList = [{
8 years ago
id: 0,
read: false,
title: 'Futuristic Notice',
}]
noticeController.setNoticesList(testList)
var testListId = noticeController.getNoticesList()[0].id
assert.equal(testListId, 0)
done()
})
})
describe('#markNoticeRead', function () {
it('should mark a notice as read', function (done) {
var testList = [{
8 years ago
id: 0,
read: false,
title: 'Futuristic Notice',
}]
noticeController.setNoticesList(testList)
noticeController.markNoticeRead(testList[0])
var newList = noticeController.getNoticesList()
assert.ok(newList[0].read)
done()
})
})
describe('#markAllNoticesRead', () => {
it('marks all notices read', (done) => {
const testList = [{
id: 0,
read: false,
title: 'Notice 1',
}, {
id: 1,
read: false,
title: 'Notice 2',
}, {
id: 2,
read: false,
title: 'Notice 3',
}]
noticeController.setNoticesList(testList)
noticeController.markAllNoticesRead()
const unreadNotices = noticeController.getUnreadNotices()
assert.equal(unreadNotices.length, 0)
done()
})
})
describe('#getNextUnreadNotice', function () {
it('should retrieve the latest unread notice', function (done) {
var testList = [
8 years ago
{id: 0, read: true, title: 'Past Notice'},
{id: 1, read: false, title: 'Current Notice'},
{id: 2, read: false, title: 'Future Notice'},
]
noticeController.setNoticesList(testList)
var latestUnread = noticeController.getNextUnreadNotice()
assert.equal(latestUnread.id, 1)
done()
})
it('should return undefined if no unread notices exist.', function (done) {
var testList = [
8 years ago
{id: 0, read: true, title: 'Past Notice'},
{id: 1, read: true, title: 'Current Notice'},
{id: 2, read: true, title: 'Future Notice'},
]
noticeController.setNoticesList(testList)
var latestUnread = noticeController.getNextUnreadNotice()
assert.ok(!latestUnread)
done()
})
})
})
})