Mailspring/spec-inbox/action-bridge-spec.coffee
Evan Morikawa 365fe400f7 feat(salesforce): add Salesforce creator
Summary:
tests on the schemas

build input elements

form builder pulls data

grouping by row

salesforce object store

salesforce api logic

successfully pulling salesforce objects into db

object store saving to db

refactoring tokenizing text field

full documented tokenizing text field with specs

linking in object picker component

converting generated form to a controlled input

form change handlers for controlled inputs

Salesforce object creator store

new way of opening windows

removed atom.state.mode

create new salesforce object creator in new window

form creator loading in popup with generated form

generated form renders select and multiselcet and textarea

add checkbox

creating related objects

windnows know when others close

remove debugger statements

form submission

converting data for salesforce posting

hot window loading

new hot window registration

hot loading windows

actions for listening to salesforce objects created

generated form errors

error handling for salesforce object creator

rename saleforce object form store

display errors to form

submitting state passed through

properly posts objects to Salesforce

change name to salesforce object form

add deep clone

use formItemEach

styling for Salesforce form creator

salesforce required fields come back and populate form

generated form loads related objects into fields

remove console logs and fix sales schema adapter test

fix task queue and formbuilder specs

fix action bridge spec

fix tokenizing text field spec

fix draft store and tokenizing proptypes

fix linter issues

fix tokenizing text field bug

rename to refresh window props

remove console.log

Test Plan: edgehill --test

Reviewers: bengotow

Reviewed By: bengotow

Differential Revision: https://review.inboxapp.com/D1425
2015-04-24 12:36:19 -04:00

102 lines
4 KiB
CoffeeScript

Reflux = require 'reflux'
Actions = require '../src/flux/actions'
ActionBridge = require '../src/flux/action-bridge'
Message = require '../src/flux/models/message'
DatabaseStore = require '../src/flux/stores/database-store'
NamespaceStore = require '../src/flux/stores/namespace-store'
_ = require 'underscore-plus'
ipc =
on: ->
send: ->
describe "ActionBridge", ->
describe "in the editor window", ->
beforeEach ->
spyOn(atom, "getWindowType").andReturn "default"
spyOn(atom, "isMainWindow").andReturn true
@bridge = new ActionBridge(ipc)
it "should have the role Role.ROOT", ->
expect(@bridge.role).toBe(ActionBridge.Role.ROOT)
it "should rebroadcast global actions", ->
spyOn(@bridge, 'onRebroadcast')
testAction = Actions[Actions.globalActions[0]]
testAction('bla')
expect(@bridge.onRebroadcast).toHaveBeenCalled()
it "should rebroadcast when the DatabaseStore triggers", ->
spyOn(@bridge, 'onRebroadcast')
DatabaseStore.trigger({})
expect(@bridge.onRebroadcast).toHaveBeenCalled()
it "should not rebroadcast mainWindow actions since it is the main window", ->
spyOn(@bridge, 'onRebroadcast')
testAction = Actions.didMakeAPIRequest
testAction('bla')
expect(@bridge.onRebroadcast).not.toHaveBeenCalled()
it "should not rebroadcast window actions", ->
spyOn(@bridge, 'onRebroadcast')
testAction = Actions[Actions.windowActions[0]]
testAction('bla')
expect(@bridge.onRebroadcast).not.toHaveBeenCalled()
describe "in a secondary window", ->
beforeEach ->
spyOn(atom, "getWindowType").andReturn "popout"
spyOn(atom, "isMainWindow").andReturn false
@bridge = new ActionBridge(ipc)
@message = new Message
id: 'test-id'
namespaceId: 'test-namespace-id'
it "should have the role Role.SECONDARY", ->
expect(@bridge.role).toBe(ActionBridge.Role.SECONDARY)
it "should rebroadcast global actions", ->
spyOn(@bridge, 'onRebroadcast')
testAction = Actions[Actions.globalActions[0]]
testAction('bla')
expect(@bridge.onRebroadcast).toHaveBeenCalled()
it "should rebroadcast mainWindow actions", ->
spyOn(@bridge, 'onRebroadcast')
testAction = Actions.didMakeAPIRequest
testAction('bla')
expect(@bridge.onRebroadcast).toHaveBeenCalled()
it "should not rebroadcast window actions", ->
spyOn(@bridge, 'onRebroadcast')
testAction = Actions[Actions.windowActions[0]]
testAction('bla')
expect(@bridge.onRebroadcast).not.toHaveBeenCalled()
describe "onRebroadcast", ->
beforeEach ->
spyOn(atom, "getWindowType").andReturn "popout"
spyOn(atom, "isMainWindow").andReturn false
@bridge = new ActionBridge(ipc)
describe "when called with TargetWindows.ALL", ->
it "should broadcast the action over IPC to all windows", ->
spyOn(ipc, 'send')
Actions.didSwapModel.firing = false
@bridge.onRebroadcast(ActionBridge.TargetWindows.ALL, 'didSwapModel', [{oldModel: '1', newModel: 2}])
expect(ipc.send).toHaveBeenCalledWith('action-bridge-rebroadcast-to-all', 'popout', 'didSwapModel', '[{"oldModel":"1","newModel":2}]')
describe "when called with TargetWindows.MAIN", ->
it "should broadcast the action over IPC to the main window only", ->
spyOn(ipc, 'send')
Actions.didSwapModel.firing = false
@bridge.onRebroadcast(ActionBridge.TargetWindows.MAIN, 'didSwapModel', [{oldModel: '1', newModel: 2}])
expect(ipc.send).toHaveBeenCalledWith('action-bridge-rebroadcast-to-main', 'popout', 'didSwapModel', '[{"oldModel":"1","newModel":2}]')
it "should not do anything if the current invocation of the Action was triggered by itself", ->
spyOn(ipc, 'send')
Actions.didSwapModel.firing = true
@bridge.onRebroadcast(ActionBridge.TargetWindows.ALL, 'didSwapModel', [{oldModel: '1', newModel: 2}])
expect(ipc.send).not.toHaveBeenCalled()