Sort groups you've left to the bottom of search
This commit is contained in:
parent
fcd0a186e0
commit
49bb1321e3
5 changed files with 18 additions and 128 deletions
|
@ -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 = [
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue