mirror of
https://github.com/shaka-project/shaka-player.git
synced 2026-06-20 16:57:25 +03:00
7e6a0f38ff
This corrects/normalizes license headers in misc. files, such as config files, docs, build tools, tests, and externs. This does not affect the compiled output, and is only done for consistency. Issue #2638 Change-Id: I9d8da2de55243b08d7df2b743aac73c6f15e858a
75 lines
2.2 KiB
JavaScript
75 lines
2.2 KiB
JavaScript
/*! @license
|
|
* Shaka Player
|
|
* Copyright 2016 Google LLC
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
|
|
describe('Enforcer', () => {
|
|
const Enforcer = shaka.deprecate.Enforcer;
|
|
const Version = shaka.deprecate.Version;
|
|
|
|
/** @type {!jasmine.Spy} */
|
|
let onPendingSpy;
|
|
|
|
/** @type {!jasmine.Spy} */
|
|
let onExpiredSpy;
|
|
|
|
beforeEach(() => {
|
|
onPendingSpy = jasmine.createSpy('onPending');
|
|
onExpiredSpy = jasmine.createSpy('onExpired');
|
|
});
|
|
|
|
it('calls onExpired when feature has expired', () => {
|
|
// The library is currently at version 2.4 and the feature should have been
|
|
// removed in 2.1.
|
|
const currentVersion = new Version(2, 4);
|
|
const expiresAt = new Version(2, 1);
|
|
|
|
const enforcer = createEnforcerFor(currentVersion);
|
|
|
|
enforcer.enforce(expiresAt, 'my-feature-name', 'my-feature-description');
|
|
|
|
// Make sure that only the expired response was invoked.
|
|
expect(onExpiredSpy).toHaveBeenCalled();
|
|
expect(onPendingSpy).not.toHaveBeenCalled();
|
|
});
|
|
|
|
it('calls onPending when feature has not expired', () => {
|
|
// The library is currently at version 2.1 and the feature goes away in 2.4.
|
|
const currentVersion = new Version(2, 1);
|
|
const expiresAt = new Version(2, 4);
|
|
|
|
const enforcer = createEnforcerFor(currentVersion);
|
|
|
|
enforcer.enforce(expiresAt, 'my-feature-name', 'my-feature-description');
|
|
|
|
// Make sure that only the expired response was invoked.
|
|
expect(onExpiredSpy).not.toHaveBeenCalled();
|
|
expect(onPendingSpy).toHaveBeenCalled();
|
|
});
|
|
|
|
it('treats same version as expired', () => {
|
|
// The library is at version 2.4 and the feature expires at 2.4.
|
|
const currentVersion = new Version(2, 4);
|
|
const expiresAt = new Version(2, 4);
|
|
|
|
const enforcer = createEnforcerFor(currentVersion);
|
|
|
|
enforcer.enforce(expiresAt, 'my-feature-name', 'my-feature-description');
|
|
|
|
// We should see an error when we are on the expired feature.
|
|
expect(onExpiredSpy).toHaveBeenCalled();
|
|
});
|
|
|
|
/**
|
|
* @param {!shaka.deprecate.Version} currentVersion
|
|
* @return {!shaka.deprecate.Enforcer}
|
|
*/
|
|
function createEnforcerFor(currentVersion) {
|
|
const Util = shaka.test.Util;
|
|
|
|
return new Enforcer(
|
|
currentVersion, Util.spyFunc(onPendingSpy), Util.spyFunc(onExpiredSpy));
|
|
}
|
|
});
|