Skip to content

Commit 78bcfb1

Browse files
committed
test(orm): make the test "custom order by clause" not flaky
1 parent 18103ea commit 78bcfb1

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

test/orm/model_has_many.spec.ts

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
*/
99

1010
import { test } from '@japa/runner'
11+
import { DateTime } from 'luxon'
1112
import type { HasMany } from '../../src/types/relations.js'
1213

1314
import { scope } from '../../src/orm/base_model/index.js'
@@ -3716,6 +3717,8 @@ if (process.env.DB !== 'mysql_legacy') {
37163717

37173718
const [user0, user1] = await db.query().from('users')
37183719

3720+
const now = DateTime.now()
3721+
37193722
/**
37203723
* User 1
37213724
*/
@@ -3726,27 +3729,27 @@ if (process.env.DB !== 'mysql_legacy') {
37263729
{
37273730
user_id: user0.id,
37283731
title: 'Adonis 101',
3729-
created_at: new Date(),
3732+
created_at: now,
37303733
},
37313734
{
37323735
user_id: user0.id,
37333736
title: 'Adonis 102',
3734-
created_at: new Date(),
3737+
created_at: now.plus({ seconds: 1 }),
37353738
},
37363739
{
37373740
user_id: user0.id,
37383741
title: 'Adonis 103',
3739-
created_at: new Date(),
3742+
created_at: now.plus({ seconds: 2 }),
37403743
},
37413744
{
37423745
user_id: user0.id,
37433746
title: 'Adonis 104',
3744-
created_at: new Date(),
3747+
created_at: now.plus({ seconds: 3 }),
37453748
},
37463749
{
37473750
user_id: user0.id,
37483751
title: 'Adonis 105',
3749-
created_at: new Date(),
3752+
created_at: now.plus({ seconds: 4 }),
37503753
},
37513754
])
37523755

@@ -3760,27 +3763,27 @@ if (process.env.DB !== 'mysql_legacy') {
37603763
{
37613764
user_id: user1.id,
37623765
title: 'Lucid 101',
3763-
created_at: new Date(),
3766+
created_at: now,
37643767
},
37653768
{
37663769
user_id: user1.id,
37673770
title: 'Lucid 102',
3768-
created_at: new Date(),
3771+
created_at: now.plus({ seconds: 1 }),
37693772
},
37703773
{
37713774
user_id: user1.id,
37723775
title: 'Lucid 103',
3773-
created_at: new Date(),
3776+
created_at: now.plus({ seconds: 2 }),
37743777
},
37753778
{
37763779
user_id: user1.id,
37773780
title: 'Lucid 104',
3778-
created_at: new Date(),
3781+
created_at: now.plus({ seconds: 3 }),
37793782
},
37803783
{
37813784
user_id: user1.id,
37823785
title: 'Lucid 105',
3783-
created_at: new Date(),
3786+
created_at: now.plus({ seconds: 4 }),
37843787
},
37853788
])
37863789

0 commit comments

Comments
 (0)