()
| 117 | afterAll(() => orm.close(true)); |
| 118 | |
| 119 | async function createTestData() { |
| 120 | const em = orm.em.fork(); |
| 121 | |
| 122 | const author1 = em.create(Author, { name: 'Charlie' }); |
| 123 | const author2 = em.create(Author, { name: 'Alice' }); |
| 124 | em.create(Author, { name: 'Bob' }); |
| 125 | |
| 126 | em.create(Profile, { bio: 'Charlie bio', author: author1 }); |
| 127 | em.create(Profile, { bio: 'Alice bio', author: author2 }); |
| 128 | |
| 129 | const post1 = em.create(Post, { title: 'Post 1', createdAt: new Date('2024-01-15'), author: author1 }); |
| 130 | const post2 = em.create(Post, { title: 'Post 2', createdAt: new Date('2024-01-20'), author: author1 }); |
| 131 | em.create(Post, { title: 'Post 3', createdAt: new Date('2024-01-10'), author: author1 }); |
| 132 | |
| 133 | const c1 = em.create(Comment, { text: 'First comment', createdAt: new Date('2024-01-01'), post: post1 }); |
| 134 | em.create(Comment, { text: 'Second comment', createdAt: new Date('2024-01-03'), post: post1 }); |
| 135 | em.create(Comment, { text: 'Third comment', createdAt: new Date('2024-01-02'), post: post1 }); |
| 136 | |
| 137 | em.create(Reply, { text: 'Reply A', createdAt: new Date('2024-01-01T12:00:00'), comment: c1 }); |
| 138 | em.create(Reply, { text: 'Reply B', createdAt: new Date('2024-01-01T10:00:00'), comment: c1 }); |
| 139 | em.create(Reply, { text: 'Reply C', createdAt: new Date('2024-01-01T11:00:00'), comment: c1 }); |
| 140 | |
| 141 | const tag1 = em.create(Tag, { title: 'Zebra' }); |
| 142 | const tag2 = em.create(Tag, { title: 'Apple' }); |
| 143 | const tag3 = em.create(Tag, { title: 'Banana' }); |
| 144 | |
| 145 | post1.tags.add(tag1, tag2, tag3); |
| 146 | post1.tagsReversed.add(tag1, tag2, tag3); |
| 147 | post2.tags.add(tag2, tag3); |
| 148 | |
| 149 | em.create(Item, { name: 'Item A', priority: 1 }); |
| 150 | em.create(Item, { name: 'Item B', priority: 3 }); |
| 151 | em.create(Item, { name: 'Item C', priority: 2 }); |
| 152 | em.create(Item, { name: 'Item D', priority: 3 }); |
| 153 | |
| 154 | em.create(Event, { title: 'Event A', createdAt: new Date('2024-03-01') }); |
| 155 | em.create(Event, { title: 'Event B', createdAt: new Date('2024-01-01') }); |
| 156 | em.create(Event, { title: 'Event C', createdAt: new Date('2024-02-01') }); |
| 157 | |
| 158 | await em.flush(); |
| 159 | } |
| 160 | |
| 161 | describe('entity-level default orderBy', () => { |
| 162 | describe('em.find() with entity-level orderBy', () => { |
no test coverage detected