Merge branch 'master' into as-tiled-rendering

Conflicts:
	spec/text-editor-presenter-spec.coffee
This commit is contained in:
Antonio Scandurra
2015-05-18 11:49:12 +02:00
22 changed files with 886 additions and 774 deletions

View File

@@ -30,15 +30,12 @@ describe "CustomGutterComponent", ->
buildTestState = (customDecorations) ->
mockTestState =
gutters:
content: if customDecorations then customDecorations else {}
styles:
scrollHeight: 100
scrollTop: 10
backgroundColor: 'black'
sortedDescriptions: [{gutter, visible: true}]
customDecorations: customDecorations
lineNumberGutter:
maxLineNumberDigits: 10
lineNumbers: {}
mockTestState
it "sets the custom-decoration wrapper's scrollHeight, scrollTop, and background color", ->
@@ -53,7 +50,7 @@ describe "CustomGutterComponent", ->
expect(decorationsWrapperNode.style.backgroundColor).not.toBe ''
it "creates a new DOM node for a new decoration and adds it to the gutter at the right place", ->
customDecorations = 'test-gutter':
customDecorations =
'decoration-id-1':
top: 0
height: 10
@@ -75,7 +72,7 @@ describe "CustomGutterComponent", ->
expect(decorationItem).toBe decorationItem1
it "updates the existing DOM node for a decoration that existed but has new properties", ->
initialCustomDecorations = 'test-gutter':
initialCustomDecorations =
'decoration-id-1':
top: 0
height: 10
@@ -86,7 +83,7 @@ describe "CustomGutterComponent", ->
# Change the dimensions and item, remove the class.
decorationItem2 = document.createElement('div')
changedCustomDecorations = 'test-gutter':
changedCustomDecorations =
'decoration-id-1':
top: 10
height: 20
@@ -103,7 +100,7 @@ describe "CustomGutterComponent", ->
expect(decorationItem).toBe decorationItem2
# Remove the item, add a class.
changedCustomDecorations = 'test-gutter':
changedCustomDecorations =
'decoration-id-1':
top: 10
height: 20
@@ -118,7 +115,7 @@ describe "CustomGutterComponent", ->
expect(changedDecorationNode.children.length).toBe 0
it "removes any decorations that existed previously but aren't in the latest update", ->
customDecorations = 'test-gutter':
customDecorations =
'decoration-id-1':
top: 0
height: 10
@@ -127,6 +124,6 @@ describe "CustomGutterComponent", ->
decorationsWrapperNode = gutterComponent.getDomNode().children.item(0)
expect(decorationsWrapperNode.children.length).toBe 1
emptyCustomDecorations = 'test-gutter': {}
emptyCustomDecorations = {}
gutterComponent.updateSync(buildTestState(emptyCustomDecorations))
expect(decorationsWrapperNode.children.length).toBe 0

View File

@@ -1,5 +1,6 @@
DefaultDirectoryProvider = require "../src/default-directory-provider"
path = require "path"
fs = require 'fs-plus'
temp = require "temp"
describe "DefaultDirectoryProvider", ->

View File

@@ -1,5 +1,5 @@
{
"name": "no events",
"name": "package-with-empty-activation-commands",
"version": "0.1.0",
"activationCommands": {"atom-workspace": []}
}

View File

