Page MenuHomeSealhub

item-list.test.ts
No OneTemporary

item-list.test.ts

import { strictEqual } from "assert";
import { App, Collection, FieldTypes } from "../main";
import { withRunningApp } from "../test_utils/with-test-app";
describe("ItemList", () => {
it("allows to sort by modified_date", () =>
withRunningApp(
(test_app) =>
class extends test_app {
collections = {
...App.BaseCollections,
entries: new (class extends Collection {
fields = {
name: new FieldTypes.Text(),
};
})(),
};
},
async ({ app }) => {
await app.collections.entries.suCreate({ name: "older" });
await app.collections.entries.suCreate({ name: "newer" });
const {
items: desc,
} = await app.collections.entries
.suList()
.sort({ "_metadata.modified_at": "desc" })
.fetch();
strictEqual(desc[0].get("name"), "newer");
strictEqual(desc[1].get("name"), "older");
const {
items: asc,
} = await app.collections.entries
.suList()
.sort({ "_metadata.modified_at": "asc" })
.fetch();
strictEqual(asc[0].get("name"), "older");
strictEqual(asc[1].get("name"), "newer");
}
));
});

File Metadata

Mime Type
text/x-java
Expires
Fri, Nov 28, 15:37 (29 m, 35 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1057330
Default Alt Text
item-list.test.ts (1 KB)

Event Timeline