mirror of
https://github.com/videojs/video.js.git
synced 2024-12-12 11:15:04 +02:00
0da93249d3
* Make an object util function `keys` return an empty array for non objects * Use that function in object utils instead of `Object.assign`
37 lines
807 B
JavaScript
37 lines
807 B
JavaScript
/* eslint-env qunit */
|
|
import mergeOptions from '../../../src/js/utils/merge-options.js';
|
|
|
|
QUnit.module('merge-options');
|
|
|
|
QUnit.test('should merge options objects', function(assert) {
|
|
const ob1 = {
|
|
a: true,
|
|
b: { b1: true, b2: true, b3: true },
|
|
c: true
|
|
};
|
|
|
|
const ob2 = {
|
|
// override value
|
|
a: false,
|
|
// merge sub-option values
|
|
b: { b1: true, b2: false, b4: true },
|
|
// add new option
|
|
d: true
|
|
};
|
|
|
|
const ob3 = mergeOptions(ob1, ob2);
|
|
|
|
assert.deepEqual(ob3, {
|
|
a: false,
|
|
b: { b1: true, b2: false, b3: true, b4: true },
|
|
c: true,
|
|
d: true
|
|
}, 'options objects merged correctly');
|
|
});
|
|
|
|
QUnit.test('should ignore non-objects', function(assert) {
|
|
const obj = { a: 1 };
|
|
|
|
assert.deepEqual(mergeOptions(obj, true), obj, 'ignored non-object input');
|
|
});
|