Skip to content

Commit

Permalink
Support for multiple notifications on page (#325)
Browse files Browse the repository at this point in the history
* WIP

* WIP

* Change dismissible to autoDismiss

* WIP

* WIP

* Fix tests

* Remove console.log

* Use hideNotification

* Open link in new window instead of external window due to lack of support in react notification system

* Remove soloInGroup

* Remove comma

* Remove react-transition-group

* Remove unused styles

* Remove unused code

* Add tests for notifications reducer

* Add tests

* Adds styling for the notification link

* Use constants

* Rename to .test.js

* Set default titles

* Change some of the messages to look better with titles

* Fix test

* Move const to the if block

* Correct casing

* Correct casing
  • Loading branch information
evgenyboxer authored and dvdschwrtz committed Nov 16, 2017
1 parent 2c7c83f commit 405fae7
Show file tree
Hide file tree
Showing 35 changed files with 762 additions and 494 deletions.
75 changes: 53 additions & 22 deletions __tests__/components/Claim.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import { shallow, mount } from 'enzyme'
import Claim from '../../app/containers/Claim'
import * as neonjs from 'neon-js'
import { setClaimRequest, disableClaim } from '../../app/modules/claim'
import { SHOW_NOTIFICATION, HIDE_NOTIFICATIONS, DEFAULT_POSITION } from '../../app/modules/notifications'
import { NOTIFICATION_LEVELS } from '../../app/core/constants'

const initialState = {
claim: {
Expand Down Expand Up @@ -77,20 +79,34 @@ describe('Claim', () => {

await Promise.resolve().then().then().then()
const actions = store.getActions()
expect(actions.length).toEqual(2)
expect(actions.length).toEqual(4)
expect(actions[0]).toEqual({
payload: {
message: 'Sending Neo to Yourself...',
type: 'INFO'
},
type: 'SHOW_NOTIFICATION'
type: HIDE_NOTIFICATIONS,
payload: expect.objectContaining({
dismissible: true,
position: DEFAULT_POSITION
})
})
expect(actions[1]).toEqual({
payload: {
type: SHOW_NOTIFICATION,
payload: expect.objectContaining({
message: 'Sending Neo to Yourself...',
level: NOTIFICATION_LEVELS.INFO
})
})
expect(actions[2]).toEqual({
type: HIDE_NOTIFICATIONS,
payload: expect.objectContaining({
dismissible: true,
position: DEFAULT_POSITION
})
})
expect(actions[3]).toEqual({
type: SHOW_NOTIFICATION,
payload: expect.objectContaining({
message: 'Transaction failed!',
type: 'ERROR'
},
type: 'SHOW_NOTIFICATION'
level: NOTIFICATION_LEVELS.ERROR
})
})
})

Expand All @@ -106,23 +122,38 @@ describe('Claim', () => {

await Promise.resolve().then().then().then()
const actions = store.getActions()
expect(actions.length).toEqual(4)
expect(actions.length).toEqual(6)
expect(actions[0]).toEqual({
payload: {
message: 'Sending Neo to Yourself...',
type: 'INFO'
},
type: 'SHOW_NOTIFICATION'
type: HIDE_NOTIFICATIONS,
payload: expect.objectContaining({
dismissible: true,
position: DEFAULT_POSITION
})
})
expect(actions[1]).toEqual({
payload: {
type: SHOW_NOTIFICATION,
payload: expect.objectContaining({
message: 'Sending Neo to Yourself...',
level: NOTIFICATION_LEVELS.INFO
})
})

expect(actions[2]).toEqual({
type: HIDE_NOTIFICATIONS,
payload: expect.objectContaining({
dismissible: true,
position: DEFAULT_POSITION
})
})
expect(actions[3]).toEqual({
type: SHOW_NOTIFICATION,
payload: expect.objectContaining({
message: 'Waiting for transaction to clear...',
type: 'INFO'
},
type: 'SHOW_NOTIFICATION'
level: NOTIFICATION_LEVELS.INFO
})
})
expect(actions[2]).toEqual(setClaimRequest(true))
expect(actions[3]).toEqual(disableClaim(true))
expect(actions[4]).toEqual(setClaimRequest(true))
expect(actions[5]).toEqual(disableClaim(true))
})
})
})
16 changes: 10 additions & 6 deletions __tests__/components/LoginNep2.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import { shallow, mount } from 'enzyme'
import { createMemoryHistory } from 'history'
import LoginNep2 from '../../app/containers/LoginNep2'
import { decryptWIF } from 'neon-js'
import { SHOW_NOTIFICATION, HIDE_NOTIFICATION } from '../../app/modules/notification'
import { LOGIN } from '../../app/modules/account'
import { SHOW_NOTIFICATION, HIDE_NOTIFICATIONS, HIDE_NOTIFICATION, DEFAULT_POSITION } from '../../app/modules/notifications'
import { NOTIFICATION_LEVELS } from '../../app/core/constants'

jest.useFakeTimers()
jest.mock('neon-js')
Expand Down Expand Up @@ -110,14 +110,18 @@ describe('LoginNep2', () => {
expect(decryptWIF.mock.calls.length).toBe(1)
expect(decryptWIF.mock.calls[0][0]).toBe('6PYUGtvXiT5TBetgWf77QyAFidQj61V8FJeFBFtYttmsSxcbmP4vCFRCWu')
expect(actions[0]).toEqual({
type: SHOW_NOTIFICATION,
type: HIDE_NOTIFICATIONS,
payload: {
message: 'Decrypting encoded key...',
type: 'INFO'
dismissible: true,
position: DEFAULT_POSITION
}
})
expect(actions[1]).toEqual({
type: HIDE_NOTIFICATION
type: SHOW_NOTIFICATION,
payload: expect.objectContaining({
message: 'Decrypting encoded key...',
level: NOTIFICATION_LEVELS.INFO
})
})
done()
})
Expand Down
3 changes: 1 addition & 2 deletions __tests__/components/Logout.test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import React from 'react'
import { shallow } from 'enzyme'
import Logout from '../../app/components/Logout'
import { logout } from '../../app/modules/account'
//

describe('Logout', () => {
const logout = jest.fn()
test('should render without crashing', () => {
Expand Down
Loading

0 comments on commit 405fae7

Please sign in to comment.