Make it more difficult to blur avatars
This commit is contained in:
parent
1276368f94
commit
d28678dbf9
79 changed files with 1118 additions and 889 deletions
|
@ -6,16 +6,11 @@ import * as sinon from 'sinon';
|
|||
import { v4 as uuid } from 'uuid';
|
||||
import { RowType } from '../../../components/ConversationList';
|
||||
import { FindDirection } from '../../../components/leftPane/LeftPaneHelper';
|
||||
import { getDefaultConversation } from '../../../test-both/helpers/getDefaultConversation';
|
||||
|
||||
import { LeftPaneArchiveHelper } from '../../../components/leftPane/LeftPaneArchiveHelper';
|
||||
|
||||
describe('LeftPaneArchiveHelper', () => {
|
||||
const fakeConversation = () => ({
|
||||
id: uuid(),
|
||||
title: uuid(),
|
||||
type: 'direct' as const,
|
||||
});
|
||||
|
||||
describe('getBackAction', () => {
|
||||
it('returns the "show inbox" action', () => {
|
||||
const showInbox = sinon.fake();
|
||||
|
@ -33,7 +28,10 @@ describe('LeftPaneArchiveHelper', () => {
|
|||
);
|
||||
assert.strictEqual(
|
||||
new LeftPaneArchiveHelper({
|
||||
archivedConversations: [fakeConversation(), fakeConversation()],
|
||||
archivedConversations: [
|
||||
getDefaultConversation(),
|
||||
getDefaultConversation(),
|
||||
],
|
||||
}).getRowCount(),
|
||||
2
|
||||
);
|
||||
|
@ -43,7 +41,10 @@ describe('LeftPaneArchiveHelper', () => {
|
|||
describe('getRowIndexToScrollTo', () => {
|
||||
it('returns undefined if no conversation is selected', () => {
|
||||
const helper = new LeftPaneArchiveHelper({
|
||||
archivedConversations: [fakeConversation(), fakeConversation()],
|
||||
archivedConversations: [
|
||||
getDefaultConversation(),
|
||||
getDefaultConversation(),
|
||||
],
|
||||
});
|
||||
|
||||
assert.isUndefined(helper.getRowIndexToScrollTo(undefined));
|
||||
|
@ -51,14 +52,20 @@ describe('LeftPaneArchiveHelper', () => {
|
|||
|
||||
it('returns undefined if the selected conversation is not pinned or non-pinned', () => {
|
||||
const helper = new LeftPaneArchiveHelper({
|
||||
archivedConversations: [fakeConversation(), fakeConversation()],
|
||||
archivedConversations: [
|
||||
getDefaultConversation(),
|
||||
getDefaultConversation(),
|
||||
],
|
||||
});
|
||||
|
||||
assert.isUndefined(helper.getRowIndexToScrollTo(uuid()));
|
||||
});
|
||||
|
||||
it("returns the archived conversation's index", () => {
|
||||
const archivedConversations = [fakeConversation(), fakeConversation()];
|
||||
const archivedConversations = [
|
||||
getDefaultConversation(),
|
||||
getDefaultConversation(),
|
||||
];
|
||||
const helper = new LeftPaneArchiveHelper({ archivedConversations });
|
||||
|
||||
assert.strictEqual(
|
||||
|
@ -74,7 +81,10 @@ describe('LeftPaneArchiveHelper', () => {
|
|||
|
||||
describe('getRow', () => {
|
||||
it('returns each conversation as a row', () => {
|
||||
const archivedConversations = [fakeConversation(), fakeConversation()];
|
||||
const archivedConversations = [
|
||||
getDefaultConversation(),
|
||||
getDefaultConversation(),
|
||||
];
|
||||
const helper = new LeftPaneArchiveHelper({ archivedConversations });
|
||||
|
||||
assert.deepEqual(helper.getRow(0), {
|
||||
|
@ -90,7 +100,10 @@ describe('LeftPaneArchiveHelper', () => {
|
|||
|
||||
describe('getConversationAndMessageAtIndex', () => {
|
||||
it('returns the conversation at the given index when it exists', () => {
|
||||
const archivedConversations = [fakeConversation(), fakeConversation()];
|
||||
const archivedConversations = [
|
||||
getDefaultConversation(),
|
||||
getDefaultConversation(),
|
||||
];
|
||||
const helper = new LeftPaneArchiveHelper({ archivedConversations });
|
||||
|
||||
assert.strictEqual(
|
||||
|
@ -104,7 +117,10 @@ describe('LeftPaneArchiveHelper', () => {
|
|||
});
|
||||
|
||||
it('when requesting an index out of bounds, returns the last conversation', () => {
|
||||
const archivedConversations = [fakeConversation(), fakeConversation()];
|
||||
const archivedConversations = [
|
||||
getDefaultConversation(),
|
||||
getDefaultConversation(),
|
||||
];
|
||||
const helper = new LeftPaneArchiveHelper({ archivedConversations });
|
||||
|
||||
assert.strictEqual(
|
||||
|
@ -135,7 +151,10 @@ describe('LeftPaneArchiveHelper', () => {
|
|||
|
||||
describe('getConversationAndMessageInDirection', () => {
|
||||
it('returns the next conversation when searching downward', () => {
|
||||
const archivedConversations = [fakeConversation(), fakeConversation()];
|
||||
const archivedConversations = [
|
||||
getDefaultConversation(),
|
||||
getDefaultConversation(),
|
||||
];
|
||||
const helper = new LeftPaneArchiveHelper({ archivedConversations });
|
||||
|
||||
assert.deepEqual(
|
||||
|
@ -154,17 +173,23 @@ describe('LeftPaneArchiveHelper', () => {
|
|||
describe('shouldRecomputeRowHeights', () => {
|
||||
it('always returns false because row heights are constant', () => {
|
||||
const helper = new LeftPaneArchiveHelper({
|
||||
archivedConversations: [fakeConversation(), fakeConversation()],
|
||||
archivedConversations: [
|
||||
getDefaultConversation(),
|
||||
getDefaultConversation(),
|
||||
],
|
||||
});
|
||||
|
||||
assert.isFalse(
|
||||
helper.shouldRecomputeRowHeights({
|
||||
archivedConversations: [fakeConversation()],
|
||||
archivedConversations: [getDefaultConversation()],
|
||||
})
|
||||
);
|
||||
assert.isFalse(
|
||||
helper.shouldRecomputeRowHeights({
|
||||
archivedConversations: [fakeConversation(), fakeConversation()],
|
||||
archivedConversations: [
|
||||
getDefaultConversation(),
|
||||
getDefaultConversation(),
|
||||
],
|
||||
})
|
||||
);
|
||||
});
|
||||
|
|
|
@ -4,10 +4,10 @@
|
|||
import { assert } from 'chai';
|
||||
import * as sinon from 'sinon';
|
||||
import { times } from 'lodash';
|
||||
import { v4 as uuid } from 'uuid';
|
||||
import { RowType } from '../../../components/ConversationList';
|
||||
import * as remoteConfig from '../../../RemoteConfig';
|
||||
import { ContactCheckboxDisabledReason } from '../../../components/conversationList/ContactCheckbox';
|
||||
import { getDefaultConversation } from '../../../test-both/helpers/getDefaultConversation';
|
||||
|
||||
import { LeftPaneChooseGroupMembersHelper } from '../../../components/leftPane/LeftPaneChooseGroupMembersHelper';
|
||||
|
||||
|
@ -21,13 +21,6 @@ describe('LeftPaneChooseGroupMembersHelper', () => {
|
|||
selectedContacts: [],
|
||||
};
|
||||
|
||||
const fakeContact = () => ({
|
||||
id: uuid(),
|
||||
isGroupV2Capable: true,
|
||||
title: uuid(),
|
||||
type: 'direct' as const,
|
||||
});
|
||||
|
||||
let sinonSandbox: sinon.SinonSandbox;
|
||||
|
||||
beforeEach(() => {
|
||||
|
@ -64,7 +57,7 @@ describe('LeftPaneChooseGroupMembersHelper', () => {
|
|||
...defaults,
|
||||
candidateContacts: [],
|
||||
searchTerm: '',
|
||||
selectedContacts: [fakeContact()],
|
||||
selectedContacts: [getDefaultConversation()],
|
||||
}).getRowCount(),
|
||||
0
|
||||
);
|
||||
|
@ -73,7 +66,7 @@ describe('LeftPaneChooseGroupMembersHelper', () => {
|
|||
...defaults,
|
||||
candidateContacts: [],
|
||||
searchTerm: 'foo bar',
|
||||
selectedContacts: [fakeContact()],
|
||||
selectedContacts: [getDefaultConversation()],
|
||||
}).getRowCount(),
|
||||
0
|
||||
);
|
||||
|
@ -83,9 +76,12 @@ describe('LeftPaneChooseGroupMembersHelper', () => {
|
|||
assert.strictEqual(
|
||||
new LeftPaneChooseGroupMembersHelper({
|
||||
...defaults,
|
||||
candidateContacts: [fakeContact(), fakeContact()],
|
||||
candidateContacts: [
|
||||
getDefaultConversation(),
|
||||
getDefaultConversation(),
|
||||
],
|
||||
searchTerm: '',
|
||||
selectedContacts: [fakeContact()],
|
||||
selectedContacts: [getDefaultConversation()],
|
||||
}).getRowCount(),
|
||||
4
|
||||
);
|
||||
|
@ -99,7 +95,7 @@ describe('LeftPaneChooseGroupMembersHelper', () => {
|
|||
...defaults,
|
||||
candidateContacts: [],
|
||||
searchTerm: '',
|
||||
selectedContacts: [fakeContact()],
|
||||
selectedContacts: [getDefaultConversation()],
|
||||
}).getRow(0)
|
||||
);
|
||||
assert.isUndefined(
|
||||
|
@ -107,7 +103,7 @@ describe('LeftPaneChooseGroupMembersHelper', () => {
|
|||
...defaults,
|
||||
candidateContacts: [],
|
||||
searchTerm: '',
|
||||
selectedContacts: [fakeContact()],
|
||||
selectedContacts: [getDefaultConversation()],
|
||||
}).getRow(99)
|
||||
);
|
||||
assert.isUndefined(
|
||||
|
@ -115,13 +111,16 @@ describe('LeftPaneChooseGroupMembersHelper', () => {
|
|||
...defaults,
|
||||
candidateContacts: [],
|
||||
searchTerm: 'foo bar',
|
||||
selectedContacts: [fakeContact()],
|
||||
selectedContacts: [getDefaultConversation()],
|
||||
}).getRow(0)
|
||||
);
|
||||
});
|
||||
|
||||
it('returns a header, then the contacts, then a blank space if there are contacts', () => {
|
||||
const candidateContacts = [fakeContact(), fakeContact()];
|
||||
const candidateContacts = [
|
||||
getDefaultConversation(),
|
||||
getDefaultConversation(),
|
||||
];
|
||||
const helper = new LeftPaneChooseGroupMembersHelper({
|
||||
...defaults,
|
||||
candidateContacts,
|
||||
|
@ -149,7 +148,7 @@ describe('LeftPaneChooseGroupMembersHelper', () => {
|
|||
});
|
||||
|
||||
it("disables non-selected contact checkboxes if you've selected the maximum number of contacts", () => {
|
||||
const candidateContacts = times(50, () => fakeContact());
|
||||
const candidateContacts = times(50, () => getDefaultConversation());
|
||||
const helper = new LeftPaneChooseGroupMembersHelper({
|
||||
...defaults,
|
||||
candidateContacts,
|
||||
|
@ -173,9 +172,9 @@ describe('LeftPaneChooseGroupMembersHelper', () => {
|
|||
|
||||
it("disables contacts that aren't GV2-capable, unless they are already selected somehow", () => {
|
||||
const candidateContacts = [
|
||||
{ ...fakeContact(), isGroupV2Capable: false },
|
||||
{ ...fakeContact(), isGroupV2Capable: undefined },
|
||||
{ ...fakeContact(), isGroupV2Capable: false },
|
||||
{ ...getDefaultConversation(), isGroupV2Capable: false },
|
||||
{ ...getDefaultConversation(), isGroupV2Capable: undefined },
|
||||
{ ...getDefaultConversation(), isGroupV2Capable: false },
|
||||
];
|
||||
|
||||
const helper = new LeftPaneChooseGroupMembersHelper({
|
||||
|
|
|
@ -3,20 +3,14 @@
|
|||
|
||||
import { assert } from 'chai';
|
||||
import * as sinon from 'sinon';
|
||||
import { v4 as uuid } from 'uuid';
|
||||
import { RowType } from '../../../components/ConversationList';
|
||||
import { FindDirection } from '../../../components/leftPane/LeftPaneHelper';
|
||||
import * as remoteConfig from '../../../RemoteConfig';
|
||||
import { getDefaultConversation } from '../../../test-both/helpers/getDefaultConversation';
|
||||
|
||||
import { LeftPaneComposeHelper } from '../../../components/leftPane/LeftPaneComposeHelper';
|
||||
|
||||
describe('LeftPaneComposeHelper', () => {
|
||||
const fakeConvo = () => ({
|
||||
id: uuid(),
|
||||
title: uuid(),
|
||||
type: 'direct' as const,
|
||||
});
|
||||
|
||||
let sinonSandbox: sinon.SinonSandbox;
|
||||
let remoteConfigStub: sinon.SinonStub;
|
||||
|
||||
|
@ -65,7 +59,7 @@ describe('LeftPaneComposeHelper', () => {
|
|||
it('returns the number of contacts + 2 (for the "new group" button and header) if not searching', () => {
|
||||
assert.strictEqual(
|
||||
new LeftPaneComposeHelper({
|
||||
composeContacts: [fakeConvo(), fakeConvo()],
|
||||
composeContacts: [getDefaultConversation(), getDefaultConversation()],
|
||||
composeGroups: [],
|
||||
regionCode: 'US',
|
||||
searchTerm: '',
|
||||
|
@ -77,8 +71,8 @@ describe('LeftPaneComposeHelper', () => {
|
|||
it('returns the number of contacts + number of groups + 3 (for the "new group" button and the headers) if not searching', () => {
|
||||
assert.strictEqual(
|
||||
new LeftPaneComposeHelper({
|
||||
composeContacts: [fakeConvo(), fakeConvo()],
|
||||
composeGroups: [fakeConvo(), fakeConvo()],
|
||||
composeContacts: [getDefaultConversation(), getDefaultConversation()],
|
||||
composeGroups: [getDefaultConversation(), getDefaultConversation()],
|
||||
regionCode: 'US',
|
||||
searchTerm: '',
|
||||
}).getRowCount(),
|
||||
|
@ -98,7 +92,7 @@ describe('LeftPaneComposeHelper', () => {
|
|||
);
|
||||
assert.strictEqual(
|
||||
new LeftPaneComposeHelper({
|
||||
composeContacts: [fakeConvo(), fakeConvo()],
|
||||
composeContacts: [getDefaultConversation(), getDefaultConversation()],
|
||||
composeGroups: [],
|
||||
regionCode: 'US',
|
||||
searchTerm: 'foo bar',
|
||||
|
@ -107,8 +101,8 @@ describe('LeftPaneComposeHelper', () => {
|
|||
);
|
||||
assert.strictEqual(
|
||||
new LeftPaneComposeHelper({
|
||||
composeContacts: [fakeConvo(), fakeConvo()],
|
||||
composeGroups: [fakeConvo()],
|
||||
composeContacts: [getDefaultConversation(), getDefaultConversation()],
|
||||
composeGroups: [getDefaultConversation()],
|
||||
regionCode: 'US',
|
||||
searchTerm: 'foo bar',
|
||||
}).getRowCount(),
|
||||
|
@ -131,7 +125,7 @@ describe('LeftPaneComposeHelper', () => {
|
|||
it('returns the number of contacts + 2 (for the "Start new conversation" button and header) if searching for a phone number', () => {
|
||||
assert.strictEqual(
|
||||
new LeftPaneComposeHelper({
|
||||
composeContacts: [fakeConvo(), fakeConvo()],
|
||||
composeContacts: [getDefaultConversation(), getDefaultConversation()],
|
||||
composeGroups: [],
|
||||
regionCode: 'US',
|
||||
searchTerm: '+16505551234',
|
||||
|
@ -157,7 +151,10 @@ describe('LeftPaneComposeHelper', () => {
|
|||
});
|
||||
|
||||
it('returns a "new group" button, a header, and contacts if not searching', () => {
|
||||
const composeContacts = [fakeConvo(), fakeConvo()];
|
||||
const composeContacts = [
|
||||
getDefaultConversation(),
|
||||
getDefaultConversation(),
|
||||
];
|
||||
const helper = new LeftPaneComposeHelper({
|
||||
composeContacts,
|
||||
composeGroups: [],
|
||||
|
@ -183,8 +180,14 @@ describe('LeftPaneComposeHelper', () => {
|
|||
});
|
||||
|
||||
it('returns a "new group" button, a header, contacts, groups header, and groups -- if not searching', () => {
|
||||
const composeContacts = [fakeConvo(), fakeConvo()];
|
||||
const composeGroups = [fakeConvo(), fakeConvo()];
|
||||
const composeContacts = [
|
||||
getDefaultConversation(),
|
||||
getDefaultConversation(),
|
||||
];
|
||||
const composeGroups = [
|
||||
getDefaultConversation(),
|
||||
getDefaultConversation(),
|
||||
];
|
||||
const helper = new LeftPaneComposeHelper({
|
||||
composeContacts,
|
||||
composeGroups,
|
||||
|
@ -266,7 +269,10 @@ describe('LeftPaneComposeHelper', () => {
|
|||
});
|
||||
|
||||
it('returns one row per contact if searching', () => {
|
||||
const composeContacts = [fakeConvo(), fakeConvo()];
|
||||
const composeContacts = [
|
||||
getDefaultConversation(),
|
||||
getDefaultConversation(),
|
||||
];
|
||||
const helper = new LeftPaneComposeHelper({
|
||||
composeContacts,
|
||||
composeGroups: [],
|
||||
|
@ -300,7 +306,10 @@ describe('LeftPaneComposeHelper', () => {
|
|||
});
|
||||
|
||||
it('returns a "start new conversation" row, a header, and contacts if searching for a phone number', () => {
|
||||
const composeContacts = [fakeConvo(), fakeConvo()];
|
||||
const composeContacts = [
|
||||
getDefaultConversation(),
|
||||
getDefaultConversation(),
|
||||
];
|
||||
const helper = new LeftPaneComposeHelper({
|
||||
composeContacts,
|
||||
composeGroups: [],
|
||||
|
@ -330,7 +339,7 @@ describe('LeftPaneComposeHelper', () => {
|
|||
describe('getConversationAndMessageAtIndex', () => {
|
||||
it('returns undefined because keyboard shortcuts are not supported', () => {
|
||||
const helper = new LeftPaneComposeHelper({
|
||||
composeContacts: [fakeConvo(), fakeConvo()],
|
||||
composeContacts: [getDefaultConversation(), getDefaultConversation()],
|
||||
composeGroups: [],
|
||||
regionCode: 'US',
|
||||
searchTerm: 'foo bar',
|
||||
|
@ -343,7 +352,7 @@ describe('LeftPaneComposeHelper', () => {
|
|||
describe('getConversationAndMessageInDirection', () => {
|
||||
it('returns undefined because keyboard shortcuts are not supported', () => {
|
||||
const helper = new LeftPaneComposeHelper({
|
||||
composeContacts: [fakeConvo(), fakeConvo()],
|
||||
composeContacts: [getDefaultConversation(), getDefaultConversation()],
|
||||
composeGroups: [],
|
||||
regionCode: 'US',
|
||||
searchTerm: 'foo bar',
|
||||
|
@ -362,7 +371,7 @@ describe('LeftPaneComposeHelper', () => {
|
|||
describe('shouldRecomputeRowHeights', () => {
|
||||
it('returns false if going from "no header" to "no header"', () => {
|
||||
const helper = new LeftPaneComposeHelper({
|
||||
composeContacts: [fakeConvo(), fakeConvo()],
|
||||
composeContacts: [getDefaultConversation(), getDefaultConversation()],
|
||||
composeGroups: [],
|
||||
regionCode: 'US',
|
||||
searchTerm: 'foo bar',
|
||||
|
@ -370,7 +379,7 @@ describe('LeftPaneComposeHelper', () => {
|
|||
|
||||
assert.isFalse(
|
||||
helper.shouldRecomputeRowHeights({
|
||||
composeContacts: [fakeConvo()],
|
||||
composeContacts: [getDefaultConversation()],
|
||||
composeGroups: [],
|
||||
regionCode: 'US',
|
||||
searchTerm: 'foo bar',
|
||||
|
@ -378,7 +387,11 @@ describe('LeftPaneComposeHelper', () => {
|
|||
);
|
||||
assert.isFalse(
|
||||
helper.shouldRecomputeRowHeights({
|
||||
composeContacts: [fakeConvo(), fakeConvo(), fakeConvo()],
|
||||
composeContacts: [
|
||||
getDefaultConversation(),
|
||||
getDefaultConversation(),
|
||||
getDefaultConversation(),
|
||||
],
|
||||
composeGroups: [],
|
||||
regionCode: 'US',
|
||||
searchTerm: 'bing bong',
|
||||
|
@ -388,7 +401,7 @@ describe('LeftPaneComposeHelper', () => {
|
|||
|
||||
it('returns false if going from "has header" to "has header"', () => {
|
||||
const helper = new LeftPaneComposeHelper({
|
||||
composeContacts: [fakeConvo(), fakeConvo()],
|
||||
composeContacts: [getDefaultConversation(), getDefaultConversation()],
|
||||
composeGroups: [],
|
||||
regionCode: 'US',
|
||||
searchTerm: '',
|
||||
|
@ -396,7 +409,7 @@ describe('LeftPaneComposeHelper', () => {
|
|||
|
||||
assert.isFalse(
|
||||
helper.shouldRecomputeRowHeights({
|
||||
composeContacts: [fakeConvo()],
|
||||
composeContacts: [getDefaultConversation()],
|
||||
composeGroups: [],
|
||||
regionCode: 'US',
|
||||
searchTerm: '',
|
||||
|
@ -404,7 +417,7 @@ describe('LeftPaneComposeHelper', () => {
|
|||
);
|
||||
assert.isFalse(
|
||||
helper.shouldRecomputeRowHeights({
|
||||
composeContacts: [fakeConvo()],
|
||||
composeContacts: [getDefaultConversation()],
|
||||
composeGroups: [],
|
||||
regionCode: 'US',
|
||||
searchTerm: '+16505559876',
|
||||
|
@ -414,7 +427,7 @@ describe('LeftPaneComposeHelper', () => {
|
|||
|
||||
it('returns true if going from "no header" to "has header"', () => {
|
||||
const helper = new LeftPaneComposeHelper({
|
||||
composeContacts: [fakeConvo(), fakeConvo()],
|
||||
composeContacts: [getDefaultConversation(), getDefaultConversation()],
|
||||
composeGroups: [],
|
||||
regionCode: 'US',
|
||||
searchTerm: 'foo bar',
|
||||
|
@ -422,7 +435,7 @@ describe('LeftPaneComposeHelper', () => {
|
|||
|
||||
assert.isTrue(
|
||||
helper.shouldRecomputeRowHeights({
|
||||
composeContacts: [fakeConvo(), fakeConvo()],
|
||||
composeContacts: [getDefaultConversation(), getDefaultConversation()],
|
||||
composeGroups: [],
|
||||
regionCode: 'US',
|
||||
searchTerm: '',
|
||||
|
@ -430,7 +443,7 @@ describe('LeftPaneComposeHelper', () => {
|
|||
);
|
||||
assert.isTrue(
|
||||
helper.shouldRecomputeRowHeights({
|
||||
composeContacts: [fakeConvo(), fakeConvo()],
|
||||
composeContacts: [getDefaultConversation(), getDefaultConversation()],
|
||||
composeGroups: [],
|
||||
regionCode: 'US',
|
||||
searchTerm: '+16505551234',
|
||||
|
@ -440,7 +453,7 @@ describe('LeftPaneComposeHelper', () => {
|
|||
|
||||
it('returns true if going from "has header" to "no header"', () => {
|
||||
const helper = new LeftPaneComposeHelper({
|
||||
composeContacts: [fakeConvo(), fakeConvo()],
|
||||
composeContacts: [getDefaultConversation(), getDefaultConversation()],
|
||||
composeGroups: [],
|
||||
regionCode: 'US',
|
||||
searchTerm: '',
|
||||
|
@ -448,7 +461,7 @@ describe('LeftPaneComposeHelper', () => {
|
|||
|
||||
assert.isTrue(
|
||||
helper.shouldRecomputeRowHeights({
|
||||
composeContacts: [fakeConvo(), fakeConvo()],
|
||||
composeContacts: [getDefaultConversation(), getDefaultConversation()],
|
||||
composeGroups: [],
|
||||
regionCode: 'US',
|
||||
searchTerm: 'foo bar',
|
||||
|
@ -458,7 +471,7 @@ describe('LeftPaneComposeHelper', () => {
|
|||
|
||||
it('should be true if going from contact to group or vice versa', () => {
|
||||
const helperContacts = new LeftPaneComposeHelper({
|
||||
composeContacts: [fakeConvo(), fakeConvo()],
|
||||
composeContacts: [getDefaultConversation(), getDefaultConversation()],
|
||||
composeGroups: [],
|
||||
regionCode: 'US',
|
||||
searchTerm: 'foo bar',
|
||||
|
@ -467,7 +480,7 @@ describe('LeftPaneComposeHelper', () => {
|
|||
assert.isTrue(
|
||||
helperContacts.shouldRecomputeRowHeights({
|
||||
composeContacts: [],
|
||||
composeGroups: [fakeConvo(), fakeConvo()],
|
||||
composeGroups: [getDefaultConversation(), getDefaultConversation()],
|
||||
regionCode: 'US',
|
||||
searchTerm: 'foo bar',
|
||||
})
|
||||
|
@ -475,14 +488,14 @@ describe('LeftPaneComposeHelper', () => {
|
|||
|
||||
const helperGroups = new LeftPaneComposeHelper({
|
||||
composeContacts: [],
|
||||
composeGroups: [fakeConvo(), fakeConvo()],
|
||||
composeGroups: [getDefaultConversation(), getDefaultConversation()],
|
||||
regionCode: 'US',
|
||||
searchTerm: 'foo bar',
|
||||
});
|
||||
|
||||
assert.isTrue(
|
||||
helperGroups.shouldRecomputeRowHeights({
|
||||
composeContacts: [fakeConvo(), fakeConvo()],
|
||||
composeContacts: [getDefaultConversation(), getDefaultConversation()],
|
||||
composeGroups: [],
|
||||
regionCode: 'US',
|
||||
searchTerm: 'foo bar',
|
||||
|
@ -492,16 +505,16 @@ describe('LeftPaneComposeHelper', () => {
|
|||
|
||||
it('should be true if the headers are in different row indices as before', () => {
|
||||
const helperContacts = new LeftPaneComposeHelper({
|
||||
composeContacts: [fakeConvo(), fakeConvo()],
|
||||
composeGroups: [fakeConvo()],
|
||||
composeContacts: [getDefaultConversation(), getDefaultConversation()],
|
||||
composeGroups: [getDefaultConversation()],
|
||||
regionCode: 'US',
|
||||
searchTerm: 'soup',
|
||||
});
|
||||
|
||||
assert.isTrue(
|
||||
helperContacts.shouldRecomputeRowHeights({
|
||||
composeContacts: [fakeConvo()],
|
||||
composeGroups: [fakeConvo(), fakeConvo()],
|
||||
composeContacts: [getDefaultConversation()],
|
||||
composeGroups: [getDefaultConversation(), getDefaultConversation()],
|
||||
regionCode: 'US',
|
||||
searchTerm: 'sandwich',
|
||||
})
|
||||
|
|
|
@ -3,19 +3,13 @@
|
|||
|
||||
import { assert } from 'chai';
|
||||
import * as sinon from 'sinon';
|
||||
import { v4 as uuid } from 'uuid';
|
||||
import { RowType } from '../../../components/ConversationList';
|
||||
import { FindDirection } from '../../../components/leftPane/LeftPaneHelper';
|
||||
import { getDefaultConversation } from '../../../test-both/helpers/getDefaultConversation';
|
||||
|
||||
import { LeftPaneInboxHelper } from '../../../components/leftPane/LeftPaneInboxHelper';
|
||||
|
||||
describe('LeftPaneInboxHelper', () => {
|
||||
const fakeConversation = () => ({
|
||||
id: uuid(),
|
||||
title: uuid(),
|
||||
type: 'direct' as const,
|
||||
});
|
||||
|
||||
describe('getBackAction', () => {
|
||||
it("returns undefined; you can't go back from the main inbox", () => {
|
||||
const helper = new LeftPaneInboxHelper({
|
||||
|
@ -49,7 +43,7 @@ describe('LeftPaneInboxHelper', () => {
|
|||
const helper = new LeftPaneInboxHelper({
|
||||
conversations: [],
|
||||
pinnedConversations: [],
|
||||
archivedConversations: [fakeConversation()],
|
||||
archivedConversations: [getDefaultConversation()],
|
||||
});
|
||||
|
||||
assert.strictEqual(helper.getRowCount(), 1);
|
||||
|
@ -58,9 +52,9 @@ describe('LeftPaneInboxHelper', () => {
|
|||
it("returns the number of non-pinned conversations if that's all there is", () => {
|
||||
const helper = new LeftPaneInboxHelper({
|
||||
conversations: [
|
||||
fakeConversation(),
|
||||
fakeConversation(),
|
||||
fakeConversation(),
|
||||
getDefaultConversation(),
|
||||
getDefaultConversation(),
|
||||
getDefaultConversation(),
|
||||
],
|
||||
pinnedConversations: [],
|
||||
archivedConversations: [],
|
||||
|
@ -73,9 +67,9 @@ describe('LeftPaneInboxHelper', () => {
|
|||
const helper = new LeftPaneInboxHelper({
|
||||
conversations: [],
|
||||
pinnedConversations: [
|
||||
fakeConversation(),
|
||||
fakeConversation(),
|
||||
fakeConversation(),
|
||||
getDefaultConversation(),
|
||||
getDefaultConversation(),
|
||||
getDefaultConversation(),
|
||||
],
|
||||
archivedConversations: [],
|
||||
});
|
||||
|
@ -86,11 +80,11 @@ describe('LeftPaneInboxHelper', () => {
|
|||
it('adds 2 rows for each header if there are pinned and non-pinned conversations,', () => {
|
||||
const helper = new LeftPaneInboxHelper({
|
||||
conversations: [
|
||||
fakeConversation(),
|
||||
fakeConversation(),
|
||||
fakeConversation(),
|
||||
getDefaultConversation(),
|
||||
getDefaultConversation(),
|
||||
getDefaultConversation(),
|
||||
],
|
||||
pinnedConversations: [fakeConversation()],
|
||||
pinnedConversations: [getDefaultConversation()],
|
||||
archivedConversations: [],
|
||||
});
|
||||
|
||||
|
@ -100,12 +94,12 @@ describe('LeftPaneInboxHelper', () => {
|
|||
it('adds 1 row for the archive button if there are any archived conversations', () => {
|
||||
const helper = new LeftPaneInboxHelper({
|
||||
conversations: [
|
||||
fakeConversation(),
|
||||
fakeConversation(),
|
||||
fakeConversation(),
|
||||
getDefaultConversation(),
|
||||
getDefaultConversation(),
|
||||
getDefaultConversation(),
|
||||
],
|
||||
pinnedConversations: [],
|
||||
archivedConversations: [fakeConversation()],
|
||||
archivedConversations: [getDefaultConversation()],
|
||||
});
|
||||
|
||||
assert.strictEqual(helper.getRowCount(), 4);
|
||||
|
@ -115,8 +109,8 @@ describe('LeftPaneInboxHelper', () => {
|
|||
describe('getRowIndexToScrollTo', () => {
|
||||
it('returns undefined if no conversation is selected', () => {
|
||||
const helper = new LeftPaneInboxHelper({
|
||||
conversations: [fakeConversation(), fakeConversation()],
|
||||
pinnedConversations: [fakeConversation()],
|
||||
conversations: [getDefaultConversation(), getDefaultConversation()],
|
||||
pinnedConversations: [getDefaultConversation()],
|
||||
archivedConversations: [],
|
||||
});
|
||||
|
||||
|
@ -124,10 +118,10 @@ describe('LeftPaneInboxHelper', () => {
|
|||
});
|
||||
|
||||
it('returns undefined if the selected conversation is not pinned or non-pinned', () => {
|
||||
const archivedConversations = [fakeConversation()];
|
||||
const archivedConversations = [getDefaultConversation()];
|
||||
const helper = new LeftPaneInboxHelper({
|
||||
conversations: [fakeConversation(), fakeConversation()],
|
||||
pinnedConversations: [fakeConversation()],
|
||||
conversations: [getDefaultConversation(), getDefaultConversation()],
|
||||
pinnedConversations: [getDefaultConversation()],
|
||||
archivedConversations,
|
||||
});
|
||||
|
||||
|
@ -137,7 +131,10 @@ describe('LeftPaneInboxHelper', () => {
|
|||
});
|
||||
|
||||
it("returns the pinned conversation's index if there are only pinned conversations", () => {
|
||||
const pinnedConversations = [fakeConversation(), fakeConversation()];
|
||||
const pinnedConversations = [
|
||||
getDefaultConversation(),
|
||||
getDefaultConversation(),
|
||||
];
|
||||
const helper = new LeftPaneInboxHelper({
|
||||
conversations: [],
|
||||
pinnedConversations,
|
||||
|
@ -155,7 +152,10 @@ describe('LeftPaneInboxHelper', () => {
|
|||
});
|
||||
|
||||
it("returns the conversation's index if there are only non-pinned conversations", () => {
|
||||
const conversations = [fakeConversation(), fakeConversation()];
|
||||
const conversations = [
|
||||
getDefaultConversation(),
|
||||
getDefaultConversation(),
|
||||
];
|
||||
const helper = new LeftPaneInboxHelper({
|
||||
conversations,
|
||||
pinnedConversations: [],
|
||||
|
@ -167,9 +167,12 @@ describe('LeftPaneInboxHelper', () => {
|
|||
});
|
||||
|
||||
it("returns the pinned conversation's index + 1 (for the header) if there are both pinned and non-pinned conversations", () => {
|
||||
const pinnedConversations = [fakeConversation(), fakeConversation()];
|
||||
const pinnedConversations = [
|
||||
getDefaultConversation(),
|
||||
getDefaultConversation(),
|
||||
];
|
||||
const helper = new LeftPaneInboxHelper({
|
||||
conversations: [fakeConversation()],
|
||||
conversations: [getDefaultConversation()],
|
||||
pinnedConversations,
|
||||
archivedConversations: [],
|
||||
});
|
||||
|
@ -185,13 +188,16 @@ describe('LeftPaneInboxHelper', () => {
|
|||
});
|
||||
|
||||
it("returns the non-pinned conversation's index + pinnedConversations.length + 2 (for the headers) if there are both pinned and non-pinned conversations", () => {
|
||||
const conversations = [fakeConversation(), fakeConversation()];
|
||||
const conversations = [
|
||||
getDefaultConversation(),
|
||||
getDefaultConversation(),
|
||||
];
|
||||
const helper = new LeftPaneInboxHelper({
|
||||
conversations,
|
||||
pinnedConversations: [
|
||||
fakeConversation(),
|
||||
fakeConversation(),
|
||||
fakeConversation(),
|
||||
getDefaultConversation(),
|
||||
getDefaultConversation(),
|
||||
getDefaultConversation(),
|
||||
],
|
||||
archivedConversations: [],
|
||||
});
|
||||
|
@ -206,7 +212,10 @@ describe('LeftPaneInboxHelper', () => {
|
|||
const helper = new LeftPaneInboxHelper({
|
||||
conversations: [],
|
||||
pinnedConversations: [],
|
||||
archivedConversations: [fakeConversation(), fakeConversation()],
|
||||
archivedConversations: [
|
||||
getDefaultConversation(),
|
||||
getDefaultConversation(),
|
||||
],
|
||||
});
|
||||
|
||||
assert.deepEqual(helper.getRow(0), {
|
||||
|
@ -217,7 +226,10 @@ describe('LeftPaneInboxHelper', () => {
|
|||
});
|
||||
|
||||
it("returns pinned conversations if that's all there are", () => {
|
||||
const pinnedConversations = [fakeConversation(), fakeConversation()];
|
||||
const pinnedConversations = [
|
||||
getDefaultConversation(),
|
||||
getDefaultConversation(),
|
||||
];
|
||||
|
||||
const helper = new LeftPaneInboxHelper({
|
||||
conversations: [],
|
||||
|
@ -237,12 +249,15 @@ describe('LeftPaneInboxHelper', () => {
|
|||
});
|
||||
|
||||
it('returns pinned conversations and an archive button if there are no non-pinned conversations', () => {
|
||||
const pinnedConversations = [fakeConversation(), fakeConversation()];
|
||||
const pinnedConversations = [
|
||||
getDefaultConversation(),
|
||||
getDefaultConversation(),
|
||||
];
|
||||
|
||||
const helper = new LeftPaneInboxHelper({
|
||||
conversations: [],
|
||||
pinnedConversations,
|
||||
archivedConversations: [fakeConversation()],
|
||||
archivedConversations: [getDefaultConversation()],
|
||||
});
|
||||
|
||||
assert.deepEqual(helper.getRow(0), {
|
||||
|
@ -261,7 +276,10 @@ describe('LeftPaneInboxHelper', () => {
|
|||
});
|
||||
|
||||
it("returns non-pinned conversations if that's all there are", () => {
|
||||
const conversations = [fakeConversation(), fakeConversation()];
|
||||
const conversations = [
|
||||
getDefaultConversation(),
|
||||
getDefaultConversation(),
|
||||
];
|
||||
|
||||
const helper = new LeftPaneInboxHelper({
|
||||
conversations,
|
||||
|
@ -281,12 +299,15 @@ describe('LeftPaneInboxHelper', () => {
|
|||
});
|
||||
|
||||
it('returns non-pinned conversations and an archive button if there are no pinned conversations', () => {
|
||||
const conversations = [fakeConversation(), fakeConversation()];
|
||||
const conversations = [
|
||||
getDefaultConversation(),
|
||||
getDefaultConversation(),
|
||||
];
|
||||
|
||||
const helper = new LeftPaneInboxHelper({
|
||||
conversations,
|
||||
pinnedConversations: [],
|
||||
archivedConversations: [fakeConversation()],
|
||||
archivedConversations: [getDefaultConversation()],
|
||||
});
|
||||
|
||||
assert.deepEqual(helper.getRow(0), {
|
||||
|
@ -306,11 +327,14 @@ describe('LeftPaneInboxHelper', () => {
|
|||
|
||||
it('returns headers if there are both pinned and non-pinned conversations', () => {
|
||||
const conversations = [
|
||||
fakeConversation(),
|
||||
fakeConversation(),
|
||||
fakeConversation(),
|
||||
getDefaultConversation(),
|
||||
getDefaultConversation(),
|
||||
getDefaultConversation(),
|
||||
];
|
||||
const pinnedConversations = [
|
||||
getDefaultConversation(),
|
||||
getDefaultConversation(),
|
||||
];
|
||||
const pinnedConversations = [fakeConversation(), fakeConversation()];
|
||||
|
||||
const helper = new LeftPaneInboxHelper({
|
||||
conversations,
|
||||
|
@ -351,16 +375,19 @@ describe('LeftPaneInboxHelper', () => {
|
|||
|
||||
it('returns headers if there are both pinned and non-pinned conversations, and an archive button', () => {
|
||||
const conversations = [
|
||||
fakeConversation(),
|
||||
fakeConversation(),
|
||||
fakeConversation(),
|
||||
getDefaultConversation(),
|
||||
getDefaultConversation(),
|
||||
getDefaultConversation(),
|
||||
];
|
||||
const pinnedConversations = [
|
||||
getDefaultConversation(),
|
||||
getDefaultConversation(),
|
||||
];
|
||||
const pinnedConversations = [fakeConversation(), fakeConversation()];
|
||||
|
||||
const helper = new LeftPaneInboxHelper({
|
||||
conversations,
|
||||
pinnedConversations,
|
||||
archivedConversations: [fakeConversation()],
|
||||
archivedConversations: [getDefaultConversation()],
|
||||
});
|
||||
|
||||
assert.deepEqual(helper.getRow(0), {
|
||||
|
@ -402,11 +429,14 @@ describe('LeftPaneInboxHelper', () => {
|
|||
describe('getConversationAndMessageAtIndex', () => {
|
||||
it('returns pinned converastions, then non-pinned conversations', () => {
|
||||
const conversations = [
|
||||
fakeConversation(),
|
||||
fakeConversation(),
|
||||
fakeConversation(),
|
||||
getDefaultConversation(),
|
||||
getDefaultConversation(),
|
||||
getDefaultConversation(),
|
||||
];
|
||||
const pinnedConversations = [
|
||||
getDefaultConversation(),
|
||||
getDefaultConversation(),
|
||||
];
|
||||
const pinnedConversations = [fakeConversation(), fakeConversation()];
|
||||
|
||||
const helper = new LeftPaneInboxHelper({
|
||||
conversations,
|
||||
|
@ -437,7 +467,10 @@ describe('LeftPaneInboxHelper', () => {
|
|||
});
|
||||
|
||||
it("when requesting an index out of bounds, returns the last pinned conversation when that's all there is", () => {
|
||||
const pinnedConversations = [fakeConversation(), fakeConversation()];
|
||||
const pinnedConversations = [
|
||||
getDefaultConversation(),
|
||||
getDefaultConversation(),
|
||||
];
|
||||
|
||||
const helper = new LeftPaneInboxHelper({
|
||||
conversations: [],
|
||||
|
@ -462,7 +495,10 @@ describe('LeftPaneInboxHelper', () => {
|
|||
});
|
||||
|
||||
it("when requesting an index out of bounds, returns the last non-pinned conversation when that's all there is", () => {
|
||||
const conversations = [fakeConversation(), fakeConversation()];
|
||||
const conversations = [
|
||||
getDefaultConversation(),
|
||||
getDefaultConversation(),
|
||||
];
|
||||
|
||||
const helper = new LeftPaneInboxHelper({
|
||||
conversations,
|
||||
|
@ -487,8 +523,14 @@ describe('LeftPaneInboxHelper', () => {
|
|||
});
|
||||
|
||||
it('when requesting an index out of bounds, returns the last non-pinned conversation when there are both pinned and non-pinned conversations', () => {
|
||||
const conversations = [fakeConversation(), fakeConversation()];
|
||||
const pinnedConversations = [fakeConversation(), fakeConversation()];
|
||||
const conversations = [
|
||||
getDefaultConversation(),
|
||||
getDefaultConversation(),
|
||||
];
|
||||
const pinnedConversations = [
|
||||
getDefaultConversation(),
|
||||
getDefaultConversation(),
|
||||
];
|
||||
|
||||
const helper = new LeftPaneInboxHelper({
|
||||
conversations,
|
||||
|
@ -516,7 +558,7 @@ describe('LeftPaneInboxHelper', () => {
|
|||
const helper = new LeftPaneInboxHelper({
|
||||
conversations: [],
|
||||
pinnedConversations: [],
|
||||
archivedConversations: [fakeConversation()],
|
||||
archivedConversations: [getDefaultConversation()],
|
||||
});
|
||||
|
||||
assert.isUndefined(helper.getConversationAndMessageAtIndex(0));
|
||||
|
@ -527,8 +569,11 @@ describe('LeftPaneInboxHelper', () => {
|
|||
|
||||
describe('getConversationAndMessageInDirection', () => {
|
||||
it('returns the next conversation when searching downward', () => {
|
||||
const pinnedConversations = [fakeConversation(), fakeConversation()];
|
||||
const conversations = [fakeConversation()];
|
||||
const pinnedConversations = [
|
||||
getDefaultConversation(),
|
||||
getDefaultConversation(),
|
||||
];
|
||||
const conversations = [getDefaultConversation()];
|
||||
const helper = new LeftPaneInboxHelper({
|
||||
conversations,
|
||||
pinnedConversations,
|
||||
|
@ -552,23 +597,32 @@ describe('LeftPaneInboxHelper', () => {
|
|||
it("returns false if the number of conversations in each section doesn't change", () => {
|
||||
const helper = new LeftPaneInboxHelper({
|
||||
conversations: [
|
||||
fakeConversation(),
|
||||
fakeConversation(),
|
||||
fakeConversation(),
|
||||
getDefaultConversation(),
|
||||
getDefaultConversation(),
|
||||
getDefaultConversation(),
|
||||
],
|
||||
pinnedConversations: [fakeConversation(), fakeConversation()],
|
||||
archivedConversations: [fakeConversation()],
|
||||
pinnedConversations: [
|
||||
getDefaultConversation(),
|
||||
getDefaultConversation(),
|
||||
],
|
||||
archivedConversations: [getDefaultConversation()],
|
||||
});
|
||||
|
||||
assert.isFalse(
|
||||
helper.shouldRecomputeRowHeights({
|
||||
conversations: [
|
||||
fakeConversation(),
|
||||
fakeConversation(),
|
||||
fakeConversation(),
|
||||
getDefaultConversation(),
|
||||
getDefaultConversation(),
|
||||
getDefaultConversation(),
|
||||
],
|
||||
pinnedConversations: [
|
||||
getDefaultConversation(),
|
||||
getDefaultConversation(),
|
||||
],
|
||||
archivedConversations: [
|
||||
getDefaultConversation(),
|
||||
getDefaultConversation(),
|
||||
],
|
||||
pinnedConversations: [fakeConversation(), fakeConversation()],
|
||||
archivedConversations: [fakeConversation(), fakeConversation()],
|
||||
})
|
||||
);
|
||||
});
|
||||
|
@ -576,22 +630,28 @@ describe('LeftPaneInboxHelper', () => {
|
|||
it('returns false if the only thing changed is whether conversations are archived', () => {
|
||||
const helper = new LeftPaneInboxHelper({
|
||||
conversations: [
|
||||
fakeConversation(),
|
||||
fakeConversation(),
|
||||
fakeConversation(),
|
||||
getDefaultConversation(),
|
||||
getDefaultConversation(),
|
||||
getDefaultConversation(),
|
||||
],
|
||||
pinnedConversations: [fakeConversation(), fakeConversation()],
|
||||
archivedConversations: [fakeConversation()],
|
||||
pinnedConversations: [
|
||||
getDefaultConversation(),
|
||||
getDefaultConversation(),
|
||||
],
|
||||
archivedConversations: [getDefaultConversation()],
|
||||
});
|
||||
|
||||
assert.isFalse(
|
||||
helper.shouldRecomputeRowHeights({
|
||||
conversations: [
|
||||
fakeConversation(),
|
||||
fakeConversation(),
|
||||
fakeConversation(),
|
||||
getDefaultConversation(),
|
||||
getDefaultConversation(),
|
||||
getDefaultConversation(),
|
||||
],
|
||||
pinnedConversations: [
|
||||
getDefaultConversation(),
|
||||
getDefaultConversation(),
|
||||
],
|
||||
pinnedConversations: [fakeConversation(), fakeConversation()],
|
||||
archivedConversations: [],
|
||||
})
|
||||
);
|
||||
|
@ -600,53 +660,65 @@ describe('LeftPaneInboxHelper', () => {
|
|||
it('returns false if the only thing changed is the number of non-pinned conversations', () => {
|
||||
const helper = new LeftPaneInboxHelper({
|
||||
conversations: [
|
||||
fakeConversation(),
|
||||
fakeConversation(),
|
||||
fakeConversation(),
|
||||
getDefaultConversation(),
|
||||
getDefaultConversation(),
|
||||
getDefaultConversation(),
|
||||
],
|
||||
pinnedConversations: [fakeConversation(), fakeConversation()],
|
||||
archivedConversations: [fakeConversation()],
|
||||
pinnedConversations: [
|
||||
getDefaultConversation(),
|
||||
getDefaultConversation(),
|
||||
],
|
||||
archivedConversations: [getDefaultConversation()],
|
||||
});
|
||||
|
||||
assert.isFalse(
|
||||
helper.shouldRecomputeRowHeights({
|
||||
conversations: [fakeConversation()],
|
||||
pinnedConversations: [fakeConversation(), fakeConversation()],
|
||||
archivedConversations: [fakeConversation(), fakeConversation()],
|
||||
conversations: [getDefaultConversation()],
|
||||
pinnedConversations: [
|
||||
getDefaultConversation(),
|
||||
getDefaultConversation(),
|
||||
],
|
||||
archivedConversations: [
|
||||
getDefaultConversation(),
|
||||
getDefaultConversation(),
|
||||
],
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
it('returns true if the number of pinned conversations changes', () => {
|
||||
const helper = new LeftPaneInboxHelper({
|
||||
conversations: [fakeConversation()],
|
||||
pinnedConversations: [fakeConversation(), fakeConversation()],
|
||||
archivedConversations: [fakeConversation()],
|
||||
conversations: [getDefaultConversation()],
|
||||
pinnedConversations: [
|
||||
getDefaultConversation(),
|
||||
getDefaultConversation(),
|
||||
],
|
||||
archivedConversations: [getDefaultConversation()],
|
||||
});
|
||||
|
||||
assert.isTrue(
|
||||
helper.shouldRecomputeRowHeights({
|
||||
conversations: [fakeConversation()],
|
||||
conversations: [getDefaultConversation()],
|
||||
pinnedConversations: [
|
||||
fakeConversation(),
|
||||
fakeConversation(),
|
||||
fakeConversation(),
|
||||
getDefaultConversation(),
|
||||
getDefaultConversation(),
|
||||
getDefaultConversation(),
|
||||
],
|
||||
archivedConversations: [fakeConversation()],
|
||||
archivedConversations: [getDefaultConversation()],
|
||||
})
|
||||
);
|
||||
assert.isTrue(
|
||||
helper.shouldRecomputeRowHeights({
|
||||
conversations: [fakeConversation()],
|
||||
pinnedConversations: [fakeConversation()],
|
||||
archivedConversations: [fakeConversation()],
|
||||
conversations: [getDefaultConversation()],
|
||||
pinnedConversations: [getDefaultConversation()],
|
||||
archivedConversations: [getDefaultConversation()],
|
||||
})
|
||||
);
|
||||
assert.isTrue(
|
||||
helper.shouldRecomputeRowHeights({
|
||||
conversations: [fakeConversation()],
|
||||
conversations: [getDefaultConversation()],
|
||||
pinnedConversations: [],
|
||||
archivedConversations: [fakeConversation()],
|
||||
archivedConversations: [getDefaultConversation()],
|
||||
})
|
||||
);
|
||||
});
|
||||
|
|
|
@ -5,16 +5,11 @@ import { assert } from 'chai';
|
|||
import * as sinon from 'sinon';
|
||||
import { v4 as uuid } from 'uuid';
|
||||
import { RowType } from '../../../components/ConversationList';
|
||||
import { getDefaultConversation } from '../../../test-both/helpers/getDefaultConversation';
|
||||
|
||||
import { LeftPaneSearchHelper } from '../../../components/leftPane/LeftPaneSearchHelper';
|
||||
|
||||
describe('LeftPaneSearchHelper', () => {
|
||||
const fakeConversation = () => ({
|
||||
id: uuid(),
|
||||
title: uuid(),
|
||||
type: 'direct' as const,
|
||||
});
|
||||
|
||||
const fakeMessage = () => ({
|
||||
id: uuid(),
|
||||
conversationId: uuid(),
|
||||
|
@ -54,7 +49,7 @@ describe('LeftPaneSearchHelper', () => {
|
|||
new LeftPaneSearchHelper({
|
||||
conversationResults: {
|
||||
isLoading: false,
|
||||
results: [fakeConversation(), fakeConversation()],
|
||||
results: [getDefaultConversation(), getDefaultConversation()],
|
||||
},
|
||||
contactResults: { isLoading: true },
|
||||
messageResults: { isLoading: true },
|
||||
|
@ -88,7 +83,7 @@ describe('LeftPaneSearchHelper', () => {
|
|||
const helper = new LeftPaneSearchHelper({
|
||||
conversationResults: {
|
||||
isLoading: false,
|
||||
results: [fakeConversation(), fakeConversation()],
|
||||
results: [getDefaultConversation(), getDefaultConversation()],
|
||||
},
|
||||
contactResults: { isLoading: false, results: [] },
|
||||
messageResults: { isLoading: false, results: [fakeMessage()] },
|
||||
|
@ -111,7 +106,7 @@ describe('LeftPaneSearchHelper', () => {
|
|||
new LeftPaneSearchHelper({
|
||||
conversationResults: {
|
||||
isLoading: false,
|
||||
results: [fakeConversation(), fakeConversation()],
|
||||
results: [getDefaultConversation(), getDefaultConversation()],
|
||||
},
|
||||
contactResults: { isLoading: true },
|
||||
messageResults: { isLoading: true },
|
||||
|
@ -139,8 +134,11 @@ describe('LeftPaneSearchHelper', () => {
|
|||
});
|
||||
|
||||
it('returns header + results when all sections have loaded with results', () => {
|
||||
const conversations = [fakeConversation(), fakeConversation()];
|
||||
const contacts = [fakeConversation()];
|
||||
const conversations = [
|
||||
getDefaultConversation(),
|
||||
getDefaultConversation(),
|
||||
];
|
||||
const contacts = [getDefaultConversation()];
|
||||
const messages = [fakeMessage(), fakeMessage()];
|
||||
|
||||
const helper = new LeftPaneSearchHelper({
|
||||
|
@ -188,7 +186,7 @@ describe('LeftPaneSearchHelper', () => {
|
|||
});
|
||||
|
||||
it('omits conversations when there are no conversation results', () => {
|
||||
const contacts = [fakeConversation()];
|
||||
const contacts = [getDefaultConversation()];
|
||||
const messages = [fakeMessage(), fakeMessage()];
|
||||
|
||||
const helper = new LeftPaneSearchHelper({
|
||||
|
@ -224,7 +222,10 @@ describe('LeftPaneSearchHelper', () => {
|
|||
});
|
||||
|
||||
it('omits contacts when there are no contact results', () => {
|
||||
const conversations = [fakeConversation(), fakeConversation()];
|
||||
const conversations = [
|
||||
getDefaultConversation(),
|
||||
getDefaultConversation(),
|
||||
];
|
||||
const messages = [fakeMessage(), fakeMessage()];
|
||||
|
||||
const helper = new LeftPaneSearchHelper({
|
||||
|
@ -265,8 +266,8 @@ describe('LeftPaneSearchHelper', () => {
|
|||
});
|
||||
|
||||
it('omits messages when there are no message results', () => {
|
||||
const conversations = [fakeConversation(), fakeConversation()];
|
||||
const contacts = [fakeConversation()];
|
||||
const conversations = [getDefaultConversation(), getDefaultConversation()];
|
||||
const contacts = [getDefaultConversation()];
|
||||
|
||||
const helper = new LeftPaneSearchHelper({
|
||||
conversationResults: {
|
||||
|
@ -313,7 +314,7 @@ describe('LeftPaneSearchHelper', () => {
|
|||
new LeftPaneSearchHelper({
|
||||
conversationResults: {
|
||||
isLoading: false,
|
||||
results: [fakeConversation(), fakeConversation()],
|
||||
results: [getDefaultConversation(), getDefaultConversation()],
|
||||
},
|
||||
contactResults: { isLoading: true },
|
||||
messageResults: { isLoading: true },
|
||||
|
@ -336,7 +337,7 @@ describe('LeftPaneSearchHelper', () => {
|
|||
const helper = new LeftPaneSearchHelper({
|
||||
conversationResults: {
|
||||
isLoading: false,
|
||||
results: [fakeConversation(), fakeConversation()],
|
||||
results: [getDefaultConversation(), getDefaultConversation()],
|
||||
},
|
||||
contactResults: { isLoading: false, results: [] },
|
||||
messageResults: {
|
||||
|
@ -354,7 +355,7 @@ describe('LeftPaneSearchHelper', () => {
|
|||
const helper = new LeftPaneSearchHelper({
|
||||
conversationResults: {
|
||||
isLoading: false,
|
||||
results: [fakeConversation(), fakeConversation()],
|
||||
results: [getDefaultConversation(), getDefaultConversation()],
|
||||
},
|
||||
contactResults: { isLoading: false, results: [] },
|
||||
messageResults: {
|
||||
|
@ -368,7 +369,7 @@ describe('LeftPaneSearchHelper', () => {
|
|||
helper.shouldRecomputeRowHeights({
|
||||
conversationResults: {
|
||||
isLoading: false,
|
||||
results: [fakeConversation(), fakeConversation()],
|
||||
results: [getDefaultConversation(), getDefaultConversation()],
|
||||
},
|
||||
contactResults: { isLoading: false, results: [] },
|
||||
messageResults: {
|
||||
|
@ -392,7 +393,7 @@ describe('LeftPaneSearchHelper', () => {
|
|||
helper.shouldRecomputeRowHeights({
|
||||
conversationResults: {
|
||||
isLoading: false,
|
||||
results: [fakeConversation()],
|
||||
results: [getDefaultConversation()],
|
||||
},
|
||||
contactResults: { isLoading: true },
|
||||
messageResults: { isLoading: true },
|
||||
|
@ -413,7 +414,7 @@ describe('LeftPaneSearchHelper', () => {
|
|||
helper.shouldRecomputeRowHeights({
|
||||
conversationResults: {
|
||||
isLoading: false,
|
||||
results: [fakeConversation(), fakeConversation()],
|
||||
results: [getDefaultConversation(), getDefaultConversation()],
|
||||
},
|
||||
contactResults: { isLoading: false, results: [] },
|
||||
messageResults: { isLoading: false, results: [fakeMessage()] },
|
||||
|
@ -426,7 +427,7 @@ describe('LeftPaneSearchHelper', () => {
|
|||
const helper = new LeftPaneSearchHelper({
|
||||
conversationResults: {
|
||||
isLoading: false,
|
||||
results: [fakeConversation(), fakeConversation()],
|
||||
results: [getDefaultConversation(), getDefaultConversation()],
|
||||
},
|
||||
contactResults: { isLoading: false, results: [] },
|
||||
messageResults: { isLoading: false, results: [] },
|
||||
|
@ -437,7 +438,7 @@ describe('LeftPaneSearchHelper', () => {
|
|||
helper.shouldRecomputeRowHeights({
|
||||
conversationResults: {
|
||||
isLoading: false,
|
||||
results: [fakeConversation()],
|
||||
results: [getDefaultConversation()],
|
||||
},
|
||||
contactResults: { isLoading: true },
|
||||
messageResults: { isLoading: true },
|
||||
|
|
|
@ -3,18 +3,12 @@
|
|||
|
||||
import { assert } from 'chai';
|
||||
import * as sinon from 'sinon';
|
||||
import { v4 as uuid } from 'uuid';
|
||||
import { RowType } from '../../../components/ConversationList';
|
||||
import { getDefaultConversation } from '../../../test-both/helpers/getDefaultConversation';
|
||||
|
||||
import { LeftPaneSetGroupMetadataHelper } from '../../../components/leftPane/LeftPaneSetGroupMetadataHelper';
|
||||
|
||||
describe('LeftPaneSetGroupMetadataHelper', () => {
|
||||
const fakeContact = () => ({
|
||||
id: uuid(),
|
||||
title: uuid(),
|
||||
type: 'direct' as const,
|
||||
});
|
||||
|
||||
describe('getBackAction', () => {
|
||||
it('returns the "show composer" action if a request is not active', () => {
|
||||
const showChooseGroupMembers = sinon.fake();
|
||||
|
@ -68,7 +62,10 @@ describe('LeftPaneSetGroupMetadataHelper', () => {
|
|||
groupName: '',
|
||||
hasError: false,
|
||||
isCreating: false,
|
||||
selectedContacts: [fakeContact(), fakeContact()],
|
||||
selectedContacts: [
|
||||
getDefaultConversation(),
|
||||
getDefaultConversation(),
|
||||
],
|
||||
}).getRowCount(),
|
||||
4
|
||||
);
|
||||
|
@ -89,7 +86,10 @@ describe('LeftPaneSetGroupMetadataHelper', () => {
|
|||
});
|
||||
|
||||
it('returns a header, then the contacts, then a blank space if there are contacts', () => {
|
||||
const selectedContacts = [fakeContact(), fakeContact()];
|
||||
const selectedContacts = [
|
||||
getDefaultConversation(),
|
||||
getDefaultConversation(),
|
||||
];
|
||||
const helper = new LeftPaneSetGroupMetadataHelper({
|
||||
groupAvatar: undefined,
|
||||
groupName: '',
|
||||
|
|
|
@ -2,21 +2,17 @@
|
|||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
import { assert } from 'chai';
|
||||
import { v4 as uuid } from 'uuid';
|
||||
import {
|
||||
FindDirection,
|
||||
ToFindType,
|
||||
} from '../../../components/leftPane/LeftPaneHelper';
|
||||
import { getDefaultConversation } from '../../../test-both/helpers/getDefaultConversation';
|
||||
|
||||
import { getConversationInDirection } from '../../../components/leftPane/getConversationInDirection';
|
||||
|
||||
describe('getConversationInDirection', () => {
|
||||
const fakeConversation = (markedUnread = false) => ({
|
||||
id: uuid(),
|
||||
title: uuid(),
|
||||
type: 'direct' as const,
|
||||
markedUnread,
|
||||
});
|
||||
const fakeConversation = (markedUnread = false) =>
|
||||
getDefaultConversation({ markedUnread });
|
||||
|
||||
const fakeConversations = [
|
||||
fakeConversation(),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue