From 82b815d827e013be954ddc1156124403cdcc9412 Mon Sep 17 00:00:00 2001 From: OKNoah Date: Thu, 10 Aug 2017 19:03:50 -0700 Subject: [PATCH] Adds proper test for sorting --- index.test.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/index.test.js b/index.test.js index 5ac62c6..ace23f9 100644 --- a/index.test.js +++ b/index.test.js @@ -1,5 +1,6 @@ import dotenv from 'dotenv' import { randomBytes } from 'crypto' +import { sortBy, isEqual } from 'lodash' import ormjs from './index' import moment from 'moment' @@ -86,7 +87,9 @@ test('make sure all documents have createdAt field', async () => { test('make sure all documents have updatedAt field', async () => { const post = await Post.findOne({ - body: username + where: { + body: username + } }) post.body = 'Updated!' @@ -103,3 +106,14 @@ test('use aql query', async () => { const users = await cursor.all() expect(users.length).toBe(10) }) + +test('check list is sorted', async () => { + const posts = await Post.find({ + sort: 'post.createdAt asc', + limit: 100 + }) + + const sorted = await sortBy(posts, ['createdAt']) + + expect(isEqual(posts, sorted)).toBe(true) +})