aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorkumavis <kumavis@users.noreply.github.com>2019-03-29 14:23:02 +0800
committerGitHub <noreply@github.com>2019-03-29 14:23:02 +0800
commitc3a605f27a846b72227237cefa6e4590c8a3b2c1 (patch)
tree6dfc14e35e25ae47b04a331d8d8ccb0bc4341c64 /test
parent133ed80aeeeea4e2b0e9f1acb532f5d66f2575ca (diff)
parented381f5b2a3a85d351248769b3d150742acb703b (diff)
downloadtangerine-wallet-browser-c3a605f27a846b72227237cefa6e4590c8a3b2c1.tar
tangerine-wallet-browser-c3a605f27a846b72227237cefa6e4590c8a3b2c1.tar.gz
tangerine-wallet-browser-c3a605f27a846b72227237cefa6e4590c8a3b2c1.tar.bz2
tangerine-wallet-browser-c3a605f27a846b72227237cefa6e4590c8a3b2c1.tar.lz
tangerine-wallet-browser-c3a605f27a846b72227237cefa6e4590c8a3b2c1.tar.xz
tangerine-wallet-browser-c3a605f27a846b72227237cefa6e4590c8a3b2c1.tar.zst
tangerine-wallet-browser-c3a605f27a846b72227237cefa6e4590c8a3b2c1.zip
Merge pull request #6328 from MetaMask/clearNotices
Clear notices
Diffstat (limited to 'test')
-rw-r--r--test/unit/app/controllers/notice-controller-test.js25
-rw-r--r--test/unit/app/nodeify-test.js49
-rw-r--r--test/unit/ui/app/actions.spec.js23
3 files changed, 93 insertions, 4 deletions
diff --git a/test/unit/app/controllers/notice-controller-test.js b/test/unit/app/controllers/notice-controller-test.js
index 834c88f7b..caa50a03e 100644
--- a/test/unit/app/controllers/notice-controller-test.js
+++ b/test/unit/app/controllers/notice-controller-test.js
@@ -39,6 +39,31 @@ describe('notice-controller', function () {
})
})
+ describe('#markAllNoticesRead', () => {
+ it('marks all notices read', async () => {
+ 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)
+ })
+ })
+
describe('#getNextUnreadNotice', function () {
it('should retrieve the latest unread notice', function (done) {
var testList = [
diff --git a/test/unit/app/nodeify-test.js b/test/unit/app/nodeify-test.js
index 938b76c68..fa5e49fb2 100644
--- a/test/unit/app/nodeify-test.js
+++ b/test/unit/app/nodeify-test.js
@@ -2,16 +2,16 @@ const assert = require('assert')
const nodeify = require('../../../app/scripts/lib/nodeify')
describe('nodeify', function () {
- var obj = {
+ const obj = {
foo: 'bar',
promiseFunc: function (a) {
- var solution = this.foo + a
+ const solution = this.foo + a
return Promise.resolve(solution)
},
}
it('should retain original context', function (done) {
- var nodified = nodeify(obj.promiseFunc, obj)
+ const nodified = nodeify(obj.promiseFunc, obj)
nodified('baz', function (err, res) {
if (!err) {
assert.equal(res, 'barbaz')
@@ -22,7 +22,7 @@ describe('nodeify', function () {
})
})
- it('should allow the last argument to not be a function', function (done) {
+ it('no callback - should allow the last argument to not be a function', function (done) {
const nodified = nodeify(obj.promiseFunc, obj)
try {
nodified('baz')
@@ -31,4 +31,45 @@ describe('nodeify', function () {
done(new Error('should not have thrown if the last argument is not a function'))
}
})
+
+ it('no callback - should asyncly throw an error if underlying function does', function (done) {
+ const nodified = nodeify(async () => { throw new Error('boom!') }, obj)
+ process.prependOnceListener('uncaughtException', function (err) {
+ assert.ok(err, 'got expected error')
+ assert.ok(err.message.includes('boom!'), 'got expected error message')
+ done()
+ })
+ try {
+ nodified('baz')
+ } catch (err) {
+ done(new Error('should not have thrown an error synchronously'))
+ }
+ })
+
+ it('sync functions - returns value', function (done) {
+ const nodified = nodeify(() => 42)
+ try {
+ nodified((err, result) => {
+ if (err) return done(new Error(`should not have thrown any error: ${err.message}`))
+ assert.equal(42, result, 'got expected result')
+ })
+ done()
+ } catch (err) {
+ done(new Error(`should not have thrown any error: ${err.message}`))
+ }
+ })
+
+ it('sync functions - handles errors', function (done) {
+ const nodified = nodeify(() => { throw new Error('boom!') })
+ try {
+ nodified((err, result) => {
+ if (result) return done(new Error('should not have returned any result'))
+ assert.ok(err, 'got expected error')
+ assert.ok(err.message.includes('boom!'), 'got expected error message')
+ })
+ done()
+ } catch (err) {
+ done(new Error(`should not have thrown any error: ${err.message}`))
+ }
+ })
})
diff --git a/test/unit/ui/app/actions.spec.js b/test/unit/ui/app/actions.spec.js
index 46e94bb32..a578ec89c 100644
--- a/test/unit/ui/app/actions.spec.js
+++ b/test/unit/ui/app/actions.spec.js
@@ -1308,6 +1308,29 @@ describe('Actions', () => {
})
})
+ describe('#setCompletedOnboarding', () => {
+ let markAllNoticesReadSpy, completeOnboardingSpy
+
+ beforeEach(() => {
+ markAllNoticesReadSpy = sinon.stub(background, 'markAllNoticesRead')
+ markAllNoticesReadSpy.callsFake(cb => cb())
+ completeOnboardingSpy = sinon.stub(background, 'completeOnboarding')
+ completeOnboardingSpy.callsFake(cb => cb())
+ })
+
+ after(() => {
+ markAllNoticesReadSpy.restore()
+ completeOnboardingSpy.restore()
+ })
+
+ it('completing onboarding marks all notices as read', async () => {
+ const store = mockStore()
+ await store.dispatch(actions.setCompletedOnboarding())
+ assert.equal(markAllNoticesReadSpy.callCount, 1)
+ assert.equal(completeOnboardingSpy.callCount, 1)
+ })
+ })
+
describe('#updateNetworkNonce', () => {
let getTransactionCountSpy