mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-01-04 07:10:06 +08:00
42 lines
1.9 KiB
Text
42 lines
1.9 KiB
Text
|
const Thread = require('../../src/flux/models/thread').default;
|
||
|
const FocusedContentStore = require('../../src/flux/stores/focused-content-store').default;
|
||
|
|
||
|
const testThread = new Thread({ id: '123', accountId: TEST_ACCOUNT_ID });
|
||
|
|
||
|
describe('FocusedContentStore', function() {
|
||
|
describe('onSetFocus', function() {
|
||
|
it('should not trigger if the thread is already focused', function() {
|
||
|
FocusedContentStore._onFocus({ collection: 'thread', item: testThread });
|
||
|
spyOn(FocusedContentStore, 'triggerAfterAnimationFrame');
|
||
|
FocusedContentStore._onFocus({ collection: 'thread', item: testThread });
|
||
|
expect(FocusedContentStore.triggerAfterAnimationFrame).not.toHaveBeenCalled();
|
||
|
});
|
||
|
|
||
|
it('should not trigger if the focus is already null', function() {
|
||
|
FocusedContentStore._onFocus({ collection: 'thread', item: null });
|
||
|
spyOn(FocusedContentStore, 'triggerAfterAnimationFrame');
|
||
|
FocusedContentStore._onFocus({ collection: 'thread', item: null });
|
||
|
expect(FocusedContentStore.triggerAfterAnimationFrame).not.toHaveBeenCalled();
|
||
|
});
|
||
|
|
||
|
it('should trigger otherwise', function() {
|
||
|
FocusedContentStore._onFocus({ collection: 'thread', item: null });
|
||
|
spyOn(FocusedContentStore, 'triggerAfterAnimationFrame');
|
||
|
FocusedContentStore._onFocus({ collection: 'thread', item: testThread });
|
||
|
expect(FocusedContentStore.triggerAfterAnimationFrame).toHaveBeenCalled();
|
||
|
});
|
||
|
});
|
||
|
|
||
|
describe('threadId', () =>
|
||
|
it('should return the id of the focused thread', function() {
|
||
|
FocusedContentStore._onFocus({ collection: 'thread', item: testThread });
|
||
|
expect(FocusedContentStore.focusedId('thread')).toBe(testThread.id);
|
||
|
}));
|
||
|
|
||
|
describe('thread', () =>
|
||
|
it('should return the focused thread object', function() {
|
||
|
FocusedContentStore._onFocus({ collection: 'thread', item: testThread });
|
||
|
expect(FocusedContentStore.focused('thread')).toBe(testThread);
|
||
|
}));
|
||
|
});
|