Mailspring/internal_packages/message-list/spec/message-toolbar-items-spec.cjsx
Evan Morikawa 00c74cd1a9 WIP: This is the initial diff for new folders & labels.
Summary:
There are now two objects, Folders & Labels. These inherit from `Category`
(that's what Eben said they were using on the backend).

There are two separate tasks.

1. MoveToFolderTask
2. ApplyLabelsTask

It turns out that the semantics between the two are quite different.
The reverse operation for moving to a folder is a bit tricky.

As of 7-8-15, the Tasks are pretty much complete. I need to write tests
for them still and do some manual testing in the client.

Test Plan: Writing specs

Reviewers: bengotow

Reviewed By: bengotow

Differential Revision: https://phab.nylas.com/D1724
2015-07-16 11:54:20 -04:00

44 lines
1.6 KiB
CoffeeScript

React = require "react/addons"
TestUtils = React.addons.TestUtils
{Thread, FocusedContentStore, Actions} = require "nylas-exports"
MessageToolbarItems = require '../lib/message-toolbar-items'
test_thread = (new Thread).fromJSON({
"id" : "thread_12345"
"subject" : "Subject 12345"
"starred": false
})
test_thread_starred = (new Thread).fromJSON({
"id" : "thread_starred_12345"
"subject" : "Subject 12345"
"starred": true
})
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].objects).toEqual([test_thread])
expect(Actions.queueTask.mostRecentCall.args[0].newValues).toEqual(starred: true)
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].objects).toEqual([test_thread_starred])
expect(Actions.queueTask.mostRecentCall.args[0].newValues).toEqual(starred: false)