forked from atom/atom
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtitle-bar-spec.js
67 lines (58 loc) · 1.75 KB
/
title-bar-spec.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
const TitleBar = require('../src/title-bar')
const temp = require('temp').track()
describe('TitleBar', () => {
it('updates its title when document.title changes', () => {
const titleBar = new TitleBar({
workspace: atom.workspace,
themes: atom.themes,
applicationDelegate: atom.applicationDelegate
})
expect(titleBar.element.querySelector('.title').textContent).toBe(
document.title
)
const paneItem = new FakePaneItem('Title 1')
atom.workspace.getActivePane().activateItem(paneItem)
expect(document.title).toMatch('Title 1')
expect(titleBar.element.querySelector('.title').textContent).toBe(
document.title
)
paneItem.setTitle('Title 2')
expect(document.title).toMatch('Title 2')
expect(titleBar.element.querySelector('.title').textContent).toBe(
document.title
)
atom.project.setPaths([temp.mkdirSync('project-1')])
expect(document.title).toMatch('project-1')
expect(titleBar.element.querySelector('.title').textContent).toBe(
document.title
)
})
it('can update the sheet offset for the current window based on its height', () => {
const titleBar = new TitleBar({
workspace: atom.workspace,
themes: atom.themes,
applicationDelegate: atom.applicationDelegate
})
expect(() => titleBar.updateWindowSheetOffset()).not.toThrow()
})
})
class FakePaneItem {
constructor (title) {
this.title = title
}
getTitle () {
return this.title
}
onDidChangeTitle (callback) {
this.didChangeTitleCallback = callback
return {
dispose: () => {
this.didChangeTitleCallback = null
}
}
}
setTitle (title) {
this.title = title
if (this.didChangeTitleCallback) this.didChangeTitleCallback(title)
}
}