Skip to content

Commit

Permalink
Added power boosting balance tests to take snapshot
Browse files Browse the repository at this point in the history
  • Loading branch information
aminlatifi committed Jul 31, 2023
1 parent c25218b commit 3558e0e
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/repositories/powerBoostingRepository.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { PowerSnapshot } from '../entities/powerSnapshot';
import { PowerBoostingSnapshot } from '../entities/powerBoostingSnapshot';
import { errorMessages } from '../utils/errorMessages';
import { AppDataSource } from '../orm';
import { PowerBalanceSnapshot } from '../entities/powerBalanceSnapshot';

describe('findUserPowerBoosting() testCases', findUserPowerBoostingTestCases);
describe('findPowerBoostings() testCases', findPowerBoostingsTestCases);
Expand Down Expand Up @@ -848,6 +849,11 @@ function powerBoostingSnapshotTests() {
take: 4,
});

const [powerBalanceSnapshots, powerBalanceSnapshotsCounts] =
await PowerBalanceSnapshot.findAndCount({
where: { powerSnapshotId: snapshot?.id },
});

assert.equal(powerBoostingCounts, powerBoostingSnapshotsCounts);
powerBoostings.forEach(pb => {
const pbs = powerBoostingSnapshots.find(
Expand All @@ -859,6 +865,18 @@ function powerBoostingSnapshotTests() {
);
assert.isDefined(pbs);
});

assert.equal(powerBalanceSnapshotsCounts, 2);
assert.isDefined(
powerBalanceSnapshots.find(
p => p.userId === user1.id && p.powerSnapshotId === snapshot?.id,
),
);
assert.isDefined(
powerBalanceSnapshots.find(
p => p.userId === user2.id && p.powerSnapshotId === snapshot?.id,
),
);
});

it('should return snapshot corresponding round correctly', async () => {
Expand Down

0 comments on commit 3558e0e

Please sign in to comment.