mirror of
https://github.com/Foundry376/Mailspring.git
synced 2024-11-14 13:44:41 +08:00
886328ff7a
Great breakdown of React changes here: https://github.com/facebook/react/blob/master/CHANGELOG.md#0140-october-7-2015 Due to deprecation warnings, I don't think this will break third-party extensions unless they were doing really bad things.
61 lines
1.9 KiB
JavaScript
61 lines
1.9 KiB
JavaScript
import React from 'react';
|
|
import {findDOMNode} from 'react-dom';
|
|
import {Simulate, findRenderedDOMComponentWithClass} from 'react-addons-test-utils';
|
|
|
|
import {DateUtils} from 'nylas-exports'
|
|
import SendLaterPopover from '../lib/send-later-popover';
|
|
import {renderIntoDocument} from '../../../spec/nylas-test-utils'
|
|
|
|
const makePopover = (props = {})=> {
|
|
return renderIntoDocument(
|
|
<SendLaterPopover
|
|
scheduledDate={null}
|
|
onSendLater={()=>{}}
|
|
onCancelSendLater={()=>{}}
|
|
{...props} />
|
|
);
|
|
};
|
|
|
|
describe('SendLaterPopover', ()=> {
|
|
beforeEach(()=> {
|
|
spyOn(DateUtils, 'format').andReturn('formatted')
|
|
});
|
|
|
|
describe('selectDate', ()=> {
|
|
it('calls props.onSendLtaer', ()=> {
|
|
const onSendLater = jasmine.createSpy('onSendLater')
|
|
const popover = makePopover({onSendLater})
|
|
popover.selectDate({utc: ()=> 'utc'}, 'Custom')
|
|
|
|
expect(onSendLater).toHaveBeenCalledWith('formatted', 'Custom')
|
|
});
|
|
});
|
|
|
|
describe('onSelectCustomOption', ()=> {
|
|
it('selects date', ()=> {
|
|
const popover = makePopover()
|
|
spyOn(popover, 'selectDate')
|
|
popover.onSelectCustomOption('date', 'abc')
|
|
expect(popover.selectDate).toHaveBeenCalledWith('date', 'Custom')
|
|
});
|
|
|
|
it('throws error if date is invalid', ()=> {
|
|
spyOn(NylasEnv, 'showErrorDialog')
|
|
const popover = makePopover()
|
|
popover.onSelectCustomOption(null, 'abc')
|
|
expect(NylasEnv.showErrorDialog).toHaveBeenCalled()
|
|
});
|
|
});
|
|
|
|
describe('render', ()=> {
|
|
it('renders cancel button if scheduled', ()=> {
|
|
const onCancelSendLater = jasmine.createSpy('onCancelSendLater')
|
|
const popover = makePopover({onCancelSendLater, scheduledDate: 'date'})
|
|
const button = findDOMNode(
|
|
findRenderedDOMComponentWithClass(popover, 'btn-cancel')
|
|
)
|
|
Simulate.click(button)
|
|
expect(onCancelSendLater).toHaveBeenCalled()
|
|
});
|
|
});
|
|
});
|