@@ -5,17 +5,20 @@ describe "GutterContainerComponent", ->
[gutterContainerComponent] = []
mockGutterContainer = {}
buildTestState = (sortedDescriptions) ->
mockTestState =
gutters:
scrollHeight: 100
scrollTop: 10
backgroundColor: 'black'
sortedDescriptions: sortedDescriptions
customDecorations: {}
lineNumberGutter:
maxLineNumberDigits: 10
lineNumbers: {}
buildTestState = (gutters) ->
styles =
scrollHeight: 100
scrollTop: 10
backgroundColor: 'black'
mockTestState = {gutters: []}
for gutter in gutters
if gutter.name is 'line-number'
content = {maxLineNumberDigits: 10, lineNumbers: {}}
else
content = {}
mockTestState.gutters.push({gutter, styles, content, visible: gutter.visible})
mockTestState
beforeEach ->
@@ -30,7 +33,7 @@ describe "GutterContainerComponent", ->
describe "when updated with state that contains a new line-number gutter", ->
it "adds a LineNumberGutterComponent to its children", ->
lineNumberGutter = new Gutter(mockGutterContainer, {name: 'line-number'})
testState = buildTestState([{gutter: lineNumberGutter, visible: true}])
testState = buildTestState([lineNumberGutter])
expect(gutterContainerComponent.getDomNode().children.length).toBe 0
gutterContainerComponent.updateSync(testState)
@@ -45,7 +48,7 @@ describe "GutterContainerComponent", ->
describe "when updated with state that contains a new custom gutter", ->
it "adds a CustomGutterComponent to its children", ->
customGutter = new Gutter(mockGutterContainer, {name: 'custom'})
testState = buildTestState([{gutter: customGutter, visible: true}])
testState = buildTestState([customGutter])
expect(gutterContainerComponent.getDomNode().children.length).toBe 0
gutterContainerComponent.updateSync(testState)
@@ -57,15 +60,16 @@ describe "GutterContainerComponent", ->
describe "when updated with state that contains a new gutter that is not visible", ->
it "creates the gutter view but hides it, and unhides it when it is later updated to be visible", ->
customGutter = new Gutter(mockGutterContainer, {name: 'custom'})
testState = buildTestState([{gutter: customGutter, visible: false}])
customGutter = new Gutter(mockGutterContainer, {name: 'custom', visible: false})
testState = buildTestState([customGutter])
gutterContainerComponent.updateSync(testState)
expect(gutterContainerComponent.getDomNode().children.length).toBe 1
expectedCustomGutterNode = gutterContainerComponent.getDomNode().children.item(0)
expect(expectedCustomGutterNode.style.display).toBe 'none'
testState = buildTestState([{gutter: customGutter, visible: true}])
customGutter.show()
testState = buildTestState([customGutter])
gutterContainerComponent.updateSync(testState)
expect(gutterContainerComponent.getDomNode().children.length).toBe 1
expectedCustomGutterNode = gutterContainerComponent.getDomNode().children.item(0)
@@ -74,20 +78,20 @@ describe "GutterContainerComponent", ->
describe "when updated with a gutter that already exists", ->
it "reuses the existing gutter view, instead of recreating it", ->
customGutter = new Gutter(mockGutterContainer, {name: 'custom'})
testState = buildTestState([{gutter: customGutter, visible: true}])
testState = buildTestState([customGutter])
gutterContainerComponent.updateSync(testState)
expect(gutterContainerComponent.getDomNode().children.length).toBe 1
expectedCustomGutterNode = gutterContainerComponent.getDomNode().children.item(0)
testState = buildTestState([{gutter: customGutter, visible: true}])
testState = buildTestState([customGutter])
gutterContainerComponent.updateSync(testState)
expect(gutterContainerComponent.getDomNode().children.length).toBe 1
expect(gutterContainerComponent.getDomNode().children.item(0)).toBe expectedCustomGutterNode
it "removes a gutter from the DOM if it does not appear in the latest state update", ->
lineNumberGutter = new Gutter(mockGutterContainer, {name: 'line-number'})
testState = buildTestState([{gutter: lineNumberGutter, visible: true}])
testState = buildTestState([lineNumberGutter])
gutterContainerComponent.updateSync(testState)
expect(gutterContainerComponent.getDomNode().children.length).toBe 1
@@ -99,7 +103,7 @@ describe "GutterContainerComponent", ->
it "positions (and repositions) the gutters to match the order they appear in each state update", ->
lineNumberGutter = new Gutter(mockGutterContainer, {name: 'line-number'})
customGutter1 = new Gutter(mockGutterContainer, {name: 'custom', priority: -100})
testState = buildTestState([{gutter: customGutter1, visible: true}, {gutter: lineNumberGutter, visible: true}])
testState = buildTestState([customGutter1, lineNumberGutter])
gutterContainerComponent.updateSync(testState)
expect(gutterContainerComponent.getDomNode().children.length).toBe 2
@@ -110,11 +114,7 @@ describe "GutterContainerComponent", ->
# Add a gutter.
customGutter2 = new Gutter(mockGutterContainer, {name: 'custom2', priority: -10})
testState = buildTestState([
{gutter: customGutter1, visible: true},
{gutter: customGutter2, visible: true},
{gutter: lineNumberGutter, visible: true}
])
testState = buildTestState([customGutter1, customGutter2, lineNumberGutter])
gutterContainerComponent.updateSync(testState)
expect(gutterContainerComponent.getDomNode().children.length).toBe 3
expectedCustomGutterNode1 = gutterContainerComponent.getDomNode().children.item(0)
@@ -125,12 +125,9 @@ describe "GutterContainerComponent", ->
expect(expectedLineNumbersNode).toBe atom.views.getView(lineNumberGutter)
# Hide one gutter, reposition one gutter, remove one gutter; and add a new gutter.
customGutter2.hide()
customGutter3 = new Gutter(mockGutterContainer, {name: 'custom3', priority: 100})
testState = buildTestState([
{gutter: customGutter2, visible: false},
{gutter: customGutter1, visible: true},
{gutter: customGutter3, visible: true}
])
testState = buildTestState([customGutter2, customGutter1, customGutter3])
gutterContainerComponent.updateSync(testState)
expect(gutterContainerComponent.getDomNode().children.length).toBe 3
expectedCustomGutterNode2 = gutterContainerComponent.getDomNode().children.item(0)

