mirror of
https://github.com/atom/atom.git
synced 2026-02-13 16:14:59 -05:00
Merge branch 'master' into wl-build-on-node-7
This commit is contained in:
@@ -142,6 +142,11 @@ describe "AtomEnvironment", ->
|
||||
atom.assert(false, "a == b", (e) -> error = e)
|
||||
expect(error).toBe errors[0]
|
||||
|
||||
describe "if passed metadata", ->
|
||||
it "assigns the metadata on the assertion failure's error object", ->
|
||||
atom.assert(false, "a == b", {foo: 'bar'})
|
||||
expect(errors[0].metadata).toEqual {foo: 'bar'}
|
||||
|
||||
describe "if the condition is true", ->
|
||||
it "does nothing", ->
|
||||
result = atom.assert(true, "a == b")
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
path = require 'path'
|
||||
process = require 'process'
|
||||
_ = require 'underscore-plus'
|
||||
grim = require 'grim'
|
||||
marked = require 'marked'
|
||||
@@ -20,12 +21,15 @@ formatStackTrace = (spec, message='', stackTrace) ->
|
||||
lines.shift() if message.trim() is errorMatch?[1]?.trim()
|
||||
|
||||
for line, index in lines
|
||||
# Remove prefix of lines matching: at [object Object].<anonymous> (path:1:2)
|
||||
prefixMatch = line.match(/at \[object Object\]\.<anonymous> \(([^)]+)\)/)
|
||||
# Remove prefix of lines matching: at .<anonymous> (path:1:2)
|
||||
prefixMatch = line.match(/at \.<anonymous> \(([^)]+)\)/)
|
||||
line = "at #{prefixMatch[1]}" if prefixMatch
|
||||
|
||||
# Relativize locations to spec directory
|
||||
lines[index] = line.replace("at #{spec.specDirectory}#{path.sep}", 'at ')
|
||||
if process.platform is 'win32'
|
||||
line = line.replace('file:///', '').replace(///#{path.posix.sep}///g, path.win32.sep)
|
||||
line = line.replace("at #{spec.specDirectory}#{path.sep}", 'at ')
|
||||
lines[index] = line.replace("(#{spec.specDirectory}#{path.sep}", '(') # at step (path:1:2)
|
||||
|
||||
lines = lines.map (line) -> line.trim()
|
||||
lines.join('\n').trim()
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
DecorationManager = require '../src/decoration-manager'
|
||||
|
||||
describe "DecorationManager", ->
|
||||
[decorationManager, buffer, defaultMarkerLayer] = []
|
||||
[decorationManager, buffer, displayLayer, markerLayer1, markerLayer2] = []
|
||||
|
||||
beforeEach ->
|
||||
buffer = atom.project.bufferForPathSync('sample.js')
|
||||
displayLayer = buffer.addDisplayLayer()
|
||||
defaultMarkerLayer = displayLayer.addMarkerLayer()
|
||||
decorationManager = new DecorationManager(displayLayer, defaultMarkerLayer)
|
||||
markerLayer1 = displayLayer.addMarkerLayer()
|
||||
markerLayer2 = displayLayer.addMarkerLayer()
|
||||
decorationManager = new DecorationManager(displayLayer)
|
||||
|
||||
waitsForPromise ->
|
||||
atom.packages.activatePackage('language-javascript')
|
||||
@@ -17,38 +18,53 @@ describe "DecorationManager", ->
|
||||
buffer.release()
|
||||
|
||||
describe "decorations", ->
|
||||
[marker, decoration, decorationProperties] = []
|
||||
[layer1Marker, layer2Marker, layer1MarkerDecoration, layer2MarkerDecoration, decorationProperties] = []
|
||||
beforeEach ->
|
||||
marker = defaultMarkerLayer.markBufferRange([[2, 13], [3, 15]])
|
||||
layer1Marker = markerLayer1.markBufferRange([[2, 13], [3, 15]])
|
||||
decorationProperties = {type: 'line-number', class: 'one'}
|
||||
decoration = decorationManager.decorateMarker(marker, decorationProperties)
|
||||
layer1MarkerDecoration = decorationManager.decorateMarker(layer1Marker, decorationProperties)
|
||||
layer2Marker = markerLayer2.markBufferRange([[2, 13], [3, 15]])
|
||||
layer2MarkerDecoration = decorationManager.decorateMarker(layer2Marker, decorationProperties)
|
||||
|
||||
it "can add decorations associated with markers and remove them", ->
|
||||
expect(decoration).toBeDefined()
|
||||
expect(decoration.getProperties()).toBe decorationProperties
|
||||
expect(decorationManager.decorationForId(decoration.id)).toBe decoration
|
||||
expect(decorationManager.decorationsForScreenRowRange(2, 3)[marker.id][0]).toBe decoration
|
||||
expect(layer1MarkerDecoration).toBeDefined()
|
||||
expect(layer1MarkerDecoration.getProperties()).toBe decorationProperties
|
||||
expect(decorationManager.decorationForId(layer1MarkerDecoration.id)).toBe layer1MarkerDecoration
|
||||
expect(decorationManager.decorationsForScreenRowRange(2, 3)).toEqual {
|
||||
"#{layer1Marker.id}": [layer1MarkerDecoration],
|
||||
"#{layer2Marker.id}": [layer2MarkerDecoration]
|
||||
}
|
||||
|
||||
decoration.destroy()
|
||||
expect(decorationManager.decorationsForScreenRowRange(2, 3)[marker.id]).not.toBeDefined()
|
||||
expect(decorationManager.decorationForId(decoration.id)).not.toBeDefined()
|
||||
layer1MarkerDecoration.destroy()
|
||||
expect(decorationManager.decorationsForScreenRowRange(2, 3)[layer1Marker.id]).not.toBeDefined()
|
||||
expect(decorationManager.decorationForId(layer1MarkerDecoration.id)).not.toBeDefined()
|
||||
layer2MarkerDecoration.destroy()
|
||||
expect(decorationManager.decorationsForScreenRowRange(2, 3)[layer2Marker.id]).not.toBeDefined()
|
||||
expect(decorationManager.decorationForId(layer2MarkerDecoration.id)).not.toBeDefined()
|
||||
|
||||
it "will not fail if the decoration is removed twice", ->
|
||||
decoration.destroy()
|
||||
decoration.destroy()
|
||||
expect(decorationManager.decorationForId(decoration.id)).not.toBeDefined()
|
||||
layer1MarkerDecoration.destroy()
|
||||
layer1MarkerDecoration.destroy()
|
||||
expect(decorationManager.decorationForId(layer1MarkerDecoration.id)).not.toBeDefined()
|
||||
|
||||
it "does not allow destroyed markers to be decorated", ->
|
||||
marker.destroy()
|
||||
layer1Marker.destroy()
|
||||
expect(->
|
||||
decorationManager.decorateMarker(marker, {type: 'overlay', item: document.createElement('div')})
|
||||
decorationManager.decorateMarker(layer1Marker, {type: 'overlay', item: document.createElement('div')})
|
||||
).toThrow("Cannot decorate a destroyed marker")
|
||||
expect(decorationManager.getOverlayDecorations()).toEqual []
|
||||
|
||||
it "does not allow destroyed marker layers to be decorated", ->
|
||||
layer = displayLayer.addMarkerLayer()
|
||||
layer.destroy()
|
||||
expect(->
|
||||
decorationManager.decorateMarkerLayer(layer, {type: 'highlight'})
|
||||
).toThrow("Cannot decorate a destroyed marker layer")
|
||||
|
||||
describe "when a decoration is updated via Decoration::update()", ->
|
||||
it "emits an 'updated' event containing the new and old params", ->
|
||||
decoration.onDidChangeProperties updatedSpy = jasmine.createSpy()
|
||||
decoration.setProperties type: 'line-number', class: 'two'
|
||||
layer1MarkerDecoration.onDidChangeProperties updatedSpy = jasmine.createSpy()
|
||||
layer1MarkerDecoration.setProperties type: 'line-number', class: 'two'
|
||||
|
||||
{oldProperties, newProperties} = updatedSpy.mostRecentCall.args[0]
|
||||
expect(oldProperties).toEqual decorationProperties
|
||||
@@ -56,29 +72,29 @@ describe "DecorationManager", ->
|
||||
|
||||
describe "::getDecorations(properties)", ->
|
||||
it "returns decorations matching the given optional properties", ->
|
||||
expect(decorationManager.getDecorations()).toEqual [decoration]
|
||||
expect(decorationManager.getDecorations()).toEqual [layer1MarkerDecoration, layer2MarkerDecoration]
|
||||
expect(decorationManager.getDecorations(class: 'two').length).toEqual 0
|
||||
expect(decorationManager.getDecorations(class: 'one').length).toEqual 1
|
||||
expect(decorationManager.getDecorations(class: 'one').length).toEqual 2
|
||||
|
||||
describe "::decorateMarker", ->
|
||||
describe "when decorating gutters", ->
|
||||
[marker] = []
|
||||
[layer1Marker] = []
|
||||
|
||||
beforeEach ->
|
||||
marker = defaultMarkerLayer.markBufferRange([[1, 0], [1, 0]])
|
||||
layer1Marker = markerLayer1.markBufferRange([[1, 0], [1, 0]])
|
||||
|
||||
it "creates a decoration that is both of 'line-number' and 'gutter' type when called with the 'line-number' type", ->
|
||||
decorationProperties = {type: 'line-number', class: 'one'}
|
||||
decoration = decorationManager.decorateMarker(marker, decorationProperties)
|
||||
expect(decoration.isType('line-number')).toBe true
|
||||
expect(decoration.isType('gutter')).toBe true
|
||||
expect(decoration.getProperties().gutterName).toBe 'line-number'
|
||||
expect(decoration.getProperties().class).toBe 'one'
|
||||
layer1MarkerDecoration = decorationManager.decorateMarker(layer1Marker, decorationProperties)
|
||||
expect(layer1MarkerDecoration.isType('line-number')).toBe true
|
||||
expect(layer1MarkerDecoration.isType('gutter')).toBe true
|
||||
expect(layer1MarkerDecoration.getProperties().gutterName).toBe 'line-number'
|
||||
expect(layer1MarkerDecoration.getProperties().class).toBe 'one'
|
||||
|
||||
it "creates a decoration that is only of 'gutter' type if called with the 'gutter' type and a 'gutterName'", ->
|
||||
decorationProperties = {type: 'gutter', gutterName: 'test-gutter', class: 'one'}
|
||||
decoration = decorationManager.decorateMarker(marker, decorationProperties)
|
||||
expect(decoration.isType('gutter')).toBe true
|
||||
expect(decoration.isType('line-number')).toBe false
|
||||
expect(decoration.getProperties().gutterName).toBe 'test-gutter'
|
||||
expect(decoration.getProperties().class).toBe 'one'
|
||||
layer1MarkerDecoration = decorationManager.decorateMarker(layer1Marker, decorationProperties)
|
||||
expect(layer1MarkerDecoration.isType('gutter')).toBe true
|
||||
expect(layer1MarkerDecoration.isType('line-number')).toBe false
|
||||
expect(layer1MarkerDecoration.getProperties().gutterName).toBe 'test-gutter'
|
||||
expect(layer1MarkerDecoration.getProperties().class).toBe 'one'
|
||||
|
||||
@@ -28,6 +28,15 @@ describe "DefaultDirectoryProvider", ->
|
||||
directory = provider.directoryForURISync(nonNormalizedPath)
|
||||
expect(directory.getPath()).toEqual tmp
|
||||
|
||||
it "normalizes disk drive letter in path on #win32", ->
|
||||
provider = new DefaultDirectoryProvider()
|
||||
nonNormalizedPath = tmp[0].toLowerCase()+tmp.slice(1)
|
||||
expect(tmp).not.toMatch /^[a-z]:/
|
||||
expect(nonNormalizedPath).toMatch /^[a-z]:/
|
||||
|
||||
directory = provider.directoryForURISync(nonNormalizedPath)
|
||||
expect(directory.getPath()).toEqual tmp
|
||||
|
||||
it "creates a Directory for its parent dir when passed a file", ->
|
||||
provider = new DefaultDirectoryProvider()
|
||||
file = path.join(tmp, "example.txt")
|
||||
|
||||
@@ -1,60 +0,0 @@
|
||||
DOMElementPool = require '../src/dom-element-pool'
|
||||
{contains} = require 'underscore-plus'
|
||||
|
||||
describe "DOMElementPool", ->
|
||||
domElementPool = null
|
||||
|
||||
beforeEach ->
|
||||
domElementPool = new DOMElementPool
|
||||
|
||||
it "builds DOM nodes, recycling them when they are freed", ->
|
||||
[div, span1, span2, span3, span4, span5, textNode] = elements = [
|
||||
domElementPool.buildElement("div")
|
||||
domElementPool.buildElement("span")
|
||||
domElementPool.buildElement("span")
|
||||
domElementPool.buildElement("span")
|
||||
domElementPool.buildElement("span")
|
||||
domElementPool.buildElement("span")
|
||||
domElementPool.buildText("Hello world!")
|
||||
]
|
||||
|
||||
div.appendChild(span1)
|
||||
span1.appendChild(span2)
|
||||
div.appendChild(span3)
|
||||
span3.appendChild(span4)
|
||||
span4.appendChild(textNode)
|
||||
|
||||
domElementPool.freeElementAndDescendants(div)
|
||||
domElementPool.freeElementAndDescendants(span5)
|
||||
|
||||
expect(contains(elements, domElementPool.buildElement("div"))).toBe(true)
|
||||
expect(contains(elements, domElementPool.buildElement("span"))).toBe(true)
|
||||
expect(contains(elements, domElementPool.buildElement("span"))).toBe(true)
|
||||
expect(contains(elements, domElementPool.buildElement("span"))).toBe(true)
|
||||
expect(contains(elements, domElementPool.buildElement("span"))).toBe(true)
|
||||
expect(contains(elements, domElementPool.buildElement("span"))).toBe(true)
|
||||
expect(contains(elements, domElementPool.buildText("another text"))).toBe(true)
|
||||
|
||||
expect(contains(elements, domElementPool.buildElement("div"))).toBe(false)
|
||||
expect(contains(elements, domElementPool.buildElement("span"))).toBe(false)
|
||||
expect(contains(elements, domElementPool.buildText("unexisting"))).toBe(false)
|
||||
|
||||
it "forgets free nodes after being cleared", ->
|
||||
span = domElementPool.buildElement("span")
|
||||
div = domElementPool.buildElement("div")
|
||||
domElementPool.freeElementAndDescendants(span)
|
||||
domElementPool.freeElementAndDescendants(div)
|
||||
|
||||
domElementPool.clear()
|
||||
|
||||
expect(domElementPool.buildElement("span")).not.toBe(span)
|
||||
expect(domElementPool.buildElement("div")).not.toBe(div)
|
||||
|
||||
it "throws an error when trying to free the same node twice", ->
|
||||
div = domElementPool.buildElement("div")
|
||||
domElementPool.freeElementAndDescendants(div)
|
||||
expect(-> domElementPool.freeElementAndDescendants(div)).toThrow()
|
||||
|
||||
it "throws an error when trying to free an invalid element", ->
|
||||
expect(-> domElementPool.freeElementAndDescendants(null)).toThrow()
|
||||
expect(-> domElementPool.freeElementAndDescendants(undefined)).toThrow()
|
||||
112
spec/dom-element-pool-spec.js
Normal file
112
spec/dom-element-pool-spec.js
Normal file
@@ -0,0 +1,112 @@
|
||||
const DOMElementPool = require ('../src/dom-element-pool')
|
||||
|
||||
describe('DOMElementPool', function () {
|
||||
let domElementPool
|
||||
|
||||
beforeEach(() => { domElementPool = new DOMElementPool() })
|
||||
|
||||
it('builds DOM nodes, recycling them when they are freed', function () {
|
||||
let elements
|
||||
const [div, span1, span2, span3, span4, span5, textNode] = Array.from(elements = [
|
||||
domElementPool.buildElement('div', 'foo'),
|
||||
domElementPool.buildElement('span'),
|
||||
domElementPool.buildElement('span'),
|
||||
domElementPool.buildElement('span'),
|
||||
domElementPool.buildElement('span'),
|
||||
domElementPool.buildElement('span'),
|
||||
domElementPool.buildText('Hello world!')
|
||||
])
|
||||
|
||||
expect(div.className).toBe('foo')
|
||||
div.textContent = 'testing'
|
||||
div.style.backgroundColor = 'red'
|
||||
div.dataset.foo = 'bar'
|
||||
|
||||
expect(textNode.textContent).toBe('Hello world!')
|
||||
|
||||
div.appendChild(span1)
|
||||
span1.appendChild(span2)
|
||||
div.appendChild(span3)
|
||||
span3.appendChild(span4)
|
||||
span4.appendChild(textNode)
|
||||
|
||||
domElementPool.freeElementAndDescendants(div)
|
||||
domElementPool.freeElementAndDescendants(span5)
|
||||
|
||||
expect(elements.includes(domElementPool.buildElement('div'))).toBe(true)
|
||||
expect(elements.includes(domElementPool.buildElement('span'))).toBe(true)
|
||||
expect(elements.includes(domElementPool.buildElement('span'))).toBe(true)
|
||||
expect(elements.includes(domElementPool.buildElement('span'))).toBe(true)
|
||||
expect(elements.includes(domElementPool.buildElement('span'))).toBe(true)
|
||||
expect(elements.includes(domElementPool.buildElement('span'))).toBe(true)
|
||||
expect(elements.includes(domElementPool.buildText('another text'))).toBe(true)
|
||||
|
||||
expect(elements.includes(domElementPool.buildElement('div'))).toBe(false)
|
||||
expect(elements.includes(domElementPool.buildElement('span'))).toBe(false)
|
||||
expect(elements.includes(domElementPool.buildText('unexisting'))).toBe(false)
|
||||
|
||||
expect(div.className).toBe('')
|
||||
expect(div.textContent).toBe('')
|
||||
expect(div.style.backgroundColor).toBe('')
|
||||
expect(div.dataset.foo).toBeUndefined()
|
||||
|
||||
expect(textNode.textContent).toBe('another text')
|
||||
})
|
||||
|
||||
it('forgets free nodes after being cleared', function () {
|
||||
const span = domElementPool.buildElement('span')
|
||||
const div = domElementPool.buildElement('div')
|
||||
domElementPool.freeElementAndDescendants(span)
|
||||
domElementPool.freeElementAndDescendants(div)
|
||||
|
||||
domElementPool.clear()
|
||||
|
||||
expect(domElementPool.buildElement('span')).not.toBe(span)
|
||||
expect(domElementPool.buildElement('div')).not.toBe(div)
|
||||
})
|
||||
|
||||
it('does not attempt to free nodes that were not created by the pool', () => {
|
||||
let assertionFailure
|
||||
atom.onDidFailAssertion((error) => assertionFailure = error)
|
||||
|
||||
const foreignDiv = document.createElement('div')
|
||||
const div = domElementPool.buildElement('div')
|
||||
div.appendChild(foreignDiv)
|
||||
domElementPool.freeElementAndDescendants(div)
|
||||
const span = domElementPool.buildElement('span')
|
||||
span.appendChild(foreignDiv)
|
||||
domElementPool.freeElementAndDescendants(span)
|
||||
|
||||
expect(assertionFailure).toBeUndefined()
|
||||
})
|
||||
|
||||
it('fails an assertion when freeing the same element twice', function () {
|
||||
let assertionFailure
|
||||
atom.onDidFailAssertion((error) => assertionFailure = error)
|
||||
|
||||
const div = domElementPool.buildElement('div')
|
||||
div.textContent = 'testing'
|
||||
domElementPool.freeElementAndDescendants(div)
|
||||
expect(assertionFailure).toBeUndefined()
|
||||
domElementPool.freeElementAndDescendants(div)
|
||||
expect(assertionFailure.message).toBe('Assertion failed: The element has already been freed!')
|
||||
expect(assertionFailure.metadata.content).toBe('<div>testing</div>')
|
||||
})
|
||||
|
||||
it('fails an assertion when freeing the same text node twice', function () {
|
||||
let assertionFailure
|
||||
atom.onDidFailAssertion((error) => assertionFailure = error)
|
||||
|
||||
const node = domElementPool.buildText('testing')
|
||||
domElementPool.freeElementAndDescendants(node)
|
||||
expect(assertionFailure).toBeUndefined()
|
||||
domElementPool.freeElementAndDescendants(node)
|
||||
expect(assertionFailure.message).toBe('Assertion failed: The element has already been freed!')
|
||||
expect(assertionFailure.metadata.content).toBe('testing')
|
||||
})
|
||||
|
||||
it('throws an error when trying to free an invalid element', function () {
|
||||
expect(() => domElementPool.freeElementAndDescendants(null)).toThrow()
|
||||
expect(() => domElementPool.freeElementAndDescendants(undefined)).toThrow()
|
||||
})
|
||||
})
|
||||
@@ -196,7 +196,9 @@ describe('AtomApplication', function () {
|
||||
it('persists window state based on the project directories', async function () {
|
||||
const tempDirPath = makeTempDir()
|
||||
const atomApplication = buildAtomApplication()
|
||||
const window1 = atomApplication.launch(parseCommandLine([path.join(tempDirPath, 'new-file')]))
|
||||
const nonExistentFilePath = path.join(tempDirPath, 'new-file')
|
||||
|
||||
const window1 = atomApplication.launch(parseCommandLine([nonExistentFilePath]))
|
||||
await evalInWebContents(window1.browserWindow.webContents, function (sendBackToMainProcess) {
|
||||
atom.workspace.observeActivePaneItem(function (textEditor) {
|
||||
if (textEditor) {
|
||||
@@ -205,17 +207,31 @@ describe('AtomApplication', function () {
|
||||
}
|
||||
})
|
||||
})
|
||||
await window1.saveState()
|
||||
window1.close()
|
||||
await window1.closedPromise
|
||||
|
||||
const window2 = atomApplication.launch(parseCommandLine([path.join(tempDirPath)]))
|
||||
// Restore unsaved state when opening the directory itself
|
||||
const window2 = atomApplication.launch(parseCommandLine([tempDirPath]))
|
||||
await window2.loadedPromise
|
||||
const window2Text = await evalInWebContents(window2.browserWindow.webContents, function (sendBackToMainProcess) {
|
||||
atom.workspace.observeActivePaneItem(function (textEditor) {
|
||||
if (textEditor) sendBackToMainProcess(textEditor.getText())
|
||||
})
|
||||
const textEditor = atom.workspace.getActiveTextEditor()
|
||||
textEditor.moveToBottom()
|
||||
textEditor.insertText(' How are you?')
|
||||
sendBackToMainProcess(textEditor.getText())
|
||||
})
|
||||
assert.equal(window2Text, 'Hello World! How are you?')
|
||||
await window2.saveState()
|
||||
window2.close()
|
||||
await window2.closedPromise
|
||||
|
||||
assert.equal(window2Text, 'Hello World!')
|
||||
// Restore unsaved state when opening a path to a non-existent file in the directory
|
||||
const window3 = atomApplication.launch(parseCommandLine([path.join(tempDirPath, 'another-non-existent-file')]))
|
||||
await window3.loadedPromise
|
||||
const window3Texts = await evalInWebContents(window3.browserWindow.webContents, function (sendBackToMainProcess, nonExistentFilePath) {
|
||||
sendBackToMainProcess(atom.workspace.getTextEditors().map(editor => editor.getText()))
|
||||
})
|
||||
assert.include(window3Texts, 'Hello World! How are you?')
|
||||
})
|
||||
|
||||
it('shows all directories in the tree view when multiple directory paths are passed to Atom', async function () {
|
||||
@@ -260,7 +276,7 @@ describe('AtomApplication', function () {
|
||||
})
|
||||
assert.equal(window1EditorTitle, 'untitled')
|
||||
|
||||
const window2 = atomApplication.launch(parseCommandLine([]))
|
||||
const window2 = atomApplication.openWithOptions(parseCommandLine([]))
|
||||
await focusWindow(window2)
|
||||
const window2EditorTitle = await evalInWebContents(window1.browserWindow.webContents, function (sendBackToMainProcess) {
|
||||
sendBackToMainProcess(atom.workspace.getActiveTextEditor().getTitle())
|
||||
@@ -472,7 +488,7 @@ describe('AtomApplication', function () {
|
||||
}
|
||||
|
||||
let channelIdCounter = 0
|
||||
function evalInWebContents (webContents, source) {
|
||||
function evalInWebContents (webContents, source, ...args) {
|
||||
const channelId = 'eval-result-' + channelIdCounter++
|
||||
return new Promise(function (resolve) {
|
||||
electron.ipcMain.on(channelId, receiveResult)
|
||||
|
||||
@@ -112,7 +112,7 @@ describe("FileRecoveryService", () => {
|
||||
const mockWindow = {}
|
||||
const filePath = temp.path()
|
||||
fs.writeFileSync(filePath, "content")
|
||||
fs.chmodSync(filePath, 0444)
|
||||
fs.chmodSync(filePath, 0o444)
|
||||
|
||||
let logs = []
|
||||
this.stub(console, 'log', (message) => logs.push(message))
|
||||
|
||||
@@ -614,3 +614,7 @@ describe "Project", ->
|
||||
|
||||
randomPath = path.join("some", "random", "path")
|
||||
expect(atom.project.contains(randomPath)).toBe false
|
||||
|
||||
describe ".resolvePath(uri)", ->
|
||||
it "normalizes disk drive letter in passed path on #win32", ->
|
||||
expect(atom.project.resolvePath("d:\\file.txt")).toEqual "D:\\file.txt"
|
||||
|
||||
@@ -1747,11 +1747,13 @@ describe('TextEditorComponent', function () {
|
||||
})
|
||||
|
||||
describe('block decorations rendering', function () {
|
||||
let markerLayer
|
||||
|
||||
function createBlockDecorationBeforeScreenRow(screenRow, {className}) {
|
||||
let item = document.createElement("div")
|
||||
item.className = className || ""
|
||||
let blockDecoration = editor.decorateMarker(
|
||||
editor.markScreenPosition([screenRow, 0], {invalidate: "never"}),
|
||||
markerLayer.markScreenPosition([screenRow, 0], {invalidate: "never"}),
|
||||
{type: "block", item: item, position: "before"}
|
||||
)
|
||||
return [item, blockDecoration]
|
||||
@@ -1761,13 +1763,14 @@ describe('TextEditorComponent', function () {
|
||||
let item = document.createElement("div")
|
||||
item.className = className || ""
|
||||
let blockDecoration = editor.decorateMarker(
|
||||
editor.markScreenPosition([screenRow, 0], {invalidate: "never"}),
|
||||
markerLayer.markScreenPosition([screenRow, 0], {invalidate: "never"}),
|
||||
{type: "block", item: item, position: "after"}
|
||||
)
|
||||
return [item, blockDecoration]
|
||||
}
|
||||
|
||||
beforeEach(function () {
|
||||
markerLayer = editor.addMarkerLayer()
|
||||
wrapperNode.style.height = 5 * lineHeightInPixels + 'px'
|
||||
editor.update({autoHeight: false})
|
||||
component.measureDimensions()
|
||||
|
||||
@@ -886,8 +886,12 @@ describe "Workspace", ->
|
||||
|
||||
describe "document.title", ->
|
||||
describe "when there is no item open", ->
|
||||
it "sets the title to 'untitled'", ->
|
||||
expect(document.title).toMatch ///^untitled///
|
||||
it "sets the title to the project path", ->
|
||||
expect(document.title).toMatch escapeStringRegex(fs.tildify(atom.project.getPaths()[0]))
|
||||
|
||||
it "sets the title to 'untitled' if there is no project path", ->
|
||||
atom.project.setPaths([])
|
||||
expect(document.title).toMatch /^untitled/
|
||||
|
||||
describe "when the active pane item's path is not inside a project path", ->
|
||||
beforeEach ->
|
||||
@@ -948,10 +952,10 @@ describe "Workspace", ->
|
||||
expect(document.title).toMatch ///^#{item.getTitle()}\ \u2014\ #{pathEscaped}///
|
||||
|
||||
describe "when the last pane item is removed", ->
|
||||
it "updates the title to be untitled", ->
|
||||
it "updates the title to the project's first path", ->
|
||||
atom.workspace.getActivePane().destroy()
|
||||
expect(atom.workspace.getActivePaneItem()).toBeUndefined()
|
||||
expect(document.title).toMatch ///^untitled///
|
||||
expect(document.title).toMatch escapeStringRegex(fs.tildify(atom.project.getPaths()[0]))
|
||||
|
||||
describe "when an inactive pane's item changes", ->
|
||||
it "does not update the title", ->
|
||||
|
||||
Reference in New Issue
Block a user