Support passing escape item to TouchBar constructor

This commit is contained in:
Kevin Sawicki 2017-04-03 15:12:57 -07:00
parent b24b4212c5
commit 414540bfcb
3 changed files with 28 additions and 9 deletions

View file

@ -6,23 +6,28 @@ const {TouchBarButton, TouchBarColorPicker, TouchBarGroup} = TouchBar
const {TouchBarLabel, TouchBarPopover, TouchBarScrubber, TouchBarSegmentedControl, TouchBarSlider, TouchBarSpacer} = TouchBar
describe('TouchBar module', function () {
it('throws an error when created without an items array', function () {
it('throws an error when created without an options object', function () {
assert.throws(() => {
const touchBar = new TouchBar()
touchBar.toString()
}, /Must specify items array as first argument/)
}, /Must specify options object as first argument/)
})
it('throws an error when created with invalid items', function () {
assert.throws(() => {
const touchBar = new TouchBar([1, true, {}, []])
const touchBar = new TouchBar({items: [1, true, {}, []]})
touchBar.toString()
}, /Each item must be an instance of TouchBarItem/)
})
it('throws an error when an invalid escape item is set', function () {
assert.throws(() => {
const touchBar = new TouchBar([])
const touchBar = new TouchBar({items: [], escapeItem: 'esc'})
touchBar.toString()
}, /Escape item must be an instance of TouchBarItem/)
assert.throws(() => {
const touchBar = new TouchBar({items: []})
touchBar.escapeItem = 'esc'
}, /Escape item must be an instance of TouchBarItem/)
})