diff --git a/lib/node_modules/@stdlib/plot/vega/title/ctor/lib/main.js b/lib/node_modules/@stdlib/plot/vega/title/ctor/lib/main.js index 9a9fdfe5c464..17a4bb3d7c37 100644 --- a/lib/node_modules/@stdlib/plot/vega/title/ctor/lib/main.js +++ b/lib/node_modules/@stdlib/plot/vega/title/ctor/lib/main.js @@ -396,7 +396,7 @@ setReadWriteAccessor( Title.prototype, 'font', getFont, setFont ); * * @name fontSize * @memberof Title.prototype -* @type {(string|void)} +* @type {(number|void)} * * @example * var title = new Title({ diff --git a/lib/node_modules/@stdlib/plot/vega/title/ctor/test/test.align.js b/lib/node_modules/@stdlib/plot/vega/title/ctor/test/test.align.js new file mode 100644 index 000000000000..095b147f4578 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/title/ctor/test/test.align.js @@ -0,0 +1,167 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isUndefined = require( '@stdlib/assert/is-undefined' ); +var hasProp = require( '@stdlib/assert/has-property' ); +var isString = require( '@stdlib/assert/is-string' ); +var Title = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Title, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `align` property', function test( t ) { + var v; + + v = new Title(); + t.strictEqual( hasOwnProp( v, 'align' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'align' ), true, 'returns expected value' ); + t.strictEqual( isUndefined( v.align ), true, 'returns expected value' ); + + v = new Title({ + 'align': 'left' + }); + t.strictEqual( isString( v.align ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor throws an error if provided an invalid `align` option', function test( t ) { + var values; + var i; + + values = [ + 5, + NaN, + null, + true, + false, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + var title = new Title({ // eslint-disable-line no-unused-vars + 'align': value + }); + }; + } +}); + +tape( 'the constructor returns an instance having a `align` property which throws an error if set to an invalid value', function test( t ) { + var values; + var i; + + values = [ + 5, + NaN, + null, + true, + false, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + var title = new Title(); + title.align = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `align` property', function test( t ) { + var title; + + title = new Title(); + t.strictEqual( isUndefined( title.align ), true, 'returns expected value' ); + + title = new Title({ + 'align': 'left' + }); + t.strictEqual( title.align, 'left', 'returns expected value' ); + + title = new Title({ + 'align': 'top' + }); + t.strictEqual( title.align, 'top', 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `align` property which can be set to a valid method', function test( t ) { + var title; + + title = new Title(); + + title.align = 'left'; + t.strictEqual( title.align, 'left', 'returns expected value' ); + + title.align = 'top'; + t.strictEqual( title.align, 'top', 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `align` property is set to a new value', function test( t ) { + var title; + var count; + + title = new Title(); + count = 0; + + title.on( 'change', onChange ); + + title.align = 'left'; + t.strictEqual( count, 1, 'returns expected value' ); + + title.align = 'top'; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + title.align = 'top'; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/title/ctor/test/test.anchor.js b/lib/node_modules/@stdlib/plot/vega/title/ctor/test/test.anchor.js new file mode 100644 index 000000000000..01ee3dfd905e --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/title/ctor/test/test.anchor.js @@ -0,0 +1,167 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var hasProp = require( '@stdlib/assert/has-property' ); +var isString = require( '@stdlib/assert/is-string' ); +var Title = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Title, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `anchor` property', function test( t ) { + var v; + + v = new Title(); + t.strictEqual( hasOwnProp( v, 'anchor' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'anchor' ), true, 'returns expected value' ); + t.strictEqual( isString( v.anchor ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor throws an error if provided an invalid `anchor` option', function test( t ) { + var values; + var i; + + values = [ + 'beep', + 'boop', + 'START', + 5, + NaN, + null, + true, + false, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + var title = new Title({ // eslint-disable-line no-unused-vars + 'anchor': value + }); + }; + } +}); + +tape( 'the constructor returns an instance having a `anchor` property which throws an error if set to an invalid value', function test( t ) { + var values; + var i; + + values = [ + 'beep', + 'boop', + 'START', + 5, + NaN, + null, + true, + false, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + var title = new Title(); + title.anchor = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `anchor` property', function test( t ) { + var title; + + title = new Title(); + t.strictEqual( title.anchor, 'middle', 'returns expected value' ); + + title = new Title({ + 'anchor': 'start' + }); + t.strictEqual( title.anchor, 'start', 'returns expected value' ); + + title = new Title({ + 'anchor': 'end' + }); + t.strictEqual( title.anchor, 'end', 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `anchor` property which can be set to a valid method', function test( t ) { + var title; + + title = new Title(); + + title.anchor = 'start'; + t.strictEqual( title.anchor, 'start', 'returns expected value' ); + + title.anchor = 'end'; + t.strictEqual( title.anchor, 'end', 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `anchor` property is set to a new value', function test( t ) { + var title; + var count; + + title = new Title(); + count = 0; + + title.on( 'change', onChange ); + + title.anchor = 'start'; + t.strictEqual( count, 1, 'returns expected value' ); + + title.anchor = 'end'; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + title.anchor = 'end'; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/title/ctor/test/test.angle.js b/lib/node_modules/@stdlib/plot/vega/title/ctor/test/test.angle.js new file mode 100644 index 000000000000..96097ddfc3ee --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/title/ctor/test/test.angle.js @@ -0,0 +1,167 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isUndefined = require( '@stdlib/assert/is-undefined' ); +var hasProp = require( '@stdlib/assert/has-property' ); +var isNumber = require( '@stdlib/assert/is-number' ); +var Title = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Title, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `angle` property', function test( t ) { + var v; + + v = new Title(); + t.strictEqual( hasOwnProp( v, 'angle' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'angle' ), true, 'returns expected value' ); + t.strictEqual( isUndefined( v.angle ), true, 'returns expected value' ); + + v = new Title({ + 'angle': 90 + }); + t.strictEqual( isNumber( v.angle ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor throws an error if provided an invalid `angle` option', function test( t ) { + var values; + var i; + + values = [ + 'beep', + 'boop', + null, + true, + false, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + var title = new Title({ // eslint-disable-line no-unused-vars + 'angle': value + }); + }; + } +}); + +tape( 'the constructor returns an instance having a `angle` property which throws an error if set to an invalid value', function test( t ) { + var values; + var i; + + values = [ + 'beep', + 'boop', + null, + true, + false, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + var title = new Title(); + title.angle = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `angle` property', function test( t ) { + var title; + + title = new Title(); + t.strictEqual( isUndefined( title.angle ), true, 'returns expected value' ); + + title = new Title({ + 'angle': 90 + }); + t.strictEqual( title.angle, 90, 'returns expected value' ); + + title = new Title({ + 'angle': 180 + }); + t.strictEqual( title.angle, 180, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `angle` property which can be set to a valid method', function test( t ) { + var title; + + title = new Title(); + + title.angle = 90; + t.strictEqual( title.angle, 90, 'returns expected value' ); + + title.angle = 180; + t.strictEqual( title.angle, 180, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `angle` property is set to a new value', function test( t ) { + var title; + var count; + + title = new Title(); + count = 0; + + title.on( 'change', onChange ); + + title.angle = 90; + t.strictEqual( count, 1, 'returns expected value' ); + + title.angle = 180; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + title.angle = 180; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/title/ctor/test/test.aria.js b/lib/node_modules/@stdlib/plot/vega/title/ctor/test/test.aria.js new file mode 100644 index 000000000000..b4496bca501d --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/title/ctor/test/test.aria.js @@ -0,0 +1,160 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var hasProp = require( '@stdlib/assert/has-property' ); +var isBoolean = require( '@stdlib/assert/is-boolean' ); +var Title = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Title, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `aria` property', function test( t ) { + var v; + + v = new Title(); + t.strictEqual( hasOwnProp( v, 'aria' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'aria' ), true, 'returns expected value' ); + t.strictEqual( isBoolean( v.aria ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the constructor throws an error if provided an invalid `aria` option', function test( t ) { + var values; + var i; + + values = [ + '5', + 5, + NaN, + null, + void 0, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + var title = new Title({ // eslint-disable-line no-unused-vars + 'aria': value + }); + }; + } +}); + +tape( 'the constructor returns an instance having a `aria` property which throws an error if set to a non-boolean value', function test( t ) { + var values; + var i; + + values = [ + '5', + 5, + NaN, + null, + void 0, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + var title = new Title(); + title.aria = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `aria` property', function test( t ) { + var title; + + title = new Title(); + t.strictEqual( title.aria, true, 'returns expected value' ); + + title = new Title({ + 'aria': false + }); + t.strictEqual( title.aria, false, 'returns expected value' ); + + title = new Title({ + 'aria': true + }); + t.strictEqual( title.aria, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `aria` property which can be set to a boolean', function test( t ) { + var title; + + title = new Title(); + + title.aria = true; + t.strictEqual( title.aria, true, 'returns expected value' ); + + title.aria = false; + t.strictEqual( title.aria, false, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `aria` property is set to a new value', function test( t ) { + var title; + var count; + + title = new Title(); + count = 0; + + title.on( 'change', onChange ); + + title.aria = false; + t.strictEqual( count, 1, 'returns expected value' ); + + title.aria = true; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + title.aria = true; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/title/ctor/test/test.baseline.js b/lib/node_modules/@stdlib/plot/vega/title/ctor/test/test.baseline.js new file mode 100644 index 000000000000..a37803d3bae3 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/title/ctor/test/test.baseline.js @@ -0,0 +1,167 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isUndefined = require( '@stdlib/assert/is-undefined' ); +var hasProp = require( '@stdlib/assert/has-property' ); +var isString = require( '@stdlib/assert/is-string' ); +var Title = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Title, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `baseline` property', function test( t ) { + var v; + + v = new Title(); + t.strictEqual( hasOwnProp( v, 'baseline' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'baseline' ), true, 'returns expected value' ); + t.strictEqual( isUndefined( v.baseline ), true, 'returns expected value' ); + + v = new Title({ + 'baseline': 'top' + }); + t.strictEqual( isString( v.baseline ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor throws an error if provided an invalid `baseline` option', function test( t ) { + var values; + var i; + + values = [ + 5, + NaN, + null, + true, + false, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + var title = new Title({ // eslint-disable-line no-unused-vars + 'baseline': value + }); + }; + } +}); + +tape( 'the constructor returns an instance having a `baseline` property which throws an error if set to an invalid value', function test( t ) { + var values; + var i; + + values = [ + 5, + NaN, + null, + true, + false, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + var title = new Title(); + title.baseline = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `baseline` property', function test( t ) { + var title; + + title = new Title(); + t.strictEqual( isUndefined( title.baseline ), true, 'returns expected value' ); + + title = new Title({ + 'baseline': 'top' + }); + t.strictEqual( title.baseline, 'top', 'returns expected value' ); + + title = new Title({ + 'baseline': 'bottom' + }); + t.strictEqual( title.baseline, 'bottom', 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `baseline` property which can be set to a valid method', function test( t ) { + var title; + + title = new Title(); + + title.baseline = 'top'; + t.strictEqual( title.baseline, 'top', 'returns expected value' ); + + title.baseline = 'bottom'; + t.strictEqual( title.baseline, 'bottom', 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `baseline` property is set to a new value', function test( t ) { + var title; + var count; + + title = new Title(); + count = 0; + + title.on( 'change', onChange ); + + title.baseline = 'bottom'; + t.strictEqual( count, 1, 'returns expected value' ); + + title.baseline = 'top'; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + title.baseline = 'top'; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/title/ctor/test/test.color.js b/lib/node_modules/@stdlib/plot/vega/title/ctor/test/test.color.js new file mode 100644 index 000000000000..5d2d5abd4438 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/title/ctor/test/test.color.js @@ -0,0 +1,167 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isUndefined = require( '@stdlib/assert/is-undefined' ); +var hasProp = require( '@stdlib/assert/has-property' ); +var isString = require( '@stdlib/assert/is-string' ); +var Title = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Title, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `color` property', function test( t ) { + var v; + + v = new Title(); + t.strictEqual( hasOwnProp( v, 'color' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'color' ), true, 'returns expected value' ); + t.strictEqual( isUndefined( v.color ), true, 'returns expected value' ); + + v = new Title({ + 'color': 'red' + }); + t.strictEqual( isString( v.color ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor throws an error if provided an invalid `color` option', function test( t ) { + var values; + var i; + + values = [ + 5, + NaN, + null, + true, + false, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + var title = new Title({ // eslint-disable-line no-unused-vars + 'color': value + }); + }; + } +}); + +tape( 'the constructor returns an instance having a `color` property which throws an error if set to an invalid value', function test( t ) { + var values; + var i; + + values = [ + 5, + NaN, + null, + true, + false, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + var title = new Title(); + title.color = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `color` property', function test( t ) { + var title; + + title = new Title(); + t.strictEqual( isUndefined( title.color ), true, 'returns expected value' ); + + title = new Title({ + 'color': 'steelblue' + }); + t.strictEqual( title.color, 'steelblue', 'returns expected value' ); + + title = new Title({ + 'color': 'red' + }); + t.strictEqual( title.color, 'red', 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `color` property which can be set to a valid method', function test( t ) { + var title; + + title = new Title(); + + title.color = 'steelblue'; + t.strictEqual( title.color, 'steelblue', 'returns expected value' ); + + title.color = 'red'; + t.strictEqual( title.color, 'red', 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `color` property is set to a new value', function test( t ) { + var title; + var count; + + title = new Title(); + count = 0; + + title.on( 'change', onChange ); + + title.color = 'red'; + t.strictEqual( count, 1, 'returns expected value' ); + + title.color = 'steelblue'; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + title.color = 'steelblue'; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/title/ctor/test/test.dx.js b/lib/node_modules/@stdlib/plot/vega/title/ctor/test/test.dx.js new file mode 100644 index 000000000000..16a6d4bef6e8 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/title/ctor/test/test.dx.js @@ -0,0 +1,167 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isUndefined = require( '@stdlib/assert/is-undefined' ); +var hasProp = require( '@stdlib/assert/has-property' ); +var isNumber = require( '@stdlib/assert/is-number' ); +var Title = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Title, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `dx` property', function test( t ) { + var v; + + v = new Title(); + t.strictEqual( hasOwnProp( v, 'dx' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'dx' ), true, 'returns expected value' ); + t.strictEqual( isUndefined( v.dx ), true, 'returns expected value' ); + + v = new Title({ + 'dx': 2 + }); + t.strictEqual( isNumber( v.dx ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor throws an error if provided an invalid `dx` option', function test( t ) { + var values; + var i; + + values = [ + 'beep', + 'boop', + null, + true, + false, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + var title = new Title({ // eslint-disable-line no-unused-vars + 'dx': value + }); + }; + } +}); + +tape( 'the constructor returns an instance having a `dx` property which throws an error if set to an invalid value', function test( t ) { + var values; + var i; + + values = [ + 'beep', + 'boop', + null, + true, + false, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + var title = new Title(); + title.dx = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `dx` property', function test( t ) { + var title; + + title = new Title(); + t.strictEqual( isUndefined( title.dx ), true, 'returns expected value' ); + + title = new Title({ + 'dx': 2 + }); + t.strictEqual( title.dx, 2, 'returns expected value' ); + + title = new Title({ + 'dx': 4 + }); + t.strictEqual( title.dx, 4, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `dx` property which can be set to a valid method', function test( t ) { + var title; + + title = new Title(); + + title.dx = 2; + t.strictEqual( title.dx, 2, 'returns expected value' ); + + title.dx = 4; + t.strictEqual( title.dx, 4, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `dx` property is set to a new value', function test( t ) { + var title; + var count; + + title = new Title(); + count = 0; + + title.on( 'change', onChange ); + + title.dx = 2; + t.strictEqual( count, 1, 'returns expected value' ); + + title.dx = 4; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + title.dx = 4; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/title/ctor/test/test.dy.js b/lib/node_modules/@stdlib/plot/vega/title/ctor/test/test.dy.js new file mode 100644 index 000000000000..40905c38aaf2 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/title/ctor/test/test.dy.js @@ -0,0 +1,167 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isUndefined = require( '@stdlib/assert/is-undefined' ); +var hasProp = require( '@stdlib/assert/has-property' ); +var isNumber = require( '@stdlib/assert/is-number' ); +var Title = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Title, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `dy` property', function test( t ) { + var v; + + v = new Title(); + t.strictEqual( hasOwnProp( v, 'dy' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'dy' ), true, 'returns expected value' ); + t.strictEqual( isUndefined( v.dy ), true, 'returns expected value' ); + + v = new Title({ + 'dy': 2 + }); + t.strictEqual( isNumber( v.dy ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor throws an error if provided an invalid `dy` option', function test( t ) { + var values; + var i; + + values = [ + 'beep', + 'boop', + null, + true, + false, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + var title = new Title({ // eslint-disable-line no-unused-vars + 'dy': value + }); + }; + } +}); + +tape( 'the constructor returns an instance having a `dy` property which throws an error if set to an invalid value', function test( t ) { + var values; + var i; + + values = [ + 'beep', + 'boop', + null, + true, + false, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + var title = new Title(); + title.dy = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `dy` property', function test( t ) { + var title; + + title = new Title(); + t.strictEqual( isUndefined( title.dy ), true, 'returns expected value' ); + + title = new Title({ + 'dy': 2 + }); + t.strictEqual( title.dy, 2, 'returns expected value' ); + + title = new Title({ + 'dy': 4 + }); + t.strictEqual( title.dy, 4, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `dy` property which can be set to a valid method', function test( t ) { + var title; + + title = new Title(); + + title.dy = 2; + t.strictEqual( title.dy, 2, 'returns expected value' ); + + title.dy = 4; + t.strictEqual( title.dy, 4, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `dy` property is set to a new value', function test( t ) { + var title; + var count; + + title = new Title(); + count = 0; + + title.on( 'change', onChange ); + + title.dy = 2; + t.strictEqual( count, 1, 'returns expected value' ); + + title.dy = 4; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + title.dy = 4; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/title/ctor/test/test.encode.js b/lib/node_modules/@stdlib/plot/vega/title/ctor/test/test.encode.js new file mode 100644 index 000000000000..03f84d0a9140 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/title/ctor/test/test.encode.js @@ -0,0 +1,230 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isUndefined = require( '@stdlib/assert/is-undefined' ); +var hasProp = require( '@stdlib/assert/has-property' ); +var isObject = require( '@stdlib/assert/is-object' ); +var Title = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Title, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `encode` property', function test( t ) { + var v; + + v = new Title(); + t.strictEqual( hasOwnProp( v, 'encode' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'encode' ), true, 'returns expected value' ); + t.strictEqual( isUndefined( v.encode ), true, 'returns expected value' ); + + v = new Title({ + 'encode': { + 'title': { + 'enter': { + 'fill': { + 'value': 'steelblue' + } + } + } + } + }); + t.strictEqual( isObject( v.encode ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor throws an error if provided an invalid `encode` option', function test( t ) { + var values; + var i; + + values = [ + 5, + 'beep', + 'boop', + NaN, + null, + true, + false, + [], + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + var title = new Title({ // eslint-disable-line no-unused-vars + 'encode': value + }); + }; + } +}); + +tape( 'the constructor returns an instance having a `encode` property which throws an error if set to an invalid value', function test( t ) { + var values; + var i; + + values = [ + 5, + 'beep', + 'boop', + NaN, + null, + true, + false, + [], + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + var title = new Title(); + title.encode = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `encode` property', function test( t ) { + var expected; + var title; + + title = new Title(); + t.strictEqual( isUndefined( title.encode ), true, 'returns expected value' ); + + title = new Title({ + 'encode': { + 'title': { + 'enter': { + 'fill': { + 'value': 'steelblue' + } + } + } + } + }); + + expected = { + 'encode': { + 'title': { + 'enter': { + 'fill': { + 'value': 'steelblue' + } + } + } + } + }; + t.deepEqual( title.encode, expected.encode, 'returns expected value' ); + t.end(); +}); + +tape( 'the constructor returns an instance having a `encode` property which can be set to a valid method', function test( t ) { + var expected; + var title; + + title = new Title(); + + title.encode = { + 'title': { + 'enter': { + 'fill': { + 'value': 'steelblue' + } + } + } + }; + + expected = { + 'encode': { + 'title': { + 'enter': { + 'fill': { + 'value': 'steelblue' + } + } + } + } + }; + t.deepEqual( title.encode, expected.encode, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `encode` property is set to a new value', function test( t ) { + var title; + var count; + var obj1; + var obj2; + + title = new Title(); + count = 0; + + title.on( 'change', onChange ); + + obj1 = { + 'title': { + 'enter': { + 'fill': { + 'value': 'steelblue' + } + } + } + }; + title.encode = obj1; + t.strictEqual( count, 1, 'returns expected value' ); + + obj2 = { + 'title': { + 'enter': { + 'fill': { + 'value': 'red' + } + } + } + }; + title.encode = obj2; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + title.encode = obj2; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/title/ctor/test/test.font.js b/lib/node_modules/@stdlib/plot/vega/title/ctor/test/test.font.js new file mode 100644 index 000000000000..dffc122db8bb --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/title/ctor/test/test.font.js @@ -0,0 +1,167 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isUndefined = require( '@stdlib/assert/is-undefined' ); +var hasProp = require( '@stdlib/assert/has-property' ); +var isString = require( '@stdlib/assert/is-string' ); +var Title = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Title, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `font` property', function test( t ) { + var v; + + v = new Title(); + t.strictEqual( hasOwnProp( v, 'font' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'font' ), true, 'returns expected value' ); + t.strictEqual( isUndefined( v.font ), true, 'returns expected value' ); + + v = new Title({ + 'font': 'Arial' + }); + t.strictEqual( isString( v.font ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor throws an error if provided an invalid `font` option', function test( t ) { + var values; + var i; + + values = [ + 5, + NaN, + null, + true, + false, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + var title = new Title({ // eslint-disable-line no-unused-vars + 'font': value + }); + }; + } +}); + +tape( 'the constructor returns an instance having a `font` property which throws an error if set to an invalid value', function test( t ) { + var values; + var i; + + values = [ + 5, + NaN, + null, + true, + false, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + var title = new Title(); + title.font = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `font` property', function test( t ) { + var title; + + title = new Title(); + t.strictEqual( isUndefined( title.font ), true, 'returns expected value' ); + + title = new Title({ + 'font': 'Arial' + }); + t.strictEqual( title.font, 'Arial', 'returns expected value' ); + + title = new Title({ + 'font': 'Sans' + }); + t.strictEqual( title.font, 'Sans', 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `font` property which can be set to a valid method', function test( t ) { + var title; + + title = new Title(); + + title.font = 'Arial'; + t.strictEqual( title.font, 'Arial', 'returns expected value' ); + + title.font = 'Sans'; + t.strictEqual( title.font, 'Sans', 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `font` property is set to a new value', function test( t ) { + var title; + var count; + + title = new Title(); + count = 0; + + title.on( 'change', onChange ); + + title.font = 'Sans'; + t.strictEqual( count, 1, 'returns expected value' ); + + title.font = 'Arial'; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + title.font = 'Arial'; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/title/ctor/test/test.font_size.js b/lib/node_modules/@stdlib/plot/vega/title/ctor/test/test.font_size.js new file mode 100644 index 000000000000..a41c8dd5bdf7 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/title/ctor/test/test.font_size.js @@ -0,0 +1,167 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isUndefined = require( '@stdlib/assert/is-undefined' ); +var hasProp = require( '@stdlib/assert/has-property' ); +var isNumber = require( '@stdlib/assert/is-number' ); +var Title = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Title, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `fontSize` property', function test( t ) { + var v; + + v = new Title(); + t.strictEqual( hasOwnProp( v, 'fontSize' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'fontSize' ), true, 'returns expected value' ); + t.strictEqual( isUndefined( v.fontSize ), true, 'returns expected value' ); + + v = new Title({ + 'fontSize': 12 + }); + t.strictEqual( isNumber( v.fontSize ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor throws an error if provided an invalid `fontSize` option', function test( t ) { + var values; + var i; + + values = [ + 'beep', + 'boop', + null, + true, + false, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + var title = new Title({ // eslint-disable-line no-unused-vars + 'fontSize': value + }); + }; + } +}); + +tape( 'the constructor returns an instance having a `fontSize` property which throws an error if set to an invalid value', function test( t ) { + var values; + var i; + + values = [ + 'beep', + 'boop', + null, + true, + false, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + var title = new Title(); + title.fontSize = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `fontSize` property', function test( t ) { + var title; + + title = new Title(); + t.strictEqual( isUndefined( title.fontSize ), true, 'returns expected value' ); + + title = new Title({ + 'fontSize': 12 + }); + t.strictEqual( title.fontSize, 12, 'returns expected value' ); + + title = new Title({ + 'fontSize': 14 + }); + t.strictEqual( title.fontSize, 14, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `fontSize` property which can be set to a valid method', function test( t ) { + var title; + + title = new Title(); + + title.fontSize = 12; + t.strictEqual( title.fontSize, 12, 'returns expected value' ); + + title.fontSize = 14; + t.strictEqual( title.fontSize, 14, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `fontSize` property is set to a new value', function test( t ) { + var title; + var count; + + title = new Title(); + count = 0; + + title.on( 'change', onChange ); + + title.fontSize = 12; + t.strictEqual( count, 1, 'returns expected value' ); + + title.fontSize = 14; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + title.fontSize = 14; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/title/ctor/test/test.font_style.js b/lib/node_modules/@stdlib/plot/vega/title/ctor/test/test.font_style.js new file mode 100644 index 000000000000..18cb1c19f096 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/title/ctor/test/test.font_style.js @@ -0,0 +1,167 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isUndefined = require( '@stdlib/assert/is-undefined' ); +var hasProp = require( '@stdlib/assert/has-property' ); +var isString = require( '@stdlib/assert/is-string' ); +var Title = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Title, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `fontStyle` property', function test( t ) { + var v; + + v = new Title(); + t.strictEqual( hasOwnProp( v, 'fontStyle' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'fontStyle' ), true, 'returns expected value' ); + t.strictEqual( isUndefined( v.fontStyle ), true, 'returns expected value' ); + + v = new Title({ + 'fontStyle': 'Arial' + }); + t.strictEqual( isString( v.fontStyle ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor throws an error if provided an invalid `fontStyle` option', function test( t ) { + var values; + var i; + + values = [ + 5, + NaN, + null, + true, + false, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + var title = new Title({ // eslint-disable-line no-unused-vars + 'fontStyle': value + }); + }; + } +}); + +tape( 'the constructor returns an instance having a `fontStyle` property which throws an error if set to an invalid value', function test( t ) { + var values; + var i; + + values = [ + 5, + NaN, + null, + true, + false, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + var title = new Title(); + title.fontStyle = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `fontStyle` property', function test( t ) { + var title; + + title = new Title(); + t.strictEqual( isUndefined( title.fontStyle ), true, 'returns expected value' ); + + title = new Title({ + 'fontStyle': 'Arial' + }); + t.strictEqual( title.fontStyle, 'Arial', 'returns expected value' ); + + title = new Title({ + 'fontStyle': 'Sans' + }); + t.strictEqual( title.fontStyle, 'Sans', 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `fontStyle` property which can be set to a valid method', function test( t ) { + var title; + + title = new Title(); + + title.fontStyle = 'Arial'; + t.strictEqual( title.fontStyle, 'Arial', 'returns expected value' ); + + title.fontStyle = 'Sans'; + t.strictEqual( title.fontStyle, 'Sans', 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `fontStyle` property is set to a new value', function test( t ) { + var title; + var count; + + title = new Title(); + count = 0; + + title.on( 'change', onChange ); + + title.fontStyle = 'Sans'; + t.strictEqual( count, 1, 'returns expected value' ); + + title.fontStyle = 'Arial'; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + title.fontStyle = 'Arial'; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/title/ctor/test/test.font_weight.js b/lib/node_modules/@stdlib/plot/vega/title/ctor/test/test.font_weight.js new file mode 100644 index 000000000000..94657b56f117 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/title/ctor/test/test.font_weight.js @@ -0,0 +1,185 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isUndefined = require( '@stdlib/assert/is-undefined' ); +var hasProp = require( '@stdlib/assert/has-property' ); +var isString = require( '@stdlib/assert/is-string' ); +var isNumber = require( '@stdlib/assert/is-number' ); +var Title = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Title, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `fontWeight` property', function test( t ) { + var v; + + v = new Title(); + t.strictEqual( hasOwnProp( v, 'fontWeight' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'fontWeight' ), true, 'returns expected value' ); + t.strictEqual( isUndefined( v.fontWeight ), true, 'returns expected value' ); + + v = new Title({ + 'fontWeight': 'bold' + }); + t.strictEqual( isString( v.fontWeight ), true, 'returns expected value' ); + + v = new Title({ + 'fontWeight': 6 + }); + t.strictEqual( isNumber( v.fontWeight ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor throws an error if provided an invalid `fontWeight` option', function test( t ) { + var values; + var i; + + values = [ + null, + true, + false, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + var title = new Title({ // eslint-disable-line no-unused-vars + 'fontWeight': value + }); + }; + } +}); + +tape( 'the constructor returns an instance having a `fontWeight` property which throws an error if set to an invalid value', function test( t ) { + var values; + var i; + + values = [ + null, + true, + false, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + var title = new Title(); + title.fontWeight = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `fontWeight` property', function test( t ) { + var title; + + title = new Title(); + t.strictEqual( isUndefined( title.fontWeight ), true, 'returns expected value' ); + + title = new Title({ + 'fontWeight': 'bold' + }); + t.strictEqual( title.fontWeight, 'bold', 'returns expected value' ); + + title = new Title({ + 'fontWeight': 'light' + }); + t.strictEqual( title.fontWeight, 'light', 'returns expected value' ); + + title = new Title({ + 'fontWeight': 6 + }); + t.strictEqual( title.fontWeight, 6, 'returns expected value' ); + + title = new Title({ + 'fontWeight': 8 + }); + t.strictEqual( title.fontWeight, 8, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `fontWeight` property which can be set to a valid method', function test( t ) { + var title; + + title = new Title(); + + title.fontWeight = 'bold'; + t.strictEqual( title.fontWeight, 'bold', 'returns expected value' ); + + title.fontWeight = 'light'; + t.strictEqual( title.fontWeight, 'light', 'returns expected value' ); + + title.fontWeight = 6; + t.strictEqual( title.fontWeight, 6, 'returns expected value' ); + + title.fontWeight = 8; + t.strictEqual( title.fontWeight, 8, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `fontWeight` property is set to a new value', function test( t ) { + var title; + var count; + + title = new Title(); + count = 0; + + title.on( 'change', onChange ); + + title.fontWeight = 'light'; + t.strictEqual( count, 1, 'returns expected value' ); + + title.fontWeight = 'bold'; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + title.fontWeight = 'bold'; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/title/ctor/test/test.frame.js b/lib/node_modules/@stdlib/plot/vega/title/ctor/test/test.frame.js new file mode 100644 index 000000000000..0e5570717866 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/title/ctor/test/test.frame.js @@ -0,0 +1,162 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var hasProp = require( '@stdlib/assert/has-property' ); +var isString = require( '@stdlib/assert/is-string' ); +var Title = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Title, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `frame` property', function test( t ) { + var v; + + v = new Title(); + t.strictEqual( hasOwnProp( v, 'frame' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'frame' ), true, 'returns expected value' ); + t.strictEqual( isString( v.frame ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor throws an error if provided an invalid `frame` option', function test( t ) { + var values; + var i; + + values = [ + 'beep', + 'boop', + 'GROUP', + 5, + NaN, + null, + true, + false, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + var title = new Title({ // eslint-disable-line no-unused-vars + 'frame': value + }); + }; + } +}); + +tape( 'the constructor returns an instance having a `frame` property which throws an error if set to an invalid value', function test( t ) { + var values; + var i; + + values = [ + 'beep', + 'boop', + 'GROUP', + 5, + NaN, + null, + true, + false, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + var title = new Title(); + title.frame = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `frame` property', function test( t ) { + var title; + + title = new Title(); + t.strictEqual( title.frame, 'bounds', 'returns expected value' ); + + title = new Title({ + 'frame': 'group' + }); + t.strictEqual( title.frame, 'group', 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `frame` property which can be set to a valid method', function test( t ) { + var title; + + title = new Title(); + + title.frame = 'group'; + t.strictEqual( title.frame, 'group', 'returns expected value' ); + + title.frame = 'bounds'; + t.strictEqual( title.frame, 'bounds', 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `frame` property is set to a new value', function test( t ) { + var title; + var count; + + title = new Title(); + count = 0; + + title.on( 'change', onChange ); + + title.frame = 'group'; + t.strictEqual( count, 1, 'returns expected value' ); + + title.frame = 'bounds'; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + title.frame = 'bounds'; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/title/ctor/test/test.js b/lib/node_modules/@stdlib/plot/vega/title/ctor/test/test.js new file mode 100644 index 000000000000..92e3958e0bec --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/title/ctor/test/test.js @@ -0,0 +1,252 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var isSameArray = require( '@stdlib/assert/is-same-array' ); +var instanceOf = require( '@stdlib/assert/instance-of' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var Title = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Title, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function is a constructor', function test( t ) { + var title = new Title(); + t.strictEqual( instanceOf( title, Title ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the constructor does not require the `new` keyword', function test( t ) { + var title; + var ctor; + + ctor = Title; + title = ctor(); + t.strictEqual( instanceOf( title, Title ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the constructor does not require the `new` keyword (options)', function test( t ) { + var title; + var ctor; + + ctor = Title; + title = ctor({ + 'text': 'Beep boop' + }); + t.strictEqual( instanceOf( title, Title ), true, 'returns expected value' ); + t.strictEqual( isSameArray( title.text, [ 'Beep boop' ] ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the constructor throws an error if provided an options argument which is not an object', function test( t ) { + var values; + var i; + + values = [ + '5', + 5, + NaN, + null, + void 0, + true, + false, + [], + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + var title = new Title( value ); // eslint-disable-line no-unused-vars + }; + } +}); + +tape( 'the constructor has a read-only `name` property', function test( t ) { + t.strictEqual( Title.name, 'Title', 'returns expected value' ); + t.end(); +}); + +tape( 'the constructor returns an instance having a `toJSON` method for serializing an instance to JSON', function test( t ) { + var expected; + var title; + var json; + + title = new Title(); + json = title.toJSON(); + + expected = { + 'anchor': 'middle', + 'aria': true, + 'frame': 'bounds', + 'orient': 'top', + 'text': [], + 'zindex': 0 + }; + t.deepEqual( json, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the constructor returns an instance having a `toJSON` method for serializing an instance to JSON (options)', function test( t ) { + var expected; + var title; + var json; + + title = new Title({ + 'text': 'Beep boop', + 'align': 'left', + 'anchor': 'start', + 'angle': 90, + 'aria': false, + 'baseline': 'top', + 'color': 'steelblue', + 'dx': 2, + 'dy': 2, + 'encode': { + 'title': { + 'enter': { + 'fill': { + 'value': 'steelblue' + } + } + } + }, + 'font': 'Arial', + 'fontSize': 12, + 'fontStyle': 'Arial', + 'fontWeight': 'bold', + 'frame': 'group', + 'limit': 100, + 'lineHeight': 2, + 'offset': 12, + 'orient': 'bottom', + 'subtitle': 'foo bar', + 'subtitleColor': 'steelblue', + 'subtitleFont': 'Arial', + 'subtitleFontSize': 14, + 'subtitleFontStyle': 'italic', + 'subtitleFontWeight': 'bold', + 'subtitleLineHeight': 16, + 'subtitlePadding': 24, + 'zindex': 2 + }); + json = title.toJSON(); + + expected = { + 'align': 'left', + 'anchor': 'start', + 'angle': 90, + 'aria': false, + 'baseline': 'top', + 'color': 'steelblue', + 'dx': 2, + 'dy': 2, + 'encode': { + 'title': { + 'enter': { + 'fill': { + 'value': 'steelblue' + } + } + } + }, + 'font': 'Arial', + 'fontSize': 12, + 'fontStyle': 'Arial', + 'fontWeight': 'bold', + 'frame': 'group', + 'limit': 100, + 'lineHeight': 2, + 'offset': 12, + 'orient': 'bottom', + 'subtitle': [ 'foo bar' ], + 'subtitleColor': 'steelblue', + 'subtitleFont': 'Arial', + 'subtitleFontSize': 14, + 'subtitleFontStyle': 'italic', + 'subtitleFontWeight': 'bold', + 'subtitleLineHeight': 16, + 'subtitlePadding': 24, + 'text': [ 'Beep boop' ], + 'zindex': 2 + }; + t.deepEqual( json, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the `toJSON` method is implicitly invoked by `JSON.stringify`', function test( t ) { + var expected; + var title; + + title = new Title({ + 'text': 'Beep boop' + }); + + expected = { + 'aria': true, + 'anchor': 'middle', + 'frame': 'bounds', + 'orient': 'top', + 'text': [ 'Beep boop' ], + 'zindex': 0 + }; + t.strictEqual( JSON.stringify( title ), JSON.stringify( expected ), 'returns expected value' ); + t.end(); +}); + +tape( 'the constructor returns an instance which inherits from EventEmitter', function test( t ) { + var title; + + title = new Title(); + + t.strictEqual( typeof title.on, 'function', 'returns expected value' ); + t.strictEqual( typeof title.emit, 'function', 'returns expected value' ); + t.strictEqual( typeof title.removeListener, 'function', 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor ignores unrecognized options', function test( t ) { + var title; + + title = new Title({ + 'text': 'Beep boop', + 'beep': 'boop', + 'foo': 'bar' + }); + + t.strictEqual( isSameArray( title.text, [ 'Beep boop' ] ), true, 'returns expected value' ); + t.strictEqual( hasOwnProp( title, 'beep' ), false, 'returns expected value' ); + t.strictEqual( hasOwnProp( title, 'foo' ), false, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/plot/vega/title/ctor/test/test.limit.js b/lib/node_modules/@stdlib/plot/vega/title/ctor/test/test.limit.js new file mode 100644 index 000000000000..44082b47ecba --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/title/ctor/test/test.limit.js @@ -0,0 +1,167 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isUndefined = require( '@stdlib/assert/is-undefined' ); +var hasProp = require( '@stdlib/assert/has-property' ); +var isNumber = require( '@stdlib/assert/is-number' ); +var Title = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Title, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `limit` property', function test( t ) { + var v; + + v = new Title(); + t.strictEqual( hasOwnProp( v, 'limit' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'limit' ), true, 'returns expected value' ); + t.strictEqual( isUndefined( v.limit ), true, 'returns expected value' ); + + v = new Title({ + 'limit': 100 + }); + t.strictEqual( isNumber( v.limit ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor throws an error if provided an invalid `limit` option', function test( t ) { + var values; + var i; + + values = [ + 'beep', + 'boop', + null, + true, + false, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + var title = new Title({ // eslint-disable-line no-unused-vars + 'limit': value + }); + }; + } +}); + +tape( 'the constructor returns an instance having a `limit` property which throws an error if set to an invalid value', function test( t ) { + var values; + var i; + + values = [ + 'beep', + 'boop', + null, + true, + false, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + var title = new Title(); + title.limit = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `limit` property', function test( t ) { + var title; + + title = new Title(); + t.strictEqual( isUndefined( title.limit ), true, 'returns expected value' ); + + title = new Title({ + 'limit': 100 + }); + t.strictEqual( title.limit, 100, 'returns expected value' ); + + title = new Title({ + 'limit': 150 + }); + t.strictEqual( title.limit, 150, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `limit` property which can be set to a valid method', function test( t ) { + var title; + + title = new Title(); + + title.limit = 100; + t.strictEqual( title.limit, 100, 'returns expected value' ); + + title.limit = 150; + t.strictEqual( title.limit, 150, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `limit` property is set to a new value', function test( t ) { + var title; + var count; + + title = new Title(); + count = 0; + + title.on( 'change', onChange ); + + title.limit = 100; + t.strictEqual( count, 1, 'returns expected value' ); + + title.limit = 150; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + title.limit = 150; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/title/ctor/test/test.line_height.js b/lib/node_modules/@stdlib/plot/vega/title/ctor/test/test.line_height.js new file mode 100644 index 000000000000..b8d59abbf1e5 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/title/ctor/test/test.line_height.js @@ -0,0 +1,167 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isUndefined = require( '@stdlib/assert/is-undefined' ); +var hasProp = require( '@stdlib/assert/has-property' ); +var isNumber = require( '@stdlib/assert/is-number' ); +var Title = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Title, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `lineHeight` property', function test( t ) { + var v; + + v = new Title(); + t.strictEqual( hasOwnProp( v, 'lineHeight' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'lineHeight' ), true, 'returns expected value' ); + t.strictEqual( isUndefined( v.lineHeight ), true, 'returns expected value' ); + + v = new Title({ + 'lineHeight': 2 + }); + t.strictEqual( isNumber( v.lineHeight ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor throws an error if provided an invalid `lineHeight` option', function test( t ) { + var values; + var i; + + values = [ + 'beep', + 'boop', + null, + true, + false, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + var title = new Title({ // eslint-disable-line no-unused-vars + 'lineHeight': value + }); + }; + } +}); + +tape( 'the constructor returns an instance having a `lineHeight` property which throws an error if set to an invalid value', function test( t ) { + var values; + var i; + + values = [ + 'beep', + 'boop', + null, + true, + false, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + var title = new Title(); + title.lineHeight = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `lineHeight` property', function test( t ) { + var title; + + title = new Title(); + t.strictEqual( isUndefined( title.lineHeight ), true, 'returns expected value' ); + + title = new Title({ + 'lineHeight': 2 + }); + t.strictEqual( title.lineHeight, 2, 'returns expected value' ); + + title = new Title({ + 'lineHeight': 4 + }); + t.strictEqual( title.lineHeight, 4, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `lineHeight` property which can be set to a valid method', function test( t ) { + var title; + + title = new Title(); + + title.lineHeight = 2; + t.strictEqual( title.lineHeight, 2, 'returns expected value' ); + + title.lineHeight = 4; + t.strictEqual( title.lineHeight, 4, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `lineHeight` property is set to a new value', function test( t ) { + var title; + var count; + + title = new Title(); + count = 0; + + title.on( 'change', onChange ); + + title.lineHeight = 2; + t.strictEqual( count, 1, 'returns expected value' ); + + title.lineHeight = 4; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + title.lineHeight = 4; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/title/ctor/test/test.offset.js b/lib/node_modules/@stdlib/plot/vega/title/ctor/test/test.offset.js new file mode 100644 index 000000000000..f12bdc8d130b --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/title/ctor/test/test.offset.js @@ -0,0 +1,167 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isUndefined = require( '@stdlib/assert/is-undefined' ); +var hasProp = require( '@stdlib/assert/has-property' ); +var isNumber = require( '@stdlib/assert/is-number' ); +var Title = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Title, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `offset` property', function test( t ) { + var v; + + v = new Title(); + t.strictEqual( hasOwnProp( v, 'offset' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'offset' ), true, 'returns expected value' ); + t.strictEqual( isUndefined( v.offset ), true, 'returns expected value' ); + + v = new Title({ + 'offset': 12 + }); + t.strictEqual( isNumber( v.offset ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor throws an error if provided an invalid `offset` option', function test( t ) { + var values; + var i; + + values = [ + 'beep', + 'boop', + null, + true, + false, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + var title = new Title({ // eslint-disable-line no-unused-vars + 'offset': value + }); + }; + } +}); + +tape( 'the constructor returns an instance having a `offset` property which throws an error if set to an invalid value', function test( t ) { + var values; + var i; + + values = [ + 'beep', + 'boop', + null, + true, + false, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + var title = new Title(); + title.offset = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `offset` property', function test( t ) { + var title; + + title = new Title(); + t.strictEqual( isUndefined( title.offset ), true, 'returns expected value' ); + + title = new Title({ + 'offset': 12 + }); + t.strictEqual( title.offset, 12, 'returns expected value' ); + + title = new Title({ + 'offset': 14 + }); + t.strictEqual( title.offset, 14, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `offset` property which can be set to a valid method', function test( t ) { + var title; + + title = new Title(); + + title.offset = 12; + t.strictEqual( title.offset, 12, 'returns expected value' ); + + title.offset = 14; + t.strictEqual( title.offset, 14, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `offset` property is set to a new value', function test( t ) { + var title; + var count; + + title = new Title(); + count = 0; + + title.on( 'change', onChange ); + + title.offset = 12; + t.strictEqual( count, 1, 'returns expected value' ); + + title.offset = 14; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + title.offset = 14; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/title/ctor/test/test.orient.js b/lib/node_modules/@stdlib/plot/vega/title/ctor/test/test.orient.js new file mode 100644 index 000000000000..73b84a822f61 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/title/ctor/test/test.orient.js @@ -0,0 +1,178 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var hasProp = require( '@stdlib/assert/has-property' ); +var isString = require( '@stdlib/assert/is-string' ); +var Title = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Title, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `orient` property', function test( t ) { + var v; + + v = new Title(); + t.strictEqual( hasOwnProp( v, 'orient' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'orient' ), true, 'returns expected value' ); + t.strictEqual( isString( v.orient ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor throws an error if provided an invalid `orient` option', function test( t ) { + var values; + var i; + + values = [ + 'beep', + 'boop', + 'BOTTOM', + 5, + NaN, + null, + true, + false, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + var title = new Title({ // eslint-disable-line no-unused-vars + 'orient': value + }); + }; + } +}); + +tape( 'the constructor returns an instance having a `orient` property which throws an error if set to an invalid value', function test( t ) { + var values; + var i; + + values = [ + 'beep', + 'boop', + 'BOTTOM', + 5, + NaN, + null, + true, + false, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + var title = new Title(); + title.orient = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `orient` property', function test( t ) { + var title; + + title = new Title(); + t.strictEqual( title.orient, 'top', 'returns expected value' ); + + title = new Title({ + 'orient': 'bottom' + }); + t.strictEqual( title.orient, 'bottom', 'returns expected value' ); + + title = new Title({ + 'orient': 'left' + }); + t.strictEqual( title.orient, 'left', 'returns expected value' ); + + title = new Title({ + 'orient': 'right' + }); + t.strictEqual( title.orient, 'right', 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `orient` property which can be set to a valid method', function test( t ) { + var title; + + title = new Title(); + + title.orient = 'bottom'; + t.strictEqual( title.orient, 'bottom', 'returns expected value' ); + + title.orient = 'top'; + t.strictEqual( title.orient, 'top', 'returns expected value' ); + + title.orient = 'left'; + t.strictEqual( title.orient, 'left', 'returns expected value' ); + + title.orient = 'right'; + t.strictEqual( title.orient, 'right', 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `orient` property is set to a new value', function test( t ) { + var title; + var count; + + title = new Title(); + count = 0; + + title.on( 'change', onChange ); + + title.orient = 'bottom'; + t.strictEqual( count, 1, 'returns expected value' ); + + title.orient = 'top'; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + title.orient = 'top'; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/title/ctor/test/test.properties.js b/lib/node_modules/@stdlib/plot/vega/title/ctor/test/test.properties.js new file mode 100644 index 000000000000..be0d60b5f707 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/title/ctor/test/test.properties.js @@ -0,0 +1,77 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var hasProp = require( '@stdlib/assert/has-property' ); +var isArray = require( '@stdlib/assert/is-array' ); +var Title = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Title, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `properties` property', function test( t ) { + var v; + + v = new Title(); + t.strictEqual( hasOwnProp( v, 'properties' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'properties' ), true, 'returns expected value' ); + t.strictEqual( isArray( v.properties ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the constructor returns an instance having a `properties` property which returns a list of enumerable properties', function test( t ) { + var expected; + var title; + var props; + + title = new Title(); + props = title.properties; + + t.strictEqual( isArray( props ), true, 'returns expected value' ); + + expected = [ 'aria', 'align', 'anchor', 'angle', 'baseline', 'color', 'dx', 'dy', 'encode', 'font', 'fontSize', 'fontStyle', 'fontWeight', 'frame', 'limit', 'lineHeight', 'offset', 'orient', 'subtitle', 'subtitleColor', 'subtitleFont', 'subtitleFontSize', 'subtitleFontStyle', 'subtitleFontWeight', 'subtitleLineHeight', 'subtitlePadding', 'text', 'zindex' ]; + t.deepEqual( props, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `properties` property which returns a new array on each access', function test( t ) { + var props1; + var props2; + var title; + + title = new Title(); + props1 = title.properties; + props2 = title.properties; + + t.notEqual( props1, props2, 'returns expected value' ); + t.deepEqual( props1, props2, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/plot/vega/title/ctor/test/test.subtitle.js b/lib/node_modules/@stdlib/plot/vega/title/ctor/test/test.subtitle.js new file mode 100644 index 000000000000..b65c5f047527 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/title/ctor/test/test.subtitle.js @@ -0,0 +1,167 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isUndefined = require( '@stdlib/assert/is-undefined' ); +var hasProp = require( '@stdlib/assert/has-property' ); +var isSameArray = require( '@stdlib/assert/is-same-array' ); +var Title = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Title, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `subtitle` property', function test( t ) { + var v; + + v = new Title(); + t.strictEqual( hasOwnProp( v, 'subtitle' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'subtitle' ), true, 'returns expected value' ); + t.strictEqual( isUndefined( v.subtitle ), true, 'returns expected value' ); + + v = new Title({ + 'subtitle': 'foo bar' + }); + t.strictEqual( isSameArray( v.subtitle, [ 'foo bar' ] ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor throws an error if provided an invalid `subtitle` option', function test( t ) { + var values; + var i; + + values = [ + 5, + NaN, + null, + true, + false, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + var title = new Title({ // eslint-disable-line no-unused-vars + 'subtitle': value + }); + }; + } +}); + +tape( 'the constructor returns an instance having a `subtitle` property which throws an error if set to an invalid value', function test( t ) { + var values; + var i; + + values = [ + 5, + NaN, + null, + true, + false, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + var title = new Title(); + title.subtitle = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `subtitle` property', function test( t ) { + var title; + + title = new Title(); + t.strictEqual( isUndefined( title.subtitle ), true, 'returns expected value' ); + + title = new Title({ + 'subtitle': 'foo bar' + }); + t.strictEqual( isSameArray( title.subtitle, [ 'foo bar' ] ), true, 'returns expected value' ); + + title = new Title({ + 'subtitle': 'beep boop' + }); + t.strictEqual( isSameArray( title.subtitle, [ 'beep boop' ] ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `subtitle` property which can be set to a valid method', function test( t ) { + var title; + + title = new Title(); + + title.subtitle = 'foo bar'; + t.strictEqual( isSameArray( title.subtitle, [ 'foo bar' ] ), true, 'returns expected value' ); + + title.subtitle = 'beep boop'; + t.strictEqual( isSameArray( title.subtitle, [ 'beep boop' ] ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `subtitle` property is set to a new value', function test( t ) { + var title; + var count; + + title = new Title(); + count = 0; + + title.on( 'change', onChange ); + + title.subtitle = 'beep boop'; + t.strictEqual( count, 1, 'returns expected value' ); + + title.subtitle = 'foo bar'; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + title.subtitle = 'foo bar'; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/title/ctor/test/test.subtitle_color.js b/lib/node_modules/@stdlib/plot/vega/title/ctor/test/test.subtitle_color.js new file mode 100644 index 000000000000..3e1f580d7cf2 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/title/ctor/test/test.subtitle_color.js @@ -0,0 +1,167 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isUndefined = require( '@stdlib/assert/is-undefined' ); +var hasProp = require( '@stdlib/assert/has-property' ); +var isString = require( '@stdlib/assert/is-string' ); +var Title = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Title, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `subtitleColor` property', function test( t ) { + var v; + + v = new Title(); + t.strictEqual( hasOwnProp( v, 'subtitleColor' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'subtitleColor' ), true, 'returns expected value' ); + t.strictEqual( isUndefined( v.subtitleColor ), true, 'returns expected value' ); + + v = new Title({ + 'subtitleColor': 'red' + }); + t.strictEqual( isString( v.subtitleColor ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor throws an error if provided an invalid `subtitleColor` option', function test( t ) { + var values; + var i; + + values = [ + 5, + NaN, + null, + true, + false, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + var title = new Title({ // eslint-disable-line no-unused-vars + 'subtitleColor': value + }); + }; + } +}); + +tape( 'the constructor returns an instance having a `subtitleColor` property which throws an error if set to an invalid value', function test( t ) { + var values; + var i; + + values = [ + 5, + NaN, + null, + true, + false, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + var title = new Title(); + title.subtitleColor = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `subtitleColor` property', function test( t ) { + var title; + + title = new Title(); + t.strictEqual( isUndefined( title.subtitleColor ), true, 'returns expected value' ); + + title = new Title({ + 'subtitleColor': 'steelblue' + }); + t.strictEqual( title.subtitleColor, 'steelblue', 'returns expected value' ); + + title = new Title({ + 'subtitleColor': 'red' + }); + t.strictEqual( title.subtitleColor, 'red', 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `subtitleColor` property which can be set to a valid method', function test( t ) { + var title; + + title = new Title(); + + title.subtitleColor = 'steelblue'; + t.strictEqual( title.subtitleColor, 'steelblue', 'returns expected value' ); + + title.subtitleColor = 'red'; + t.strictEqual( title.subtitleColor, 'red', 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `subtitleColor` property is set to a new value', function test( t ) { + var title; + var count; + + title = new Title(); + count = 0; + + title.on( 'change', onChange ); + + title.subtitleColor = 'red'; + t.strictEqual( count, 1, 'returns expected value' ); + + title.subtitleColor = 'steelblue'; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + title.subtitleColor = 'steelblue'; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/title/ctor/test/test.subtitle_font.js b/lib/node_modules/@stdlib/plot/vega/title/ctor/test/test.subtitle_font.js new file mode 100644 index 000000000000..83d74429680b --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/title/ctor/test/test.subtitle_font.js @@ -0,0 +1,167 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isUndefined = require( '@stdlib/assert/is-undefined' ); +var hasProp = require( '@stdlib/assert/has-property' ); +var isString = require( '@stdlib/assert/is-string' ); +var Title = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Title, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `subtitleFont` property', function test( t ) { + var v; + + v = new Title(); + t.strictEqual( hasOwnProp( v, 'subtitleFont' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'subtitleFont' ), true, 'returns expected value' ); + t.strictEqual( isUndefined( v.subtitleFont ), true, 'returns expected value' ); + + v = new Title({ + 'subtitleFont': 'Arial' + }); + t.strictEqual( isString( v.subtitleFont ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor throws an error if provided an invalid `subtitleFont` option', function test( t ) { + var values; + var i; + + values = [ + 5, + NaN, + null, + true, + false, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + var title = new Title({ // eslint-disable-line no-unused-vars + 'subtitleFont': value + }); + }; + } +}); + +tape( 'the constructor returns an instance having a `subtitleFont` property which throws an error if set to an invalid value', function test( t ) { + var values; + var i; + + values = [ + 5, + NaN, + null, + true, + false, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + var title = new Title(); + title.subtitleFont = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `subtitleFont` property', function test( t ) { + var title; + + title = new Title(); + t.strictEqual( isUndefined( title.subtitleFont ), true, 'returns expected value' ); + + title = new Title({ + 'subtitleFont': 'Arial' + }); + t.strictEqual( title.subtitleFont, 'Arial', 'returns expected value' ); + + title = new Title({ + 'subtitleFont': 'Sans' + }); + t.strictEqual( title.subtitleFont, 'Sans', 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `subtitleFont` property which can be set to a valid method', function test( t ) { + var title; + + title = new Title(); + + title.subtitleFont = 'Arial'; + t.strictEqual( title.subtitleFont, 'Arial', 'returns expected value' ); + + title.subtitleFont = 'Sans'; + t.strictEqual( title.subtitleFont, 'Sans', 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `subtitleFont` property is set to a new value', function test( t ) { + var title; + var count; + + title = new Title(); + count = 0; + + title.on( 'change', onChange ); + + title.subtitleFont = 'Sans'; + t.strictEqual( count, 1, 'returns expected value' ); + + title.subtitleFont = 'Arial'; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + title.subtitleFont = 'Arial'; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/title/ctor/test/test.subtitle_font_size.js b/lib/node_modules/@stdlib/plot/vega/title/ctor/test/test.subtitle_font_size.js new file mode 100644 index 000000000000..4a0817d999b6 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/title/ctor/test/test.subtitle_font_size.js @@ -0,0 +1,167 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isUndefined = require( '@stdlib/assert/is-undefined' ); +var hasProp = require( '@stdlib/assert/has-property' ); +var isNumber = require( '@stdlib/assert/is-number' ); +var Title = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Title, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `subtitleFontSize` property', function test( t ) { + var v; + + v = new Title(); + t.strictEqual( hasOwnProp( v, 'subtitleFontSize' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'subtitleFontSize' ), true, 'returns expected value' ); + t.strictEqual( isUndefined( v.subtitleFontSize ), true, 'returns expected value' ); + + v = new Title({ + 'subtitleFontSize': 12 + }); + t.strictEqual( isNumber( v.subtitleFontSize ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor throws an error if provided an invalid `subtitleFontSize` option', function test( t ) { + var values; + var i; + + values = [ + 'beep', + 'boop', + null, + true, + false, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + var title = new Title({ // eslint-disable-line no-unused-vars + 'subtitleFontSize': value + }); + }; + } +}); + +tape( 'the constructor returns an instance having a `subtitleFontSize` property which throws an error if set to an invalid value', function test( t ) { + var values; + var i; + + values = [ + 'beep', + 'boop', + null, + true, + false, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + var title = new Title(); + title.subtitleFontSize = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `subtitleFontSize` property', function test( t ) { + var title; + + title = new Title(); + t.strictEqual( isUndefined( title.subtitleFontSize ), true, 'returns expected value' ); + + title = new Title({ + 'subtitleFontSize': 12 + }); + t.strictEqual( title.subtitleFontSize, 12, 'returns expected value' ); + + title = new Title({ + 'subtitleFontSize': 14 + }); + t.strictEqual( title.subtitleFontSize, 14, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `subtitleFontSize` property which can be set to a valid method', function test( t ) { + var title; + + title = new Title(); + + title.subtitleFontSize = 12; + t.strictEqual( title.subtitleFontSize, 12, 'returns expected value' ); + + title.subtitleFontSize = 14; + t.strictEqual( title.subtitleFontSize, 14, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `subtitleFontSize` property is set to a new value', function test( t ) { + var title; + var count; + + title = new Title(); + count = 0; + + title.on( 'change', onChange ); + + title.subtitleFontSize = 12; + t.strictEqual( count, 1, 'returns expected value' ); + + title.subtitleFontSize = 14; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + title.subtitleFontSize = 14; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/title/ctor/test/test.subtitle_font_style.js b/lib/node_modules/@stdlib/plot/vega/title/ctor/test/test.subtitle_font_style.js new file mode 100644 index 000000000000..4e85816fa7f6 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/title/ctor/test/test.subtitle_font_style.js @@ -0,0 +1,167 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isUndefined = require( '@stdlib/assert/is-undefined' ); +var hasProp = require( '@stdlib/assert/has-property' ); +var isString = require( '@stdlib/assert/is-string' ); +var Title = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Title, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `subtitleFontStyle` property', function test( t ) { + var v; + + v = new Title(); + t.strictEqual( hasOwnProp( v, 'subtitleFontStyle' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'subtitleFontStyle' ), true, 'returns expected value' ); + t.strictEqual( isUndefined( v.subtitleFontStyle ), true, 'returns expected value' ); + + v = new Title({ + 'subtitleFontStyle': 'Arial' + }); + t.strictEqual( isString( v.subtitleFontStyle ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor throws an error if provided an invalid `subtitleFontStyle` option', function test( t ) { + var values; + var i; + + values = [ + 5, + NaN, + null, + true, + false, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + var title = new Title({ // eslint-disable-line no-unused-vars + 'subtitleFontStyle': value + }); + }; + } +}); + +tape( 'the constructor returns an instance having a `subtitleFontStyle` property which throws an error if set to an invalid value', function test( t ) { + var values; + var i; + + values = [ + 5, + NaN, + null, + true, + false, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + var title = new Title(); + title.subtitleFontStyle = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `subtitleFontStyle` property', function test( t ) { + var title; + + title = new Title(); + t.strictEqual( isUndefined( title.subtitleFontStyle ), true, 'returns expected value' ); + + title = new Title({ + 'subtitleFontStyle': 'Arial' + }); + t.strictEqual( title.subtitleFontStyle, 'Arial', 'returns expected value' ); + + title = new Title({ + 'subtitleFontStyle': 'Sans' + }); + t.strictEqual( title.subtitleFontStyle, 'Sans', 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `subtitleFontStyle` property which can be set to a valid method', function test( t ) { + var title; + + title = new Title(); + + title.subtitleFontStyle = 'Arial'; + t.strictEqual( title.subtitleFontStyle, 'Arial', 'returns expected value' ); + + title.subtitleFontStyle = 'Sans'; + t.strictEqual( title.subtitleFontStyle, 'Sans', 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `subtitleFontStyle` property is set to a new value', function test( t ) { + var title; + var count; + + title = new Title(); + count = 0; + + title.on( 'change', onChange ); + + title.subtitleFontStyle = 'Sans'; + t.strictEqual( count, 1, 'returns expected value' ); + + title.subtitleFontStyle = 'Arial'; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + title.subtitleFontStyle = 'Arial'; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/title/ctor/test/test.subtitle_font_weight.js b/lib/node_modules/@stdlib/plot/vega/title/ctor/test/test.subtitle_font_weight.js new file mode 100644 index 000000000000..7550a20798e2 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/title/ctor/test/test.subtitle_font_weight.js @@ -0,0 +1,185 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isUndefined = require( '@stdlib/assert/is-undefined' ); +var hasProp = require( '@stdlib/assert/has-property' ); +var isString = require( '@stdlib/assert/is-string' ); +var isNumber = require( '@stdlib/assert/is-number' ); +var Title = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Title, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `subtitleFontWeight` property', function test( t ) { + var v; + + v = new Title(); + t.strictEqual( hasOwnProp( v, 'subtitleFontWeight' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'subtitleFontWeight' ), true, 'returns expected value' ); + t.strictEqual( isUndefined( v.subtitleFontWeight ), true, 'returns expected value' ); + + v = new Title({ + 'subtitleFontWeight': 'bold' + }); + t.strictEqual( isString( v.subtitleFontWeight ), true, 'returns expected value' ); + + v = new Title({ + 'subtitleFontWeight': 6 + }); + t.strictEqual( isNumber( v.subtitleFontWeight ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor throws an error if provided an invalid `subtitleFontWeight` option', function test( t ) { + var values; + var i; + + values = [ + null, + true, + false, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + var title = new Title({ // eslint-disable-line no-unused-vars + 'subtitleFontWeight': value + }); + }; + } +}); + +tape( 'the constructor returns an instance having a `subtitleFontWeight` property which throws an error if set to an invalid value', function test( t ) { + var values; + var i; + + values = [ + null, + true, + false, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + var title = new Title(); + title.subtitleFontWeight = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `subtitleFontWeight` property', function test( t ) { + var title; + + title = new Title(); + t.strictEqual( isUndefined( title.subtitleFontWeight ), true, 'returns expected value' ); + + title = new Title({ + 'subtitleFontWeight': 'bold' + }); + t.strictEqual( title.subtitleFontWeight, 'bold', 'returns expected value' ); + + title = new Title({ + 'subtitleFontWeight': 'light' + }); + t.strictEqual( title.subtitleFontWeight, 'light', 'returns expected value' ); + + title = new Title({ + 'subtitleFontWeight': 6 + }); + t.strictEqual( title.subtitleFontWeight, 6, 'returns expected value' ); + + title = new Title({ + 'subtitleFontWeight': 8 + }); + t.strictEqual( title.subtitleFontWeight, 8, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `subtitleFontWeight` property which can be set to a valid method', function test( t ) { + var title; + + title = new Title(); + + title.subtitleFontWeight = 'bold'; + t.strictEqual( title.subtitleFontWeight, 'bold', 'returns expected value' ); + + title.subtitleFontWeight = 'light'; + t.strictEqual( title.subtitleFontWeight, 'light', 'returns expected value' ); + + title.subtitleFontWeight = 6; + t.strictEqual( title.subtitleFontWeight, 6, 'returns expected value' ); + + title.subtitleFontWeight = 8; + t.strictEqual( title.subtitleFontWeight, 8, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `subtitleFontWeight` property is set to a new value', function test( t ) { + var title; + var count; + + title = new Title(); + count = 0; + + title.on( 'change', onChange ); + + title.subtitleFontWeight = 'light'; + t.strictEqual( count, 1, 'returns expected value' ); + + title.subtitleFontWeight = 'bold'; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + title.subtitleFontWeight = 'bold'; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/title/ctor/test/test.subtitle_line_height.js b/lib/node_modules/@stdlib/plot/vega/title/ctor/test/test.subtitle_line_height.js new file mode 100644 index 000000000000..08b25dcbfe6f --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/title/ctor/test/test.subtitle_line_height.js @@ -0,0 +1,167 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isUndefined = require( '@stdlib/assert/is-undefined' ); +var hasProp = require( '@stdlib/assert/has-property' ); +var isNumber = require( '@stdlib/assert/is-number' ); +var Title = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Title, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `subtitleLineHeight` property', function test( t ) { + var v; + + v = new Title(); + t.strictEqual( hasOwnProp( v, 'subtitleLineHeight' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'subtitleLineHeight' ), true, 'returns expected value' ); + t.strictEqual( isUndefined( v.subtitleLineHeight ), true, 'returns expected value' ); + + v = new Title({ + 'subtitleLineHeight': 2 + }); + t.strictEqual( isNumber( v.subtitleLineHeight ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor throws an error if provided an invalid `subtitleLineHeight` option', function test( t ) { + var values; + var i; + + values = [ + 'beep', + 'boop', + null, + true, + false, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + var title = new Title({ // eslint-disable-line no-unused-vars + 'subtitleLineHeight': value + }); + }; + } +}); + +tape( 'the constructor returns an instance having a `subtitleLineHeight` property which throws an error if set to an invalid value', function test( t ) { + var values; + var i; + + values = [ + 'beep', + 'boop', + null, + true, + false, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + var title = new Title(); + title.subtitleLineHeight = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `subtitleLineHeight` property', function test( t ) { + var title; + + title = new Title(); + t.strictEqual( isUndefined( title.subtitleLineHeight ), true, 'returns expected value' ); + + title = new Title({ + 'subtitleLineHeight': 2 + }); + t.strictEqual( title.subtitleLineHeight, 2, 'returns expected value' ); + + title = new Title({ + 'subtitleLineHeight': 4 + }); + t.strictEqual( title.subtitleLineHeight, 4, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `subtitleLineHeight` property which can be set to a valid method', function test( t ) { + var title; + + title = new Title(); + + title.subtitleLineHeight = 2; + t.strictEqual( title.subtitleLineHeight, 2, 'returns expected value' ); + + title.subtitleLineHeight = 4; + t.strictEqual( title.subtitleLineHeight, 4, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `subtitleLineHeight` property is set to a new value', function test( t ) { + var title; + var count; + + title = new Title(); + count = 0; + + title.on( 'change', onChange ); + + title.subtitleLineHeight = 2; + t.strictEqual( count, 1, 'returns expected value' ); + + title.subtitleLineHeight = 4; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + title.subtitleLineHeight = 4; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/title/ctor/test/test.subtitle_padding.js b/lib/node_modules/@stdlib/plot/vega/title/ctor/test/test.subtitle_padding.js new file mode 100644 index 000000000000..a654106b8bb2 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/title/ctor/test/test.subtitle_padding.js @@ -0,0 +1,167 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isUndefined = require( '@stdlib/assert/is-undefined' ); +var hasProp = require( '@stdlib/assert/has-property' ); +var isNumber = require( '@stdlib/assert/is-number' ); +var Title = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Title, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `subtitlePadding` property', function test( t ) { + var v; + + v = new Title(); + t.strictEqual( hasOwnProp( v, 'subtitlePadding' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'subtitlePadding' ), true, 'returns expected value' ); + t.strictEqual( isUndefined( v.subtitlePadding ), true, 'returns expected value' ); + + v = new Title({ + 'subtitlePadding': 12 + }); + t.strictEqual( isNumber( v.subtitlePadding ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor throws an error if provided an invalid `subtitlePadding` option', function test( t ) { + var values; + var i; + + values = [ + 'beep', + 'boop', + null, + true, + false, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + var title = new Title({ // eslint-disable-line no-unused-vars + 'subtitlePadding': value + }); + }; + } +}); + +tape( 'the constructor returns an instance having a `subtitlePadding` property which throws an error if set to an invalid value', function test( t ) { + var values; + var i; + + values = [ + 'beep', + 'boop', + null, + true, + false, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + var title = new Title(); + title.subtitlePadding = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `subtitlePadding` property', function test( t ) { + var title; + + title = new Title(); + t.strictEqual( isUndefined( title.subtitlePadding ), true, 'returns expected value' ); + + title = new Title({ + 'subtitlePadding': 12 + }); + t.strictEqual( title.subtitlePadding, 12, 'returns expected value' ); + + title = new Title({ + 'subtitlePadding': 14 + }); + t.strictEqual( title.subtitlePadding, 14, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `subtitlePadding` property which can be set to a valid method', function test( t ) { + var title; + + title = new Title(); + + title.subtitlePadding = 12; + t.strictEqual( title.subtitlePadding, 12, 'returns expected value' ); + + title.subtitlePadding = 14; + t.strictEqual( title.subtitlePadding, 14, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `subtitlePadding` property is set to a new value', function test( t ) { + var title; + var count; + + title = new Title(); + count = 0; + + title.on( 'change', onChange ); + + title.subtitlePadding = 12; + t.strictEqual( count, 1, 'returns expected value' ); + + title.subtitlePadding = 14; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + title.subtitlePadding = 14; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/title/ctor/test/test.text.js b/lib/node_modules/@stdlib/plot/vega/title/ctor/test/test.text.js new file mode 100644 index 000000000000..6fb2d75e1cb9 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/title/ctor/test/test.text.js @@ -0,0 +1,165 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var hasProp = require( '@stdlib/assert/has-property' ); +var isSameArray = require( '@stdlib/assert/is-same-array' ); +var isEmptyArray = require( '@stdlib/assert/is-empty-array' ); +var Title = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Title, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `text` property', function test( t ) { + var v; + + v = new Title(); + t.strictEqual( hasOwnProp( v, 'text' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'text' ), true, 'returns expected value' ); + t.strictEqual( isEmptyArray( v.text ), true, 'returns expected value' ); + + v = new Title({ + 'text': 'foo bar' + }); + t.strictEqual( isSameArray( v.text, [ 'foo bar' ] ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor throws an error if provided an invalid `text` option', function test( t ) { + var values; + var i; + + values = [ + 5, + NaN, + null, + true, + false, + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + var title = new Title({ // eslint-disable-line no-unused-vars + 'text': value + }); + }; + } +}); + +tape( 'the constructor returns an instance having a `text` property which throws an error if set to an invalid value', function test( t ) { + var values; + var i; + + values = [ + 5, + NaN, + null, + true, + false, + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + var title = new Title(); + title.text = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `text` property', function test( t ) { + var title; + + title = new Title(); + t.strictEqual( isEmptyArray( title.text ), true, 'returns expected value' ); + + title = new Title({ + 'text': 'foo bar' + }); + t.strictEqual( isSameArray( title.text, [ 'foo bar' ] ), true, 'returns expected value' ); + + title = new Title({ + 'text': 'beep boop' + }); + t.strictEqual( isSameArray( title.text, [ 'beep boop' ] ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `text` property which can be set to a valid method', function test( t ) { + var title; + + title = new Title(); + + title.text = 'foo bar'; + t.strictEqual( isSameArray( title.text, [ 'foo bar' ] ), true, 'returns expected value' ); + + title.text = 'beep boop'; + t.strictEqual( isSameArray( title.text, [ 'beep boop' ] ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `text` property is set to a new value', function test( t ) { + var title; + var count; + + title = new Title(); + count = 0; + + title.on( 'change', onChange ); + + title.text = 'beep boop'; + t.strictEqual( count, 1, 'returns expected value' ); + + title.text = 'foo bar'; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + title.text = 'foo bar'; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/title/ctor/test/test.zindex.js b/lib/node_modules/@stdlib/plot/vega/title/ctor/test/test.zindex.js new file mode 100644 index 000000000000..77362a72ffb0 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/title/ctor/test/test.zindex.js @@ -0,0 +1,161 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var hasProp = require( '@stdlib/assert/has-property' ); +var isNumber = require( '@stdlib/assert/is-number' ); +var Title = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Title, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `zindex` property', function test( t ) { + var v; + + v = new Title(); + t.strictEqual( hasOwnProp( v, 'zindex' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'zindex' ), true, 'returns expected value' ); + t.strictEqual( isNumber( v.zindex ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor throws an error if provided an invalid `zindex` option', function test( t ) { + var values; + var i; + + values = [ + 'beep', + 'boop', + null, + true, + false, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + var title = new Title({ // eslint-disable-line no-unused-vars + 'zindex': value + }); + }; + } +}); + +tape( 'the constructor returns an instance having a `zindex` property which throws an error if set to an invalid value', function test( t ) { + var values; + var i; + + values = [ + 'beep', + 'boop', + null, + true, + false, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + var title = new Title(); + title.zindex = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `zindex` property', function test( t ) { + var title; + + title = new Title(); + t.strictEqual( title.zindex, 0, 'returns expected value' ); + + title = new Title({ + 'zindex': 2 + }); + t.strictEqual( title.zindex, 2, 'returns expected value' ); + + title = new Title({ + 'zindex': 4 + }); + t.strictEqual( title.zindex, 4, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `zindex` property which can be set to a valid method', function test( t ) { + var title; + + title = new Title(); + + title.zindex = 2; + t.strictEqual( title.zindex, 2, 'returns expected value' ); + + title.zindex = 4; + t.strictEqual( title.zindex, 4, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `zindex` property is set to a new value', function test( t ) { + var title; + var count; + + title = new Title(); + count = 0; + + title.on( 'change', onChange ); + + title.zindex = 2; + t.strictEqual( count, 1, 'returns expected value' ); + + title.zindex = 4; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + title.zindex = 4; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +});