electron/spec/api-notification-spec.js

98 lines
2.4 KiB
JavaScript
Raw Normal View History

const chai = require('chai')
const dirtyChai = require('dirty-chai')
2018-09-13 16:10:51 +00:00
const { expect } = chai
chai.use(dirtyChai)
2018-02-07 06:09:23 +00:00
2018-09-13 16:10:51 +00:00
const { Notification } = require('electron').remote
2018-02-07 06:09:23 +00:00
describe('Notification module', () => {
it('inits, gets and sets basic string properties correctly', () => {
const n = new Notification({
title: 'title',
subtitle: 'subtitle',
body: 'body',
replyPlaceholder: 'replyPlaceholder',
sound: 'sound',
closeButtonText: 'closeButtonText'
})
expect(n.title).to.equal('title')
2018-02-07 06:09:23 +00:00
n.title = 'title1'
expect(n.title).to.equal('title1')
2018-02-07 06:09:23 +00:00
expect(n.subtitle).equal('subtitle')
2018-02-07 06:09:23 +00:00
n.subtitle = 'subtitle1'
expect(n.subtitle).equal('subtitle1')
2018-02-07 06:09:23 +00:00
expect(n.body).to.equal('body')
2018-02-07 06:09:23 +00:00
n.body = 'body1'
expect(n.body).to.equal('body1')
2018-02-07 06:09:23 +00:00
expect(n.replyPlaceholder).to.equal('replyPlaceholder')
2018-02-07 06:09:23 +00:00
n.replyPlaceholder = 'replyPlaceholder1'
expect(n.replyPlaceholder).to.equal('replyPlaceholder1')
2018-02-07 06:09:23 +00:00
expect(n.sound).to.equal('sound')
2018-02-07 06:09:23 +00:00
n.sound = 'sound1'
expect(n.sound).to.equal('sound1')
2018-02-07 06:09:23 +00:00
expect(n.closeButtonText).to.equal('closeButtonText')
2018-02-07 06:09:23 +00:00
n.closeButtonText = 'closeButtonText1'
expect(n.closeButtonText).to.equal('closeButtonText1')
2018-02-07 06:09:23 +00:00
})
it('inits, gets and sets basic boolean properties correctly', () => {
const n = new Notification({
silent: true,
hasReply: true
})
expect(n.silent).to.be.true()
2018-02-07 06:09:23 +00:00
n.silent = false
expect(n.silent).to.be.false()
2018-02-07 06:09:23 +00:00
expect(n.hasReply).to.be.true()
2018-02-07 06:09:23 +00:00
n.hasReply = false
expect(n.hasReply).to.be.false()
2018-02-07 06:09:23 +00:00
})
it('inits, gets and sets actions correctly', () => {
const n = new Notification({
actions: [
{
type: 'button',
text: '1'
}, {
type: 'button',
text: '2'
}
]
})
expect(n.actions.length).to.equal(2)
expect(n.actions[0].type).to.equal('button')
expect(n.actions[0].text).to.equal('1')
expect(n.actions[1].type).to.equal('button')
expect(n.actions[1].text).to.equal('2')
2018-02-07 06:09:23 +00:00
n.actions = [
{
type: 'button',
text: '3'
}, {
type: 'button',
text: '4'
}
]
expect(n.actions.length).to.equal(2)
expect(n.actions[0].type).to.equal('button')
expect(n.actions[0].text).to.equal('3')
expect(n.actions[1].type).to.equal('button')
expect(n.actions[1].text).to.equal('4')
2018-02-07 06:09:23 +00:00
})
// TODO(sethlu): Find way to test init with notification icon?
})