UNPKG

@webex/http-core

Version:

Core HTTP library for the Cisco Webex

84 lines (73 loc) 1.9 kB
/*! * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file. */ import {assert} from '@webex/test-helper-chai'; import {ProgressEvent} from '@webex/http-core'; describe('http-core', () => { describe('ProgressEvent', () => { let event; const loaded = 100; const total = 500; beforeEach(() => { event = new ProgressEvent(loaded, total); }); describe('#loaded', () => { it('exists', () => { assert.property(event, 'loaded'); }); it('matches the value passed to the constructor', () => { assert.equal(event.loaded, loaded); }); }); describe('#total', () => { it('exists', () => { assert.property(event, 'total'); }); it('matches the value passed to the constructor', () => { assert.equal(event.total, total); }); }); describe('#lengthComputable', () => { it('exists', () => { assert.property(event, 'lengthComputable'); }); it('indicates that request progress can be computed', () => { assert.isTrue(event.lengthComputable); [ { loaded: undefined, total: undefined, result: false, }, { loaded: 10, total: undefined, result: false, }, { loaded: undefined, total: 10, result: false, }, { loaded: 10, total: 10, result: true, }, { loaded: 10, total: 0, result: false, }, { loaded: 0, total: 0, result: false, }, ].forEach((item) => { assert.equal(new ProgressEvent(item.loaded, item.total).lengthComputable, item.result); }); }); }); }); });