View File

@@ -313,7 +313,7 @@ window.waitsForPromise = (args...) ->
else
promise.then(moveOn)
promise.catch.call promise, (error) ->
jasmine.getEnv().currentSpec.fail("Expected promise to be resolved, but it was rejected with #{jasmine.pp(error)}")
jasmine.getEnv().currentSpec.fail("Expected promise to be resolved, but it was rejected with: #{error?.message} #{jasmine.pp(error)}")
moveOn()
window.resetTimeouts = ->

View File

@@ -2266,13 +2266,13 @@ describe "TextEditorComponent", ->
editor.setText("")
componentNode.dispatchEvent(buildTextInputEvent(data: 'x', target: inputNode))
currentTime += 99
currentTime += 100
componentNode.dispatchEvent(buildTextInputEvent(data: 'y', target: inputNode))
currentTime += 99
currentTime += 100
componentNode.dispatchEvent(new CustomEvent('editor:duplicate-lines', bubbles: true, cancelable: true))
currentTime += 100
currentTime += 101
componentNode.dispatchEvent(new CustomEvent('editor:duplicate-lines', bubbles: true, cancelable: true))
expect(editor.getText()).toBe "xy\nxy\nxy"

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,44 @@
ipc = require 'ipc'
path = require 'path'
temp = require('temp').track()
describe "WorkspaceElement", ->
workspaceElement = null
beforeEach ->
workspaceElement = atom.views.getView(atom.workspace)
describe "the 'window:run-package-specs' command", ->
it "runs the package specs for the active item's project path, or the first project path", ->
spyOn(ipc, 'send')
# No project paths. Don't try to run specs.
atom.commands.dispatch(workspaceElement, "window:run-package-specs")
expect(ipc.send).not.toHaveBeenCalledWith("run-package-specs")
projectPaths = [temp.mkdirSync("dir1-"), temp.mkdirSync("dir2-")]
atom.project.setPaths(projectPaths)
# No active item. Use first project directory.
atom.commands.dispatch(workspaceElement, "window:run-package-specs")
expect(ipc.send).toHaveBeenCalledWith("run-package-specs", path.join(projectPaths[0], "spec"))
ipc.send.reset()
# Active item doesn't implement ::getPath(). Use first project directory.
item = document.createElement("div")
atom.workspace.getActivePane().activateItem(item)
atom.commands.dispatch(workspaceElement, "window:run-package-specs")
expect(ipc.send).toHaveBeenCalledWith("run-package-specs", path.join(projectPaths[0], "spec"))
ipc.send.reset()
# Active item has no path. Use first project directory.
item.getPath = -> null
atom.commands.dispatch(workspaceElement, "window:run-package-specs")
expect(ipc.send).toHaveBeenCalledWith("run-package-specs", path.join(projectPaths[0], "spec"))
ipc.send.reset()
# Active item has path. Use project path for item path.
item.getPath = -> path.join(projectPaths[1], "a-file.txt")
atom.commands.dispatch(workspaceElement, "window:run-package-specs")
expect(ipc.send).toHaveBeenCalledWith("run-package-specs", path.join(projectPaths[1], "spec"))
ipc.send.reset()