1
0
Fork 0
mirror of https://github.com/codex-team/codex.docs.git synced 2025-07-29 01:59:40 +02:00

Fix sorting in dropdown (#187)

* fix: fix order of page categories with raw type

* refactor: change method location and others

* refactor: fix method names and variables also split methods to be clear their role

* fix: fix variable name

* fix: change the method to group of pages

* refactor: replace filter metethod to querying database

* refactor: fix typo, rename variable, add comments, improve code quality

* fix: add exit infinite loop

* fix: replace exiting loop to throwing exception
This commit is contained in:
YeoKyung Yoon 2022-06-22 07:09:08 -07:00 committed by GitHub
parent 30d96909d3
commit b3d8a1bfd4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 191 additions and 5 deletions

View file

@ -146,4 +146,31 @@ describe('PageOrder model', () => {
await pageOrder.destroy();
});
it('Testing get parents and children order methods', async () => {
const parentTestData = {
page: '0',
order: ['1', '2', '3', '4', '5'],
};
const childTestData = {
page: 'child',
order: ['a', 'b', 'c', 'd', 'e'],
};
const parentOrder = new PageOrder(parentTestData);
const childOrder = new PageOrder(childTestData);
const insertedParentOrder = await parentOrder.save();
const insertedChildOrder = await childOrder.save();
const fetchedParentOrder = await PageOrder.getRootPageOrder();
const fetchedChildOrder = await PageOrder.getChildPageOrder();
expect(fetchedParentOrder.page).to.deep.equals(parentTestData.page);
expect(fetchedParentOrder.order).to.deep.equal(parentTestData.order);
expect(fetchedChildOrder).to.be.an('array').that.is.length(1);
expect(fetchedChildOrder[0].page).to.deep.equals(childTestData.page);
expect(fetchedChildOrder[0].order).to.deep.equals(childTestData.order);
await insertedParentOrder.destroy();
await insertedChildOrder.destroy();
});
});