Skip to content

Commit

Permalink
Fix LeaderboardRecordList model mapper
Browse files Browse the repository at this point in the history
  • Loading branch information
aminalaee committed Dec 14, 2023
1 parent 6e70de1 commit 39b67df
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
3 changes: 1 addition & 2 deletions lib/src/models/leaderboard.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ class LeaderboardRecordList with _$LeaderboardRecordList {

factory LeaderboardRecordList.fromDto(api.LeaderboardRecordList dto) =>
LeaderboardRecordList(
records:
dto.ownerRecords.map((e) => LeaderboardRecord.fromDto(e)).toList(),
records: dto.records.map((e) => LeaderboardRecord.fromDto(e)).toList(),
ownerRecords:
dto.ownerRecords.map((e) => LeaderboardRecord.fromDto(e)).toList(),
nextCursor: dto.nextCursor,
Expand Down
20 changes: 20 additions & 0 deletions test/grpc/leaderboard_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,17 @@ void main() {
});

test('list leaderboard records', () async {
await client.writeLeaderboardRecord(
session: session, leaderboardName: 'test', score: 10);

final result = await client.listLeaderboardRecords(
session: session,
leaderboardName: 'test',
);

expect(result, isA<LeaderboardRecordList>());
expect(result.records.first.score, isNotNull);
expect(result.records.first.score!.toInt(), equals(10));
});

test('write leaderboard record', () async {
Expand All @@ -37,5 +42,20 @@ void main() {
expect(result.score, isNotNull);
expect(result.score!.toInt(), equals(10));
});

test('list leaderboard records around user', () async {
await client.writeLeaderboardRecord(
session: session, leaderboardName: 'test', score: 10);

final result = await client.listLeaderboardRecordsAroundOwner(
session: session,
leaderboardName: 'test',
ownerId: session.userId,
);

expect(result, isA<LeaderboardRecordList>());
expect(result.records.first.score, isNotNull);
expect(result.records.first.score!.toInt(), equals(10));
});
});
}

0 comments on commit 39b67df

Please sign in to comment.