AI Changes: updated look, recently added, search bar, easy admin checkout
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
|
||||
import { sortDrinksFromSearch } from './drinks.sort.server';
|
||||
|
||||
test('sorts drinks by newest activity when using the new sort option', () => {
|
||||
const params = new URLSearchParams('sort=new');
|
||||
|
||||
const olderDrink = {
|
||||
id: 1,
|
||||
name: 'Zeta',
|
||||
type: 'Beer',
|
||||
abv: 5,
|
||||
description: '',
|
||||
slug: 'zeta',
|
||||
manufacturer_id: 1,
|
||||
image: null,
|
||||
link: null,
|
||||
gluten: false,
|
||||
lactose: false,
|
||||
organic: false,
|
||||
sugar: true,
|
||||
addedAt: new Date('2024-01-01T00:00:00.000Z'),
|
||||
containers: [],
|
||||
};
|
||||
|
||||
const newerDrink = {
|
||||
id: 2,
|
||||
name: 'Alpha',
|
||||
type: 'Beer',
|
||||
abv: 4.5,
|
||||
description: '',
|
||||
slug: 'alpha',
|
||||
manufacturer_id: 1,
|
||||
image: null,
|
||||
link: null,
|
||||
gluten: false,
|
||||
lactose: false,
|
||||
organic: false,
|
||||
sugar: true,
|
||||
addedAt: new Date('2024-02-01T00:00:00.000Z'),
|
||||
containers: [
|
||||
{
|
||||
inventory: 3,
|
||||
lastAdded: new Date('2024-03-01T00:00:00.000Z'),
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
const sorted = sortDrinksFromSearch(params, [olderDrink, newerDrink] as any);
|
||||
|
||||
assert.equal(sorted[0].id, 2);
|
||||
assert.equal(sorted[1].id, 1);
|
||||
});
|
||||
Reference in New Issue
Block a user