Files
ShakaPlayer/test/util/lazy_unit.js
Álvaro Velad Galván 4f62ce8b24 build: Reduce bundle size by deduplicating license headers (#10182)
Ensure generated bundles contain a single license header instead of
repeating the same notice across bundled modules.

Normalize all copyright years to 2016 and remove
duplicate license headers from generated bundles.

This reduces the final bundle size while preserving license information
in the distributed artifacts.
2026-06-05 12:43:28 +02:00

34 lines
1.1 KiB
JavaScript

/*! @license
* Shaka Player
* Copyright 2016 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/
describe('Lazy', () => {
it('returns the same object each time', () => {
const generator = jasmine.createSpy('generator').and.returnValue({});
const lazy = new shaka.util.Lazy(shaka.test.Util.spyFunc(generator));
const value = lazy.value();
const value2 = lazy.value();
expect(value).toBe(value2);
expect(generator).toHaveBeenCalledTimes(1);
});
it('works correctly for primitive value', () => {
const generator = jasmine.createSpy('generator').and.returnValue(7);
const lazy = new shaka.util.Lazy(shaka.test.Util.spyFunc(generator));
const value = lazy.value();
const value2 = lazy.value();
expect(value).toBe(value2);
expect(generator).toHaveBeenCalledTimes(1);
});
it('works correctly for null', () => {
const generator = jasmine.createSpy('generator').and.returnValue(null);
const lazy = new shaka.util.Lazy(shaka.test.Util.spyFunc(generator));
const value = lazy.value();
expect(value).toBe(null);
expect(generator).toHaveBeenCalledTimes(1);
});
});