describe('CommentStore', () => { it('should propagate comments when loaded successfully', () => { const commentList = [{ name: 'John', content: 'It looks good!' }, { name: 'Jane', content: 'Good job, dude!' }]; const listener = AppDispatcher.register.mock.calls[0][0]; listener({ type: CommentConstants.LOAD_COMMENT_SUCCESS, payload: { comment: { commentList, } } }); expect(CommentStore.getComment()).toEqual(commentList); }); });
describe('UnreadThreadStore', function() { var ChatAppDispatcher; var UnreadThreadStore; var callback; beforeEach(function() { ChatAppDispatcher = require('../../dispatcher/ChatAppDispatcher'); UnreadThreadStore = require('../UnreadThreadStore'); callback = ChatAppDispatcher.register.mock.calls[0][0]; }); it('registers a callback with the dispatcher', function() { expect(ChatAppDispatcher.register.mock.calls.length).toBe(1); }); it('provides the unread thread count', function() { var ThreadStore = require('../ThreadStore'); ThreadStore.getAll.mockReturnValueOnce( { foo: {lastMessage: {isRead: false}}, bar: {lastMessage: {isRead: false}}, baz: {lastMessage: {isRead: true}} } ); expect(UnreadThreadStore.getCount()).toBe(2); }); });
describe('UnreadThreadStore', function() { var ChatAppDispatcher; var UnreadThreadStore; var callback; beforeEach(function() { ChatAppDispatcher = require('../../dispatcher/ChatAppDispatcher'); UnreadThreadStore = require('../UnreadThreadStore'); callback = ChatAppDispatcher.register.mock.calls[0][0]; }); it('registers a callback with the dispatcher', function() { expect(ChatAppDispatcher.register.mock.calls.length).toBe(1); }); it('provides the unread thread count', function() { var ThreadStore = require('../ThreadStore'); ThreadStore.getAll.mockReturnValueOnce( { foo: {lastMessage: {isRead: false}}, bar: {lastMessage: {isRead: false}}, baz: {lastMessage: {isRead: true}} } ); expect(UnreadThreadStore.getCount()).toBe(2); }); });