Skip to content

Commit

Permalink
add unit test for MaxTargetVolumeLimit
Browse files Browse the repository at this point in the history
  • Loading branch information
bitrinjani committed Dec 29, 2017
1 parent 849d720 commit 278af3c
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions src/__tests__/LimitCheckerImpl.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import LimitCheckerImpl from '../LimitCheckerImpl';
import { options } from '../logger';
options.enabled = false;

describe('LimitCheckerImpl', () => {
test('MaxTargetVolumeLimit - violate', () => {
const config = { maxTargetVolumePercent: 50 };
const ps = {};
const analysisResult = { availableVolume: 1.0, targetVolume: 0.7 };
const checker = new LimitCheckerImpl({ config }, ps, analysisResult, analysisResult, false);
checker.limits = checker.limits.filter(limit => limit.constructor.name === 'MaxTargetVolumeLimit');
const result = checker.check();
expect(result.success).toBe(false);
expect(result.reason).toBe('Too large Volume');
});

test('MaxTargetVolumeLimit - pass', () => {
const config = { maxTargetVolumePercent: 50 };
const ps = {};
const analysisResult = { availableVolume: 1.0, targetVolume: 0.3 };
const checker = new LimitCheckerImpl({ config }, ps, analysisResult, analysisResult, false);
checker.limits = checker.limits.filter(limit => limit.constructor.name === 'MaxTargetVolumeLimit');
const result = checker.check();
expect(result.success).toBe(true);
expect(result.reason).toBe('');
});

test('MaxTargetVolumeLimit - undefined', () => {
const config = { maxTargetVolumePercent: undefined };
const ps = {};
const analysisResult = { availableVolume: 1.0, targetVolume: 0.3 };
const checker = new LimitCheckerImpl({ config }, ps, analysisResult, analysisResult, false);
checker.limits = checker.limits.filter(limit => limit.constructor.name === 'MaxTargetVolumeLimit');
const result = checker.check();
expect(result.success).toBe(true);
expect(result.reason).toBe('');
});
});

0 comments on commit 278af3c

Please sign in to comment.