Mailspring/internal_packages/message-list/spec/message-toolbar-items-spec.cjsx
Robert McQueen 13920be848 feat(starring): Star/unstar from the message detail view
Summary: Adding star button to message-toolbar view

Test Plan: Added spec for starring message from the message-toolbar view

Reviewers: bengotow

Reviewed By: bengotow

Differential Revision: https://phab.nylas.com/D1683
2015-06-25 10:33:26 -07:00

44 lines
1.7 KiB
CoffeeScript

React = require "react/addons"
TestUtils = React.addons.TestUtils
{Thread, FocusedContentStore, Actions, AddRemoveTagsTask} = require "nylas-exports"
MessageToolbarItems = require '../lib/message-toolbar-items'
test_thread = (new Thread).fromJSON({
"id" : "thread_12345"
"subject" : "Subject 12345"
})
test_thread_starred = (new Thread).fromJSON({
"id" : "thread_starred_12345"
"subject" : "Subject 12345"
"tags": [{"id": "starred"}]
})
describe "MessageToolbarItem starring", ->
it "stars a thread if the star button is clicked and thread is unstarred", ->
spyOn(FocusedContentStore, "focused").andCallFake ->
test_thread
spyOn(Actions, 'queueTask')
messageToolbarItems = TestUtils.renderIntoDocument(<MessageToolbarItems />)
starButton = React.findDOMNode(messageToolbarItems.refs.starButton)
TestUtils.Simulate.click starButton
expect(Actions.queueTask.mostRecentCall.args[0].thread).toBe(test_thread)
expect(Actions.queueTask.mostRecentCall.args[0].tagIdsToAdd).toEqual(['starred'])
expect(Actions.queueTask.mostRecentCall.args[0].tagIdsToRemove).toEqual([])
it "unstars a thread if the star button is clicked and thread is starred", ->
spyOn(FocusedContentStore, "focused").andCallFake ->
test_thread_starred
spyOn(Actions, 'queueTask')
messageToolbarItems = TestUtils.renderIntoDocument(<MessageToolbarItems />)
starButton = React.findDOMNode(messageToolbarItems.refs.starButton)
TestUtils.Simulate.click starButton
expect(Actions.queueTask.mostRecentCall.args[0].thread).toBe(test_thread_starred)
expect(Actions.queueTask.mostRecentCall.args[0].tagIdsToAdd).toEqual([])
expect(Actions.queueTask.mostRecentCall.args[0].tagIdsToRemove).toEqual(['starred'])