Sort groups you've left to the bottom of search

This commit is contained in:
Scott Nonnenberg 2022-05-31 09:28:31 -07:00 committed by GitHub
parent fcd0a186e0
commit 49bb1321e3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 18 additions and 128 deletions

View file

@ -4,90 +4,7 @@
import { assert } from 'chai';
import { getDefaultConversation } from '../helpers/getDefaultConversation';
import {
filterAndSortConversationsByTitle,
filterAndSortConversationsByRecent,
} from '../../util/filterAndSortConversations';
describe('filterAndSortConversationsByTitle', () => {
const conversations = [
getDefaultConversation({
title: '+16505551234',
e164: '+16505551234',
name: undefined,
profileName: undefined,
}),
getDefaultConversation({
name: 'Carlos Santana',
title: 'Carlos Santana',
e164: '+16505559876',
username: 'thisismyusername',
}),
getDefaultConversation({
name: 'Aaron Aardvark',
title: 'Aaron Aardvark',
}),
getDefaultConversation({
name: 'Belinda Beetle',
title: 'Belinda Beetle',
}),
getDefaultConversation({
name: 'Belinda Zephyr',
title: 'Belinda Zephyr',
}),
];
it('without a search term, sorts conversations by title (but puts no-name contacts at the bottom)', () => {
const titles = filterAndSortConversationsByTitle(
conversations,
'',
'US'
).map(contact => contact.title);
assert.deepEqual(titles, [
'Aaron Aardvark',
'Belinda Beetle',
'Belinda Zephyr',
'Carlos Santana',
'+16505551234',
]);
});
it('can search for contacts by title', () => {
const titles = filterAndSortConversationsByTitle(
conversations,
'belind',
'US'
).map(contact => contact.title);
assert.sameMembers(titles, ['Belinda Beetle', 'Belinda Zephyr']);
});
it('can search for contacts by phone number (and puts no-name contacts at the bottom)', () => {
const titles = filterAndSortConversationsByTitle(
conversations,
'650555',
'US'
).map(contact => contact.title);
assert.sameMembers(titles, ['Carlos Santana', '+16505551234']);
});
it('can search for contacts by formatted phone number (and puts no-name contacts at the bottom)', () => {
const titles = filterAndSortConversationsByTitle(
conversations,
'(650)555 12-34',
'US'
).map(contact => contact.title);
assert.sameMembers(titles, ['+16505551234']);
});
it('can search for contacts by username', () => {
const titles = filterAndSortConversationsByTitle(
conversations,
'thisis',
'US'
).map(contact => contact.title);
assert.sameMembers(titles, ['Carlos Santana']);
});
});
import { filterAndSortConversationsByRecent } from '../../util/filterAndSortConversations';
describe('filterAndSortConversationsByRecent', () => {
const conversations = [