mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
Convert spec/title-bar-spec.coffee to js
Signed-off-by: Jason Rudolph <jasonrudolph@github.com>
This commit is contained in:
committed by
Jason Rudolph
parent
62ee913567
commit
a7b1996245
@@ -1,47 +0,0 @@
|
||||
TitleBar = require '../src/title-bar'
|
||||
temp = require 'temp'
|
||||
|
||||
describe "TitleBar", ->
|
||||
it "updates its title when document.title changes", ->
|
||||
titleBar = new TitleBar({
|
||||
workspace: atom.workspace,
|
||||
themes: atom.themes,
|
||||
applicationDelegate: atom.applicationDelegate,
|
||||
})
|
||||
expect(titleBar.element.querySelector('.title').textContent).toBe(document.title)
|
||||
|
||||
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", ->
|
||||
titleBar = new TitleBar({
|
||||
workspace: atom.workspace,
|
||||
themes: atom.themes,
|
||||
applicationDelegate: atom.applicationDelegate,
|
||||
})
|
||||
expect(-> titleBar.updateWindowSheetOffset()).not.toThrow()
|
||||
|
||||
class FakePaneItem
|
||||
constructor: (title) ->
|
||||
@title = title
|
||||
|
||||
getTitle: ->
|
||||
@title
|
||||
|
||||
onDidChangeTitle: (callback) ->
|
||||
@didChangeTitleCallback = callback
|
||||
{dispose: => @didChangeTitleCallback = null}
|
||||
|
||||
setTitle: (title) ->
|
||||
@title = title
|
||||
@didChangeTitleCallback?(title)
|
||||
57
spec/title-bar-spec.js
Normal file
57
spec/title-bar-spec.js
Normal file
@@ -0,0 +1,57 @@
|
||||
const TitleBar = require('../src/title-bar')
|
||||
const temp = require('temp')
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user