mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-09-16 09:35:00 +08:00
fix(account): select account after load
Summary: It wasn't selecting the account after you added it Fixes T3569 Test Plan: new tests Reviewers: dillon, bengotow Reviewed By: bengotow Maniphest Tasks: T3569 Differential Revision: https://phab.nylas.com/D2085
This commit is contained in:
parent
53d2b4972a
commit
fe9bacadbc
3 changed files with 40 additions and 2 deletions
|
@ -52,3 +52,40 @@ describe "AccountStore", ->
|
|||
spyOn(atom.config, 'get').andCallFake -> "this isn't an object"
|
||||
@instance = new @constructor
|
||||
expect(@instance.current()).toEqual(null)
|
||||
|
||||
describe "adding account from json", ->
|
||||
beforeEach ->
|
||||
spyOn(atom.config, "set")
|
||||
@json =
|
||||
"id": "1234",
|
||||
"client_id" : 'local-4f9d476a-c175',
|
||||
"server_id" : '1234',
|
||||
"email_address":"ben@nylas.com",
|
||||
"object":"account"
|
||||
"auth_token": "auth-123"
|
||||
"organization_unit": "label"
|
||||
@instance = new @constructor
|
||||
spyOn(@instance, "onSelectAccountId").andCallThrough()
|
||||
spyOn(@instance, "trigger")
|
||||
@instance.addAccountFromJSON(@json)
|
||||
|
||||
it "sets the tokens", ->
|
||||
expect(@instance._tokens["1234"]).toBe "auth-123"
|
||||
|
||||
it "sets the accounts", ->
|
||||
account = (new Account).fromJSON(@json)
|
||||
expect(@instance._accounts.length).toBe 1
|
||||
expect(@instance._accounts[0]).toEqual account
|
||||
|
||||
it "saves the config", ->
|
||||
expect(atom.config.save).toHaveBeenCalled()
|
||||
expect(atom.config.set.calls.length).toBe 4
|
||||
|
||||
it "selects the account", ->
|
||||
expect(@instance._index).toBe 0
|
||||
expect(@instance.onSelectAccountId).toHaveBeenCalledWith("1234")
|
||||
expect(@instance.onSelectAccountId.calls.length).toBe 1
|
||||
|
||||
it "triggers", ->
|
||||
expect(@instance.trigger).toHaveBeenCalled()
|
||||
expect(@instance.trigger.calls.length).toBe 1
|
||||
|
|
|
@ -62,6 +62,7 @@ class TimeoutTransitionGroupChild extends React.Component
|
|||
|
||||
transition: (animationType, finishCallback) =>
|
||||
node = React.findDOMNode(@)
|
||||
return unless node
|
||||
className = @props.name + '-' + animationType
|
||||
activeClassName = className + '-active'
|
||||
|
||||
|
|
|
@ -29,9 +29,9 @@ class AccountStore
|
|||
atom.config.observe saveTokensKey, (updatedTokens) =>
|
||||
return if _.isEqual(updatedTokens, @_tokens)
|
||||
newAccountIds = _.keys(_.omit(updatedTokens, _.keys(@_tokens)))
|
||||
@_load()
|
||||
if newAccountIds.length > 0
|
||||
Actions.selectAccountId(newAccountIds[0])
|
||||
@_load()
|
||||
|
||||
_load: =>
|
||||
@_accounts = []
|
||||
|
@ -80,7 +80,7 @@ class AccountStore
|
|||
@_tokens[json.id] = json.auth_token
|
||||
@_accounts.push((new Account).fromJSON(json))
|
||||
@_save()
|
||||
@trigger()
|
||||
@onSelectAccountId(json.id)
|
||||
|
||||
# Exposed Data
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue