2024-10-20 12:26:36 -05:00
|
|
|
import { describe, expect, test } from 'vitest';
|
|
|
|
|
2023-02-12 14:26:18 -05:00
|
|
|
import { sortByName } from '../src/web-utils';
|
2021-02-03 11:33:04 -05:00
|
|
|
|
|
|
|
describe('Utilities', () => {
|
|
|
|
describe('Sort packages', () => {
|
|
|
|
const packages = [
|
|
|
|
{
|
|
|
|
name: 'ghc',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'abc',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'zxy',
|
|
|
|
},
|
|
|
|
];
|
|
|
|
test('should order ascending', () => {
|
|
|
|
expect(sortByName(packages)).toEqual([
|
|
|
|
{
|
|
|
|
name: 'abc',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'ghc',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'zxy',
|
|
|
|
},
|
|
|
|
]);
|
|
|
|
});
|
|
|
|
|
|
|
|
test('should order descending', () => {
|
|
|
|
expect(sortByName(packages, false)).toEqual([
|
|
|
|
{
|
|
|
|
name: 'zxy',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'ghc',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'abc',
|
|
|
|
},
|
|
|
|
]);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|