fix(specs): Update specs following 0.29.2 > 0.34.3 move

This commit is contained in:
Ben Gotow 2015-11-17 17:39:57 -08:00
parent 488dff0f90
commit 0068e7d4a7
5 changed files with 22 additions and 7 deletions

View file

@ -130,8 +130,8 @@ makeComposer = ->
describe "populated composer", ->
beforeEach ->
@isSending = {state: false}
spyOn(DraftStore, "isSendingDraft").andCallFake => @isSending.state
@isSending = false
spyOn(DraftStore, "isSendingDraft").andCallFake => @isSending
afterEach ->
DraftStore._cleanupAllSessions()
@ -524,7 +524,7 @@ describe "populated composer", ->
useFullDraft.apply(@); makeComposer.call(@)
sendBtn = React.findDOMNode(@composer.refs.sendButton)
ReactTestUtils.Simulate.click sendBtn
@isSending.state = true
@isSending = true
DraftStore.trigger()
ReactTestUtils.Simulate.click sendBtn
expect(Actions.sendDraft).toHaveBeenCalledWith(DRAFT_CLIENT_ID)
@ -537,17 +537,20 @@ describe "populated composer", ->
NylasTestUtils.loadKeymap("internal_packages/composer/keymaps/composer")
@$composer = @composer.refs.composerWrap
it "sends the draft on cmd-enter", ->
fit "sends the draft on cmd-enter", ->
NylasTestUtils.keyPress("cmd-enter", React.findDOMNode(@$composer))
expect(Actions.sendDraft).toHaveBeenCalled()
expect(Actions.sendDraft.calls.length).toBe 1
it "does not send the draft on enter if the button isn't in focus", ->
NylasTestUtils.keyPress("enter", React.findDOMNode(@$composer))
expect(Actions.sendDraft).not.toHaveBeenCalled()
it "doesn't let you send twice", ->
fit "doesn't let you send twice", ->
NylasTestUtils.keyPress("cmd-enter", React.findDOMNode(@$composer))
@isSending.state = true
expect(Actions.sendDraft).toHaveBeenCalled()
expect(Actions.sendDraft.calls.length).toBe 1
@isSending = true
DraftStore.trigger()
NylasTestUtils.keyPress("cmd-enter", React.findDOMNode(@$composer))
expect(Actions.sendDraft).toHaveBeenCalled()

View file

@ -86,6 +86,7 @@ describe 'ModuleCache', ->
exports.load = function() { require('underscore'); };
"""
spyOn(process, 'cwd').andReturn('/') # Required when running this test from CLI
packageMain = require(indexPath)
Module._findPath.reset()
expect(-> packageMain.load()).toThrow()

View file

@ -3,7 +3,7 @@ describe '"nylas" protocol URL', ->
called = false
request = new XMLHttpRequest()
request.addEventListener('load', -> called = true)
request.open('GET', 'nylas://async/package.json', true)
request.open('GET', 'nylas://account-sidebar/package.json', true)
request.send()
waitsFor 'request to be done', -> called is true

View file

@ -13,6 +13,16 @@ NylasTestUtils =
NylasEnv.keymaps.loadKeymap(keymapPath)
keyPress: (key, target) ->
# React's "renderIntoDocument" does not /actually/ attach the component
# to the document. It's a sham: http://dragon.ak.fbcdn.net/hphotos-ak-xpf1/t39.3284-6/10956909_1423563877937976_838415501_n.js
# The Atom keymap manager doesn't work correctly on elements outside of the
# DOM tree, so we need to attach it.
unless document.contains(target)
parent = target
while parent.parentNode?
parent = parent.parentNode
document.documentElement.appendChild(parent)
event = KeymapManager.buildKeydownEvent(key, target: target)
NylasEnv.keymaps.handleKeyboardEvent(event)

View file

@ -101,6 +101,7 @@ class KeyCommandsRegion extends React.Component
componentWillUnmount: ->
@_unmountListeners()
@_mounted = false
# When the {KeymapManager} finds a valid keymap in a `.cson` file, it
# will create a CustomEvent with the command name as its type. That