2015-06-26 01:33:26 +08:00
|
|
|
React = require "react/addons"
|
2015-07-22 05:16:11 +08:00
|
|
|
ReactTestUtils = React.addons.TestUtils
|
2015-06-26 01:33:26 +08:00
|
|
|
TestUtils = React.addons.TestUtils
|
2015-07-16 23:54:20 +08:00
|
|
|
{Thread, FocusedContentStore, Actions} = require "nylas-exports"
|
2015-06-26 01:33:26 +08:00
|
|
|
|
2015-07-22 05:16:11 +08:00
|
|
|
StarButton = require '../lib/thread-star-button'
|
2015-06-26 01:33:26 +08:00
|
|
|
|
|
|
|
test_thread = (new Thread).fromJSON({
|
|
|
|
"id" : "thread_12345"
|
|
|
|
"subject" : "Subject 12345"
|
2015-07-16 23:54:20 +08:00
|
|
|
"starred": false
|
2015-06-26 01:33:26 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
test_thread_starred = (new Thread).fromJSON({
|
|
|
|
"id" : "thread_starred_12345"
|
|
|
|
"subject" : "Subject 12345"
|
2015-07-16 23:54:20 +08:00
|
|
|
"starred": true
|
2015-06-26 01:33:26 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
describe "MessageToolbarItem starring", ->
|
|
|
|
it "stars a thread if the star button is clicked and thread is unstarred", ->
|
|
|
|
spyOn(Actions, 'queueTask')
|
2015-07-22 05:16:11 +08:00
|
|
|
starButton = TestUtils.renderIntoDocument(<StarButton thread={test_thread}/>)
|
2015-06-26 01:33:26 +08:00
|
|
|
|
2015-07-22 05:16:11 +08:00
|
|
|
TestUtils.Simulate.click React.findDOMNode(starButton)
|
2015-06-26 01:33:26 +08:00
|
|
|
|
2015-08-06 06:53:08 +08:00
|
|
|
expect(Actions.queueTask.mostRecentCall.args[0].threads).toEqual([test_thread])
|
|
|
|
expect(Actions.queueTask.mostRecentCall.args[0].starred).toEqual(true)
|
2015-06-26 01:33:26 +08:00
|
|
|
|
|
|
|
it "unstars a thread if the star button is clicked and thread is starred", ->
|
|
|
|
spyOn(Actions, 'queueTask')
|
2015-07-22 05:16:11 +08:00
|
|
|
starButton = TestUtils.renderIntoDocument(<StarButton thread={test_thread_starred}/>)
|
2015-06-26 01:33:26 +08:00
|
|
|
|
2015-07-22 05:16:11 +08:00
|
|
|
TestUtils.Simulate.click React.findDOMNode(starButton)
|
2015-06-26 01:33:26 +08:00
|
|
|
|
2015-08-06 06:53:08 +08:00
|
|
|
expect(Actions.queueTask.mostRecentCall.args[0].threads).toEqual([test_thread_starred])
|
|
|
|
expect(Actions.queueTask.mostRecentCall.args[0].starred).toEqual(false)
|