Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
80728 views
1
/**
2
* This file is provided by Facebook for testing and evaluation purposes
3
* only. Facebook reserves all rights not expressly granted.
4
*
5
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
6
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
7
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
8
* FACEBOOK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
9
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
10
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
11
*/
12
13
jest.dontMock('../UnreadThreadStore');
14
jest.dontMock('object-assign');
15
16
describe('UnreadThreadStore', function() {
17
18
var ChatAppDispatcher;
19
var UnreadThreadStore;
20
var callback;
21
22
beforeEach(function() {
23
ChatAppDispatcher = require('../../dispatcher/ChatAppDispatcher');
24
UnreadThreadStore = require('../UnreadThreadStore');
25
callback = ChatAppDispatcher.register.mock.calls[0][0];
26
});
27
28
it('registers a callback with the dispatcher', function() {
29
expect(ChatAppDispatcher.register.mock.calls.length).toBe(1);
30
});
31
32
it('provides the unread thread count', function() {
33
var ThreadStore = require('../ThreadStore');
34
ThreadStore.getAll.mockReturnValueOnce(
35
{
36
foo: {lastMessage: {isRead: false}},
37
bar: {lastMessage: {isRead: false}},
38
baz: {lastMessage: {isRead: true}}
39
}
40
);
41
expect(UnreadThreadStore.getCount()).toBe(2);
42
});
43
44
});
45
46