From 5b7643a9949eddb662992f23b4aefec28ef2f271 Mon Sep 17 00:00:00 2001 From: Tim Glasgow Date: Thu, 11 Aug 2022 18:36:09 -0500 Subject: [PATCH] score cache tests --- squarenotsquare/__tests__/Repo-test.js | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/squarenotsquare/__tests__/Repo-test.js b/squarenotsquare/__tests__/Repo-test.js index 32e8eb6..f33f8aa 100644 --- a/squarenotsquare/__tests__/Repo-test.js +++ b/squarenotsquare/__tests__/Repo-test.js @@ -129,4 +129,30 @@ test('Max out score repo cache', () => { } expect(testRepo.scoreCache.length).toEqual(100); +}) + +test('Build score cache', () => { + let mockRealm = new MockRealm({schemaVersion: 0}); + let testRepo = new ScoreRepo(mockRealm); + + for (let i = 0; i < 100; ++i) { + testRepo.createScore({value: i, username: 'user'}) + } + + let queried = testRepo.getHighScores(); + + expect(queried.length).toEqual(100); +}) + +test('Build max score cache', () => { + let mockRealm = new MockRealm({schemaVersion: 0}); + let testRepo = new ScoreRepo(mockRealm); + + for (let i = 0; i < 200; ++i) { + testRepo.createScore({value: i, username: 'user'}) + } + + let queried = testRepo.getHighScores(); + + expect(queried.length).toEqual(100); }) \ No newline at end of file