Skip to content

Commit c92bf2f

Browse files
authored
fix(test): unstable result in oauth test cases (#702)
1 parent 8c93a60 commit c92bf2f

File tree

1 file changed

+25
-16
lines changed

1 file changed

+25
-16
lines changed

src/v2/services/developer/oauth/__tests__/oauth.test.ts

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { oauthInfosDAO } from "../../../../dao";
99
import { testService } from "../../../../__tests__/helpers/db";
1010
import { Schema } from "../../../../__tests__/helpers/schema";
1111
import { developerOAuthInfoReturnSchema } from "../oauth.schema";
12+
import { DeveloperOAuthListByUserReturn } from "../oauth.type";
1213

1314
const namespace = "v2.services.developer.oauth";
1415
initializeDataSource(test, namespace);
@@ -164,22 +165,30 @@ test(`${namespace} - listByUser`, async ava => {
164165
size: 2,
165166
});
166167

167-
ava.deepEqual(result, [
168-
{
169-
ownerName: user3.userName,
170-
oauthUUID: oauthInfo3.oauthUUID,
171-
appName: oauthInfo3.appName,
172-
homepageURL: oauthInfo3.homepageURL,
173-
logoURL: oauthInfo3.logoURL,
174-
},
175-
{
176-
ownerName: user2.userName,
177-
oauthUUID: oauthInfo2.oauthUUID,
178-
appName: oauthInfo2.appName,
179-
homepageURL: oauthInfo2.homepageURL,
180-
logoURL: oauthInfo2.logoURL,
181-
},
182-
]);
168+
ava.deepEqual(
169+
result.sort(sortByOauthUUID),
170+
[
171+
{
172+
ownerName: user3.userName,
173+
oauthUUID: oauthInfo3.oauthUUID,
174+
appName: oauthInfo3.appName,
175+
homepageURL: oauthInfo3.homepageURL,
176+
logoURL: oauthInfo3.logoURL,
177+
},
178+
{
179+
ownerName: user2.userName,
180+
oauthUUID: oauthInfo2.oauthUUID,
181+
appName: oauthInfo2.appName,
182+
homepageURL: oauthInfo2.homepageURL,
183+
logoURL: oauthInfo2.logoURL,
184+
},
185+
].sort(sortByOauthUUID),
186+
);
187+
188+
type Item = DeveloperOAuthListByUserReturn[number];
189+
function sortByOauthUUID(a: Item, b: Item) {
190+
return a.oauthUUID.localeCompare(b.oauthUUID);
191+
}
183192

184193
await releaseRunner();
185194
});

0 commit comments

Comments
 (0)