update touch bar spec
This commit is contained in:
parent
1130ccf69b
commit
0317189213
1 changed files with 12 additions and 14 deletions
|
@ -6,22 +6,22 @@ const {closeWindow} = require('./window-helpers')
|
||||||
const {TouchBarButton, TouchBarColorPicker, TouchBarGroup} = TouchBar
|
const {TouchBarButton, TouchBarColorPicker, TouchBarGroup} = TouchBar
|
||||||
const {TouchBarLabel, TouchBarPopover, TouchBarScrubber, TouchBarSegmentedControl, TouchBarSlider, TouchBarSpacer} = TouchBar
|
const {TouchBarLabel, TouchBarPopover, TouchBarScrubber, TouchBarSegmentedControl, TouchBarSlider, TouchBarSpacer} = TouchBar
|
||||||
|
|
||||||
describe('TouchBar module', function () {
|
describe('TouchBar module', () => {
|
||||||
it('throws an error when created without an options object', function () {
|
it('throws an error when created without an options object', () => {
|
||||||
assert.throws(() => {
|
assert.throws(() => {
|
||||||
const touchBar = new TouchBar()
|
const touchBar = new TouchBar()
|
||||||
touchBar.toString()
|
touchBar.toString()
|
||||||
}, /Must specify options object as first argument/)
|
}, /Must specify options object as first argument/)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('throws an error when created with invalid items', function () {
|
it('throws an error when created with invalid items', () => {
|
||||||
assert.throws(() => {
|
assert.throws(() => {
|
||||||
const touchBar = new TouchBar({items: [1, true, {}, []]})
|
const touchBar = new TouchBar({items: [1, true, {}, []]})
|
||||||
touchBar.toString()
|
touchBar.toString()
|
||||||
}, /Each item must be an instance of TouchBarItem/)
|
}, /Each item must be an instance of TouchBarItem/)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('throws an error when an invalid escape item is set', function () {
|
it('throws an error when an invalid escape item is set', () => {
|
||||||
assert.throws(() => {
|
assert.throws(() => {
|
||||||
const touchBar = new TouchBar({items: [], escapeItem: 'esc'})
|
const touchBar = new TouchBar({items: [], escapeItem: 'esc'})
|
||||||
touchBar.toString()
|
touchBar.toString()
|
||||||
|
@ -33,19 +33,19 @@ describe('TouchBar module', function () {
|
||||||
}, /Escape item must be an instance of TouchBarItem/)
|
}, /Escape item must be an instance of TouchBarItem/)
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('BrowserWindow behavior', function () {
|
describe('BrowserWindow behavior', () => {
|
||||||
let window
|
let window
|
||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(() => {
|
||||||
window = new BrowserWindow()
|
window = new BrowserWindow()
|
||||||
})
|
})
|
||||||
|
|
||||||
afterEach(function () {
|
afterEach(() => {
|
||||||
window.setTouchBar(null)
|
window.setTouchBar(null)
|
||||||
return closeWindow(window).then(function () { window = null })
|
return closeWindow(window).then(() => { window = null })
|
||||||
})
|
})
|
||||||
|
|
||||||
it('can be added to and removed from a window', function () {
|
it('can be added to and removed from a window', () => {
|
||||||
const label = new TouchBarLabel({label: 'bar'})
|
const label = new TouchBarLabel({label: 'bar'})
|
||||||
const touchBar = new TouchBar([
|
const touchBar = new TouchBar([
|
||||||
new TouchBarButton({label: 'foo', backgroundColor: '#F00', click: () => {}}),
|
new TouchBarButton({label: 'foo', backgroundColor: '#F00', click: () => {}}),
|
||||||
|
@ -73,9 +73,7 @@ describe('TouchBar module', function () {
|
||||||
showArrowButtons: true
|
showArrowButtons: true
|
||||||
})
|
})
|
||||||
])
|
])
|
||||||
const escapeButton = new TouchBarButton({
|
const escapeButton = new TouchBarButton({label: 'foo'})
|
||||||
label: 'foo'
|
|
||||||
})
|
|
||||||
window.setTouchBar(touchBar)
|
window.setTouchBar(touchBar)
|
||||||
touchBar.escapeItem = escapeButton
|
touchBar.escapeItem = escapeButton
|
||||||
label.label = 'baz'
|
label.label = 'baz'
|
||||||
|
@ -85,7 +83,7 @@ describe('TouchBar module', function () {
|
||||||
touchBar.escapeItem = null
|
touchBar.escapeItem = null
|
||||||
})
|
})
|
||||||
|
|
||||||
it('calls the callback on the items when a window interaction event fires', function (done) {
|
it('calls the callback on the items when a window interaction event fires', (done) => {
|
||||||
const button = new TouchBarButton({
|
const button = new TouchBarButton({
|
||||||
label: 'bar',
|
label: 'bar',
|
||||||
click: () => {
|
click: () => {
|
||||||
|
@ -97,7 +95,7 @@ describe('TouchBar module', function () {
|
||||||
window.emit('-touch-bar-interaction', {}, button.id)
|
window.emit('-touch-bar-interaction', {}, button.id)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('calls the callback on the escape item when a window interaction event fires', function (done) {
|
it('calls the callback on the escape item when a window interaction event fires', (done) => {
|
||||||
const button = new TouchBarButton({
|
const button = new TouchBarButton({
|
||||||
label: 'bar',
|
label: 'bar',
|
||||||
click: () => {
|
click: () => {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue