Mailspring/internal_packages/account-sidebar/spec/account-switcher-spec.cjsx
Juan Tejada 866805f835 More account sidebar refactor + sections for unified inbox
- Refactors some of the old code which was 💩
  - Makes SidbarSection a factory for different types of items for the
    OutlineView
  - Decided not to create a OutlineViewItem.Model class since the only
    purpose it would serve would be to validate getters for props or for
    documentation, both of which are already done via React.PropTypes.
- Adds sections when looking at unified inbox and integrates with new
  mailbox perspecitve interface
- Updates OutlineViewItem a bit + styles
- Tests missing
2016-01-18 23:22:46 -08:00

54 lines
2 KiB
CoffeeScript

React = require 'react/addons'
TestUtils = React.addons.TestUtils
AccountSwitcher = require './../lib/components/account-switcher'
SidebarStore = require './../lib/sidebar-store'
{AccountStore} = require 'nylas-exports'
describe "AccountSwitcher", ->
switcher = null
beforeEach ->
account = AccountStore.accounts()[0]
spyOn(AccountStore, "accounts").andReturn [
account,
{
emailAddress: "dillon@nylas.com",
provider: "exchange"
label: "work"
}
]
spyOn(SidebarStore, "currentAccount").andReturn account
switcher = TestUtils.renderIntoDocument(
<AccountSwitcher />
)
it "doesn't render the dropdown if nothing clicked", ->
openDropdown = TestUtils.scryRenderedDOMComponentsWithClass switcher, 'open'
expect(openDropdown.length).toBe 0
it "shows the dropdown on click", ->
toggler = TestUtils.findRenderedDOMComponentWithClass switcher, 'primary-item'
TestUtils.Simulate.click toggler
openDropdown = TestUtils.scryRenderedDOMComponentsWithClass switcher, 'open'
expect(openDropdown.length).toBe 1
it "hides the dropdown on blur", ->
toggler = TestUtils.findRenderedDOMComponentWithClass switcher, 'primary-item'
TestUtils.Simulate.click toggler
toggler = TestUtils.findRenderedDOMComponentWithClass switcher, 'primary-item'
TestUtils.Simulate.blur toggler
openDropdown = TestUtils.scryRenderedDOMComponentsWithClass switcher, 'open'
expect(openDropdown.length).toBe 0
it "shows other accounts and the 'Add Account' button", ->
toggler = TestUtils.findRenderedDOMComponentWithClass switcher, 'primary-item'
TestUtils.Simulate.click toggler
dropdown = TestUtils.findRenderedDOMComponentWithClass switcher, "dropdown"
items = TestUtils.scryRenderedDOMComponentsWithClass dropdown, "secondary-item"
newAccountButton = TestUtils.scryRenderedDOMComponentsWithClass dropdown, "new-account-option"
expect(items.length).toBe 3
expect(newAccountButton.length).toBe 1