mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-01-09 01:35:52 +08:00
3954289cf4
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
43 lines
1.6 KiB
CoffeeScript
43 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)
|