import {getSortedIds} from '../../../../../app/core/datastore/cached/get-sorted-ids';

/**
 * @author Daniel de Oliveira
 */
describe('getSortedIds', () => {

    it('base', () => {

        const as = [{ id: 'a', identifier: '1.a' }, { id: 'b', identifier: '1' }];

        const result = getSortedIds(as as any, { q: '1',
            sort: 'default' // <- TODO why would we need exactMatchFirst? alnumCompare seems to do the trick here, right?
        });
        expect(result).toEqual(['b', 'a'])
    });
});

import {getSortedIds} from '../../../../../app/core/datastore/cached/get-sorted-ids';

/**
 * @author Daniel de Oliveira
 */
describe('getSortedIds', () => {

    it('exactMatchFirst', () => {

        const as = [
            { id: 'a', identifier: 'AB-C1' },
            { id: 'b', identifier: 'AB-C2' },
            { id: 'c', identifier: 'C2' }
            ];

        const result1 = getSortedIds(as as any, { q: 'C2',
            sort: 'default'
        });
        expect(result1).toEqual(['a', 'b', 'c']);

        const result2 = getSortedIds(as as any, { q: 'C2',
            sort: 'exactMatchFirst'
        });
        expect(result2).toEqual(['c', 'a', 'b']);
    });
});

Adjust test for intended use case
Adjust test for intended use case
