Move the copy event test to editor, make selection test copy implementation

This commit is contained in:
Corey Johnson
2012-02-01 17:46:22 -08:00
parent d0cdc212c5
commit 16cfcd9396
2 changed files with 13 additions and 3 deletions

View File

@@ -511,4 +511,14 @@ describe "Editor", ->
expect(editor.clipPosition(row: 1, column: 10000)).toEqual(row: 1, column: buffer.getLine(1).length)
expect(editor.clipPosition(row: 1, column: -5)).toEqual(row: 1, column: 0)
describe "cut, copy & paste", ->
describe "when a copy event is triggered", ->
beforeEach ->
editor.getSelection().setRange new Range([0,4], [0, 13])
atom.native.writeToPasteboard('first')
expect(atom.native.readFromPasteboard()).toBe 'first'
it "copies selected text onto the clipboard", ->
editor.trigger "copy"
expect(atom.native.readFromPasteboard()).toBe 'quicksort'

View File

@@ -125,16 +125,16 @@ describe "Selection", ->
it "places selected text on the clipboard", ->
selection.setRange new Range([0,4], [0,13])
editor.trigger "copy"
selection.copy()
expect(atom.native.readFromPasteboard()).toBe 'quicksort'
selection.setRange new Range([0,4], [3,13])
editor.trigger "copy"
selection.copy()
expect(atom.native.readFromPasteboard()).toBe "quicksort = function () {\n var sort = function(items) {\n if (items.length <= 1) return items;\n var pivot"
it "places nothing on the clipboard when there is no selection", ->
selection.setRange new Range([0,4], [0,4])
editor.trigger "copy"
selection.copy()
expect(atom.native.readFromPasteboard()).toBe 'first'