mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
Attach and populate the ace editor with buffer text when an editor is created.
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
App = require 'app'
|
||||
fs = require 'fs'
|
||||
|
||||
describe "App", ->
|
||||
app = null
|
||||
@@ -18,7 +19,8 @@ describe "App", ->
|
||||
|
||||
expect(app.windows().length).toBe 1
|
||||
newWindow = app.windows()[0]
|
||||
|
||||
|
||||
expect(newWindow.editor).toBeDefined()
|
||||
expect(newWindow.editor.buffer).toBeDefined()
|
||||
expect(newWindow.editor.buffer.url).toEqual filePath
|
||||
expect(newWindow.editor.buffer.text).toEqual fs.read(filePath)
|
||||
|
||||
9
spec/atom/buffer-spec.coffee
Normal file
9
spec/atom/buffer-spec.coffee
Normal file
@@ -0,0 +1,9 @@
|
||||
Buffer = require 'buffer'
|
||||
fs = require 'fs'
|
||||
|
||||
describe 'Buffer', ->
|
||||
describe 'constructor', ->
|
||||
it "loads the contents of the given url", ->
|
||||
filePath = require.resolve 'fixtures/sample.txt'
|
||||
buffer = new Buffer filePath
|
||||
expect(buffer.text).toBe fs.read(filePath)
|
||||
34
spec/atom/editor-spec.coffee
Normal file
34
spec/atom/editor-spec.coffee
Normal file
@@ -0,0 +1,34 @@
|
||||
Editor = require 'editor'
|
||||
$ = require 'jquery'
|
||||
ck = require 'coffeekup'
|
||||
|
||||
describe "Editor", ->
|
||||
mainDiv = null; editor = null; filePath = null
|
||||
|
||||
beforeEach ->
|
||||
filePath = require.resolve 'fixtures/sample.txt'
|
||||
mainDiv = $("<div id='main'>")
|
||||
$("#jasmine-content").append(mainDiv)
|
||||
editor = new Editor filePath
|
||||
|
||||
afterEach ->
|
||||
editor.destroy()
|
||||
|
||||
describe "constructor", ->
|
||||
it "attaches itself to the #main element and opens a buffer with the given url", ->
|
||||
expect(editor.buffer.url).toEqual filePath
|
||||
expect(mainDiv.children('#editor').html()).not.toBe ''
|
||||
|
||||
it "populates the editor with the contents of the buffer", ->
|
||||
expect(editor.aceEditor.getSession().getValue()).toBe editor.buffer.text
|
||||
|
||||
describe 'destroy', ->
|
||||
it 'destroys the ace editor and removes #editor from the dom.', ->
|
||||
spyOn editor.aceEditor, 'destroy'
|
||||
|
||||
editor.destroy()
|
||||
expect(editor.aceEditor.destroy).toHaveBeenCalled()
|
||||
expect(mainDiv.children('#editor').length).toBe 0
|
||||
|
||||
describe "when the text is changed via the ace editor", ->
|
||||
it "updates the buffer text", ->
|
||||
Reference in New Issue
Block a user