Fix tests

This commit is contained in:
Garen Torikian
2013-04-19 16:02:28 -07:00
committed by Garen Torikian & Nathan Sobo
parent 4b6e0916c9
commit 6c748c2f87
2 changed files with 6 additions and 12 deletions

View File

@@ -43,7 +43,7 @@ class MarkdownPreviewView extends ScrollView
@buffer.getPath()
setErrorHtml: (result)->
try failureMessage = JSON.parse(result.responseText).message
try failureMessage = JSON.parse(result).message
@html $$$ ->
@h2 'Previewing Markdown Failed'

View File

@@ -6,7 +6,6 @@ describe "MarkdownPreviewView", ->
[buffer, preview] = []
beforeEach ->
spyOn($, 'ajax')
project.setPath(project.resolve('markdown'))
buffer = project.bufferForPath('file.markdown')
preview = new MarkdownPreviewView(buffer)
@@ -15,22 +14,17 @@ describe "MarkdownPreviewView", ->
buffer.release()
describe "on construction", ->
ajaxArgs = null
beforeEach ->
ajaxArgs = $.ajax.argsForCall[0][0]
it "shows a loading spinner and fetches the rendered markdown", ->
preview.setLoading()
expect(preview.find('.markdown-spinner')).toExist()
expect($.ajax).toHaveBeenCalled()
expect(preview.buffer.getText()).toBe buffer.getText()
expect(JSON.parse(ajaxArgs.data).text).toBe buffer.getText()
ajaxArgs.success($$$ -> @div "WWII", class: 'private-ryan')
expect(preview.find(".private-ryan")).toExist()
preview.fetchRenderedMarkdown()
expect(preview.find(".emoji")).toExist()
it "shows an error message on error", ->
ajaxArgs.error()
preview.setErrorHtml("Not a real file")
expect(preview.text()).toContain "Failed"
describe "serialization", ->