1 import { MAX_DOC_SIZE, MAX_UPDATE_SIZE } from '../Models/Constants'
2 import { DocSizeTracker } from './SizeTracker'
4 describe('SizeTracker', () => {
5 it('should be able to post small update', () => {
6 const tracker = new DocSizeTracker()
8 expect(tracker.canPostUpdateOfSize(100)).toBe(true)
11 it('should not be able to post update larger than limit', () => {
12 const tracker = new DocSizeTracker()
14 expect(tracker.canPostUpdateOfSize(MAX_UPDATE_SIZE + 1)).toBe(false)
17 it('should not be able to post small update if would exceed threshold', () => {
18 const tracker = new DocSizeTracker()
20 tracker.incrementSize(MAX_DOC_SIZE - 1)
22 expect(tracker.canPostUpdateOfSize(2)).toBe(false)