Skip to content

Commit 2f10682

Browse files
committed
test(test-app): assert findFirst returns single object with orderBy
1 parent 18e4e7b commit 2f10682

1 file changed

Lines changed: 18 additions & 1 deletion

File tree

graphql/test-app/tests/orm.live.test.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,24 @@ if (!liveEnv) {
175175
},
176176
})
177177
.unwrap();
178-
assert.ok(Array.isArray(firstResult.users.nodes), 'findFirst should return users.nodes array');
178+
assert.ok(
179+
firstResult.user === null || typeof firstResult.user === 'object',
180+
'findFirst should return a single user object (or null), not an array'
181+
);
182+
if (firstResult.user) {
183+
assert.equal(typeof firstResult.user.id, 'string', 'findFirst result should expose scalar id');
184+
}
185+
186+
const orderedResult = await client.user
187+
.findFirst({
188+
select: { id: true, username: true },
189+
orderBy: ['CREATED_AT_DESC'],
190+
})
191+
.unwrap();
192+
assert.ok(
193+
orderedResult.user === null || typeof orderedResult.user === 'object',
194+
'findFirst with orderBy should return a single user object (or null)'
195+
);
179196

180197
const currentUserResult = await client.query
181198
.currentUser({

0 commit comments

Comments
 (0)