From 81f0ba986fbef9068b38a955db73a57529a61c69 Mon Sep 17 00:00:00 2001 From: Sachinn-64 Date: Mon, 6 Jul 2026 23:44:25 +0530 Subject: [PATCH] test: add tests for Legend constructor and properties --- .../plot/vega/legend/ctor/test/test.aria.js | 144 + .../vega/legend/ctor/test/test.clip_height.js | 146 + .../legend/ctor/test/test.column_padding.js | 144 + .../vega/legend/ctor/test/test.columns.js | 138 + .../legend/ctor/test/test.corner_radius.js | 146 + .../vega/legend/ctor/test/test.description.js | 145 + .../vega/legend/ctor/test/test.direction.js | 141 + .../plot/vega/legend/ctor/test/test.encode.js | 142 + .../plot/vega/legend/ctor/test/test.fill.js | 136 + .../vega/legend/ctor/test/test.fill_color.js | 145 + .../plot/vega/legend/ctor/test/test.format.js | 150 + .../vega/legend/ctor/test/test.format_type.js | 146 + .../legend/ctor/test/test.gradient_length.js | 146 + .../legend/ctor/test/test.gradient_opacity.js | 144 + .../ctor/test/test.gradient_stroke_color.js | 145 + .../ctor/test/test.gradient_stroke_width.js | 146 + .../ctor/test/test.gradient_thickness.js | 146 + .../vega/legend/ctor/test/test.grid_align.js | 144 + .../plot/vega/legend/ctor/test/test.js | 2446 +++++++++++++++++ .../vega/legend/ctor/test/test.label_align.js | 145 + .../legend/ctor/test/test.label_baseline.js | 140 + .../vega/legend/ctor/test/test.label_color.js | 145 + .../vega/legend/ctor/test/test.label_font.js | 145 + .../legend/ctor/test/test.label_font_size.js | 146 + .../legend/ctor/test/test.label_font_style.js | 145 + .../ctor/test/test.label_font_weight.js | 199 ++ .../vega/legend/ctor/test/test.label_limit.js | 146 + .../legend/ctor/test/test.label_offset.js | 144 + .../legend/ctor/test/test.label_opacity.js | 144 + .../legend/ctor/test/test.label_overlap.js | 161 ++ .../legend/ctor/test/test.label_separation.js | 140 + .../vega/legend/ctor/test/test.legend_x.js | 144 + .../vega/legend/ctor/test/test.legend_y.js | 144 + .../plot/vega/legend/ctor/test/test.offset.js | 144 + .../vega/legend/ctor/test/test.opacity.js | 145 + .../plot/vega/legend/ctor/test/test.orient.js | 151 + .../vega/legend/ctor/test/test.padding.js | 144 + .../vega/legend/ctor/test/test.properties.js | 156 ++ .../vega/legend/ctor/test/test.row_padding.js | 144 + .../plot/vega/legend/ctor/test/test.shape.js | 145 + .../plot/vega/legend/ctor/test/test.size.js | 145 + .../plot/vega/legend/ctor/test/test.stroke.js | 145 + .../legend/ctor/test/test.stroke_color.js | 145 + .../vega/legend/ctor/test/test.stroke_dash.js | 145 + .../legend/ctor/test/test.stroke_width.js | 145 + .../vega/legend/ctor/test/test.symbol_dash.js | 139 + .../ctor/test/test.symbol_dash_offset.js | 144 + .../ctor/test/test.symbol_fill_color.js | 145 + .../legend/ctor/test/test.symbol_limit.js | 144 + .../legend/ctor/test/test.symbol_offset.js | 144 + .../legend/ctor/test/test.symbol_opacity.js | 144 + .../vega/legend/ctor/test/test.symbol_size.js | 146 + .../ctor/test/test.symbol_stroke_color.js | 145 + .../ctor/test/test.symbol_stroke_width.js | 146 + .../vega/legend/ctor/test/test.symbol_type.js | 146 + .../vega/legend/ctor/test/test.tick_count.js | 163 ++ .../legend/ctor/test/test.tick_min_step.js | 144 + .../plot/vega/legend/ctor/test/test.title.js | 145 + .../vega/legend/ctor/test/test.title_align.js | 146 + .../legend/ctor/test/test.title_anchor.js | 145 + .../legend/ctor/test/test.title_baseline.js | 140 + .../vega/legend/ctor/test/test.title_color.js | 145 + .../vega/legend/ctor/test/test.title_font.js | 145 + .../legend/ctor/test/test.title_font_size.js | 146 + .../legend/ctor/test/test.title_font_style.js | 145 + .../ctor/test/test.title_font_weight.js | 199 ++ .../vega/legend/ctor/test/test.title_limit.js | 146 + .../ctor/test/test.title_line_height.js | 146 + .../legend/ctor/test/test.title_opacity.js | 144 + .../legend/ctor/test/test.title_orient.js | 144 + .../legend/ctor/test/test.title_padding.js | 144 + .../plot/vega/legend/ctor/test/test.type.js | 146 + .../plot/vega/legend/ctor/test/test.values.js | 143 + .../plot/vega/legend/ctor/test/test.zindex.js | 138 + 74 files changed, 13139 insertions(+) create mode 100644 lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.aria.js create mode 100644 lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.clip_height.js create mode 100644 lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.column_padding.js create mode 100644 lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.columns.js create mode 100644 lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.corner_radius.js create mode 100644 lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.description.js create mode 100644 lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.direction.js create mode 100644 lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.encode.js create mode 100644 lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.fill.js create mode 100644 lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.fill_color.js create mode 100644 lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.format.js create mode 100644 lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.format_type.js create mode 100644 lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.gradient_length.js create mode 100644 lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.gradient_opacity.js create mode 100644 lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.gradient_stroke_color.js create mode 100644 lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.gradient_stroke_width.js create mode 100644 lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.gradient_thickness.js create mode 100644 lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.grid_align.js create mode 100644 lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.js create mode 100644 lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.label_align.js create mode 100644 lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.label_baseline.js create mode 100644 lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.label_color.js create mode 100644 lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.label_font.js create mode 100644 lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.label_font_size.js create mode 100644 lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.label_font_style.js create mode 100644 lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.label_font_weight.js create mode 100644 lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.label_limit.js create mode 100644 lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.label_offset.js create mode 100644 lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.label_opacity.js create mode 100644 lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.label_overlap.js create mode 100644 lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.label_separation.js create mode 100644 lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.legend_x.js create mode 100644 lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.legend_y.js create mode 100644 lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.offset.js create mode 100644 lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.opacity.js create mode 100644 lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.orient.js create mode 100644 lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.padding.js create mode 100644 lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.properties.js create mode 100644 lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.row_padding.js create mode 100644 lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.shape.js create mode 100644 lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.size.js create mode 100644 lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.stroke.js create mode 100644 lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.stroke_color.js create mode 100644 lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.stroke_dash.js create mode 100644 lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.stroke_width.js create mode 100644 lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.symbol_dash.js create mode 100644 lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.symbol_dash_offset.js create mode 100644 lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.symbol_fill_color.js create mode 100644 lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.symbol_limit.js create mode 100644 lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.symbol_offset.js create mode 100644 lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.symbol_opacity.js create mode 100644 lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.symbol_size.js create mode 100644 lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.symbol_stroke_color.js create mode 100644 lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.symbol_stroke_width.js create mode 100644 lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.symbol_type.js create mode 100644 lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.tick_count.js create mode 100644 lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.tick_min_step.js create mode 100644 lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.title.js create mode 100644 lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.title_align.js create mode 100644 lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.title_anchor.js create mode 100644 lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.title_baseline.js create mode 100644 lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.title_color.js create mode 100644 lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.title_font.js create mode 100644 lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.title_font_size.js create mode 100644 lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.title_font_style.js create mode 100644 lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.title_font_weight.js create mode 100644 lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.title_limit.js create mode 100644 lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.title_line_height.js create mode 100644 lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.title_opacity.js create mode 100644 lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.title_orient.js create mode 100644 lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.title_padding.js create mode 100644 lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.type.js create mode 100644 lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.values.js create mode 100644 lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.zindex.js diff --git a/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.aria.js b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.aria.js new file mode 100644 index 000000000000..02a5fa036d6e --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.aria.js @@ -0,0 +1,144 @@ +/** +* @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' ).isPrimitive; +var Legend = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Legend, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has an `aria` property', function test( t ) { + var v; + + v = new Legend({ + 'fill': 'colorScale' + }); + 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 returns an instance having an `aria` property which throws an error if set to an invalid 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 legend = new Legend({ + 'fill': 'colorScale' + }); + legend.aria = value; + }; + } +}); + +tape( 'the constructor returns an instance having an `aria` property', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( legend.aria, true, 'returns expected value' ); + + legend = new Legend({ + 'fill': 'colorScale', + 'aria': false + }); + t.strictEqual( legend.aria, false, 'returns expected value' ); + + legend = new Legend({ + 'fill': 'colorScale', + 'aria': true + }); + t.strictEqual( legend.aria, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having an `aria` property which can be set to a boolean', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + + legend.aria = false; + t.strictEqual( legend.aria, false, 'returns expected value' ); + + legend.aria = true; + t.strictEqual( legend.aria, true, '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 count; + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + count = 0; + + legend.on( 'change', onChange ); + + legend.aria = false; + t.strictEqual( count, 1, 'returns expected value' ); + + legend.aria = true; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + legend.aria = true; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.clip_height.js b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.clip_height.js new file mode 100644 index 000000000000..f5784c2b054b --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.clip_height.js @@ -0,0 +1,146 @@ +/** +* @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 isUndefined = require( '@stdlib/assert/is-undefined' ); +var isNonNegativeNumber = require( '@stdlib/assert/is-nonnegative-number' ).isPrimitive; +var Legend = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Legend, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `clipHeight` property', function test( t ) { + var v; + + v = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( hasOwnProp( v, 'clipHeight' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'clipHeight' ), true, 'returns expected value' ); + t.strictEqual( isUndefined( v.clipHeight ), true, 'returns expected value' ); + + v = new Legend({ + 'fill': 'colorScale', + 'clipHeight': 10 + }); + t.strictEqual( isNonNegativeNumber( v.clipHeight ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the constructor returns an instance having a `clipHeight` property which throws an error if set to an invalid value', function test( t ) { + var values; + var i; + + values = [ + 'beep', + -1, + 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 legend = new Legend({ + 'fill': 'colorScale' + }); + legend.clipHeight = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `clipHeight` property', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( isUndefined( legend.clipHeight ), true, 'returns expected value' ); + + legend = new Legend({ + 'fill': 'colorScale', + 'clipHeight': 10 + }); + t.strictEqual( legend.clipHeight, 10, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `clipHeight` property which can be set to a valid value', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + + legend.clipHeight = 10; + t.strictEqual( legend.clipHeight, 10, 'returns expected value' ); + + legend.clipHeight = 20; + t.strictEqual( legend.clipHeight, 20, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `clipHeight` property is set to a new value', function test( t ) { + var count; + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + count = 0; + + legend.on( 'change', onChange ); + + legend.clipHeight = 10; + t.strictEqual( count, 1, 'returns expected value' ); + + legend.clipHeight = 20; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + legend.clipHeight = 20; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.column_padding.js b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.column_padding.js new file mode 100644 index 000000000000..996d614d2358 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.column_padding.js @@ -0,0 +1,144 @@ +/** +* @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 isUndefined = require( '@stdlib/assert/is-undefined' ); +var isNumber = require( '@stdlib/assert/is-number' ).isPrimitive; +var Legend = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Legend, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `columnPadding` property', function test( t ) { + var v; + + v = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( hasOwnProp( v, 'columnPadding' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'columnPadding' ), true, 'returns expected value' ); + t.strictEqual( isUndefined( v.columnPadding ), true, 'returns expected value' ); + + v = new Legend({ + 'fill': 'colorScale', + 'columnPadding': 10 + }); + t.strictEqual( isNumber( v.columnPadding ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the constructor returns an instance having a `columnPadding` property which throws an error if set to an invalid value', function test( t ) { + var values; + var i; + + values = [ + 'beep', + 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 legend = new Legend({ + 'fill': 'colorScale' + }); + legend.columnPadding = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `columnPadding` property', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( isUndefined( legend.columnPadding ), true, 'returns expected value' ); + + legend = new Legend({ + 'fill': 'colorScale', + 'columnPadding': 10 + }); + t.strictEqual( legend.columnPadding, 10, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `columnPadding` property which can be set to a valid value', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + + legend.columnPadding = 10; + t.strictEqual( legend.columnPadding, 10, 'returns expected value' ); + + legend.columnPadding = 20; + t.strictEqual( legend.columnPadding, 20, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `columnPadding` property is set to a new value', function test( t ) { + var count; + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + count = 0; + + legend.on( 'change', onChange ); + + legend.columnPadding = 10; + t.strictEqual( count, 1, 'returns expected value' ); + + legend.columnPadding = 20; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + legend.columnPadding = 20; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.columns.js b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.columns.js new file mode 100644 index 000000000000..01f1e6bfb947 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.columns.js @@ -0,0 +1,138 @@ +/** +* @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' ).isPrimitive; +var Legend = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Legend, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `columns` property', function test( t ) { + var v; + + v = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( hasOwnProp( v, 'columns' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'columns' ), true, 'returns expected value' ); + t.strictEqual( isNumber( v.columns ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the constructor returns an instance having a `columns` property which throws an error if set to an invalid value', function test( t ) { + var values; + var i; + + values = [ + 'beep', + 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 legend = new Legend({ + 'fill': 'colorScale' + }); + legend.columns = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `columns` property', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( legend.columns, 1, 'returns expected value' ); + + legend = new Legend({ + 'fill': 'colorScale', + 'columns': 3 + }); + t.strictEqual( legend.columns, 3, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `columns` property which can be set to a valid value', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + + legend.columns = 2; + t.strictEqual( legend.columns, 2, 'returns expected value' ); + + legend.columns = 3; + t.strictEqual( legend.columns, 3, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `columns` property is set to a new value', function test( t ) { + var count; + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + count = 0; + + legend.on( 'change', onChange ); + + legend.columns = 2; + t.strictEqual( count, 1, 'returns expected value' ); + + legend.columns = 3; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + legend.columns = 3; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.corner_radius.js b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.corner_radius.js new file mode 100644 index 000000000000..375abc2aac9d --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.corner_radius.js @@ -0,0 +1,146 @@ +/** +* @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 isUndefined = require( '@stdlib/assert/is-undefined' ); +var isNonNegativeNumber = require( '@stdlib/assert/is-nonnegative-number' ).isPrimitive; +var Legend = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Legend, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `cornerRadius` property', function test( t ) { + var v; + + v = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( hasOwnProp( v, 'cornerRadius' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'cornerRadius' ), true, 'returns expected value' ); + t.strictEqual( isUndefined( v.cornerRadius ), true, 'returns expected value' ); + + v = new Legend({ + 'fill': 'colorScale', + 'cornerRadius': 10 + }); + t.strictEqual( isNonNegativeNumber( v.cornerRadius ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the constructor returns an instance having a `cornerRadius` property which throws an error if set to an invalid value', function test( t ) { + var values; + var i; + + values = [ + 'beep', + -1, + 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 legend = new Legend({ + 'fill': 'colorScale' + }); + legend.cornerRadius = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `cornerRadius` property', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( isUndefined( legend.cornerRadius ), true, 'returns expected value' ); + + legend = new Legend({ + 'fill': 'colorScale', + 'cornerRadius': 10 + }); + t.strictEqual( legend.cornerRadius, 10, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `cornerRadius` property which can be set to a valid value', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + + legend.cornerRadius = 10; + t.strictEqual( legend.cornerRadius, 10, 'returns expected value' ); + + legend.cornerRadius = 20; + t.strictEqual( legend.cornerRadius, 20, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `cornerRadius` property is set to a new value', function test( t ) { + var count; + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + count = 0; + + legend.on( 'change', onChange ); + + legend.cornerRadius = 10; + t.strictEqual( count, 1, 'returns expected value' ); + + legend.cornerRadius = 20; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + legend.cornerRadius = 20; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.description.js b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.description.js new file mode 100644 index 000000000000..13d988a2f6f1 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.description.js @@ -0,0 +1,145 @@ +/** +* @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 isUndefined = require( '@stdlib/assert/is-undefined' ); +var isString = require( '@stdlib/assert/is-string' ).isPrimitive; +var Legend = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Legend, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `description` property', function test( t ) { + var v; + + v = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( hasOwnProp( v, 'description' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'description' ), true, 'returns expected value' ); + t.strictEqual( isUndefined( v.description ), true, 'returns expected value' ); + + v = new Legend({ + 'fill': 'colorScale', + 'description': 'A legend' + }); + t.strictEqual( isString( v.description ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the constructor returns an instance having a `description` 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 legend = new Legend({ + 'fill': 'colorScale' + }); + legend.description = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `description` property', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( isUndefined( legend.description ), true, 'returns expected value' ); + + legend = new Legend({ + 'fill': 'colorScale', + 'description': 'A legend' + }); + t.strictEqual( legend.description, 'A legend', 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `description` property which can be set to a string', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + + legend.description = 'A legend'; + t.strictEqual( legend.description, 'A legend', 'returns expected value' ); + + legend.description = 'Another legend'; + t.strictEqual( legend.description, 'Another legend', 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `description` property is set to a new value', function test( t ) { + var count; + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + count = 0; + + legend.on( 'change', onChange ); + + legend.description = 'A legend'; + t.strictEqual( count, 1, 'returns expected value' ); + + legend.description = 'Another legend'; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + legend.description = 'Another legend'; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.direction.js b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.direction.js new file mode 100644 index 000000000000..c417f3f78ecd --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.direction.js @@ -0,0 +1,141 @@ +/** +* @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' ).isPrimitive; +var Legend = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Legend, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `direction` property', function test( t ) { + var v; + + v = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( hasOwnProp( v, 'direction' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'direction' ), true, 'returns expected value' ); + t.strictEqual( isString( v.direction ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the constructor returns an instance having a `direction` property which throws an error if set to an invalid value', function test( t ) { + var values; + var i; + + values = [ + 'beep', + 'boop', + 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 legend = new Legend({ + 'fill': 'colorScale' + }); + legend.direction = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `direction` property', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( legend.direction, 'vertical', 'returns expected value' ); + + legend = new Legend({ + 'fill': 'colorScale', + 'direction': 'horizontal' + }); + t.strictEqual( legend.direction, 'horizontal', 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `direction` property which can be set to a valid direction', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + + legend.direction = 'horizontal'; + t.strictEqual( legend.direction, 'horizontal', 'returns expected value' ); + + legend.direction = 'vertical'; + t.strictEqual( legend.direction, 'vertical', 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `direction` property is set to a new value', function test( t ) { + var count; + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + count = 0; + + legend.on( 'change', onChange ); + + legend.direction = 'horizontal'; + t.strictEqual( count, 1, 'returns expected value' ); + + legend.direction = 'vertical'; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + legend.direction = 'vertical'; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.encode.js b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.encode.js new file mode 100644 index 000000000000..67f176a77017 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.encode.js @@ -0,0 +1,142 @@ +/** +* @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 isUndefined = require( '@stdlib/assert/is-undefined' ); +var isObject = require( '@stdlib/assert/is-object' ); +var Legend = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Legend, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has an `encode` property', function test( t ) { + var v; + + v = new Legend({ + 'fill': 'colorScale' + }); + 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 Legend({ + 'fill': 'colorScale', + 'encode': { 'labels': {} } + }); + t.strictEqual( isObject( v.encode ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the constructor returns an instance having an `encode` property which throws an error if set to an invalid value', function test( t ) { + var values; + var i; + + values = [ + 'beep', + 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 legend = new Legend({ + 'fill': 'colorScale' + }); + legend.encode = value; + }; + } +}); + +tape( 'the constructor returns an instance having an `encode` property', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( isUndefined( legend.encode ), true, 'returns expected value' ); + + legend = new Legend({ + 'fill': 'colorScale', + 'encode': { 'labels': {} } + }); + t.deepEqual( legend.encode, { 'labels': {} }, 'returns expected value' ); + t.end(); +}); + +tape( 'the constructor returns an instance having an `encode` property which can be set to a valid value', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + + legend.encode = { 'labels': {} }; + t.deepEqual( legend.encode, { 'labels': {} }, 'returns expected value' ); + + legend.encode = { 'symbols': {} }; + t.deepEqual( legend.encode, { 'symbols': {} }, '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 count; + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + count = 0; + + legend.on( 'change', onChange ); + + legend.encode = { 'labels': {} }; + t.strictEqual( count, 1, 'returns expected value' ); + + legend.encode = { 'symbols': {} }; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to a different object always emits since objects are compared by reference: + legend.encode = { 'symbols': {} }; + t.strictEqual( count, 3, 'returns expected value' ); + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.fill.js b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.fill.js new file mode 100644 index 000000000000..903a6d27b369 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.fill.js @@ -0,0 +1,136 @@ +/** +* @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' ).isPrimitive; +var Legend = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Legend, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `fill` property', function test( t ) { + var v; + + v = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( hasOwnProp( v, 'fill' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'fill' ), true, 'returns expected value' ); + t.strictEqual( isString( v.fill ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the constructor returns an instance having a `fill` 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 legend = new Legend({ + 'fill': 'colorScale' + }); + legend.fill = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `fill` property', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( legend.fill, 'colorScale', 'returns expected value' ); + + legend = new Legend({ + 'fill': 'anotherScale' + }); + t.strictEqual( legend.fill, 'anotherScale', 'returns expected value' ); + t.end(); +}); + +tape( 'the constructor returns an instance having a `fill` property which can be set to a string', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + + legend.fill = 'beep'; + t.strictEqual( legend.fill, 'beep', 'returns expected value' ); + + legend.fill = 'boop'; + t.strictEqual( legend.fill, 'boop', 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `fill` property is set to a new value', function test( t ) { + var count; + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + count = 0; + + legend.on( 'change', onChange ); + + legend.fill = 'beep'; + t.strictEqual( count, 1, 'returns expected value' ); + + legend.fill = 'boop'; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + legend.fill = 'boop'; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.fill_color.js b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.fill_color.js new file mode 100644 index 000000000000..d1b121d46b0c --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.fill_color.js @@ -0,0 +1,145 @@ +/** +* @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 isUndefined = require( '@stdlib/assert/is-undefined' ); +var isString = require( '@stdlib/assert/is-string' ).isPrimitive; +var Legend = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Legend, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `fillColor` property', function test( t ) { + var v; + + v = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( hasOwnProp( v, 'fillColor' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'fillColor' ), true, 'returns expected value' ); + t.strictEqual( isUndefined( v.fillColor ), true, 'returns expected value' ); + + v = new Legend({ + 'fill': 'colorScale', + 'fillColor': 'beep' + }); + t.strictEqual( isString( v.fillColor ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the constructor returns an instance having a `fillColor` 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 legend = new Legend({ + 'fill': 'colorScale' + }); + legend.fillColor = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `fillColor` property', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( isUndefined( legend.fillColor ), true, 'returns expected value' ); + + legend = new Legend({ + 'fill': 'colorScale', + 'fillColor': 'testValue' + }); + t.strictEqual( legend.fillColor, 'testValue', 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `fillColor` property which can be set to a string', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + + legend.fillColor = 'beep'; + t.strictEqual( legend.fillColor, 'beep', 'returns expected value' ); + + legend.fillColor = 'boop'; + t.strictEqual( legend.fillColor, 'boop', 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `fillColor` property is set to a new value', function test( t ) { + var count; + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + count = 0; + + legend.on( 'change', onChange ); + + legend.fillColor = 'beep'; + t.strictEqual( count, 1, 'returns expected value' ); + + legend.fillColor = 'boop'; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + legend.fillColor = 'boop'; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.format.js b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.format.js new file mode 100644 index 000000000000..193eed845170 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.format.js @@ -0,0 +1,150 @@ +/** +* @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 isUndefined = require( '@stdlib/assert/is-undefined' ); +var isString = require( '@stdlib/assert/is-string' ).isPrimitive; +var isObject = require( '@stdlib/assert/is-object' ); +var Legend = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Legend, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `format` property', function test( t ) { + var v; + + v = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( hasOwnProp( v, 'format' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'format' ), true, 'returns expected value' ); + t.strictEqual( isUndefined( v.format ), true, 'returns expected value' ); + + v = new Legend({ + 'fill': 'colorScale', + 'format': '.1f' + }); + t.strictEqual( isString( v.format ), true, 'returns expected value' ); + + v = new Legend({ + 'fill': 'colorScale', + 'format': { 'year': '%Y' } + }); + t.strictEqual( isObject( v.format ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the constructor returns an instance having a `format` 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 legend = new Legend({ + 'fill': 'colorScale' + }); + legend.format = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `format` property', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( isUndefined( legend.format ), true, 'returns expected value' ); + + legend = new Legend({ + 'fill': 'colorScale', + 'format': '.1f' + }); + t.strictEqual( legend.format, '.1f', 'returns expected value' ); + t.end(); +}); + +tape( 'the constructor returns an instance having a `format` property which can be set to a valid value', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + + legend.format = '.1f'; + t.strictEqual( legend.format, '.1f', 'returns expected value' ); + + legend.format = '.2f'; + t.strictEqual( legend.format, '.2f', 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `format` property is set to a new value', function test( t ) { + var count; + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + count = 0; + + legend.on( 'change', onChange ); + + legend.format = '.1f'; + t.strictEqual( count, 1, 'returns expected value' ); + + legend.format = '.2f'; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + legend.format = '.2f'; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.format_type.js b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.format_type.js new file mode 100644 index 000000000000..79ecb87e1677 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.format_type.js @@ -0,0 +1,146 @@ +/** +* @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 isUndefined = require( '@stdlib/assert/is-undefined' ); +var isString = require( '@stdlib/assert/is-string' ).isPrimitive; +var Legend = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Legend, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `formatType` property', function test( t ) { + var v; + + v = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( hasOwnProp( v, 'formatType' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'formatType' ), true, 'returns expected value' ); + t.strictEqual( isUndefined( v.formatType ), true, 'returns expected value' ); + + v = new Legend({ + 'fill': 'colorScale', + 'formatType': 'number' + }); + t.strictEqual( isString( v.formatType ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the constructor returns an instance having a `formatType` property which throws an error if set to an invalid value', function test( t ) { + var values; + var i; + + values = [ + 'beep', + 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 legend = new Legend({ + 'fill': 'colorScale' + }); + legend.formatType = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `formatType` property', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( isUndefined( legend.formatType ), true, 'returns expected value' ); + + legend = new Legend({ + 'fill': 'colorScale', + 'formatType': 'number' + }); + t.strictEqual( legend.formatType, 'number', 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `formatType` property which can be set to a valid value', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + + legend.formatType = 'number'; + t.strictEqual( legend.formatType, 'number', 'returns expected value' ); + + legend.formatType = 'time'; + t.strictEqual( legend.formatType, 'time', 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `formatType` property is set to a new value', function test( t ) { + var count; + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + count = 0; + + legend.on( 'change', onChange ); + + legend.formatType = 'number'; + t.strictEqual( count, 1, 'returns expected value' ); + + legend.formatType = 'time'; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + legend.formatType = 'time'; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.gradient_length.js b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.gradient_length.js new file mode 100644 index 000000000000..7b25a878af31 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.gradient_length.js @@ -0,0 +1,146 @@ +/** +* @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 isUndefined = require( '@stdlib/assert/is-undefined' ); +var isNonNegativeNumber = require( '@stdlib/assert/is-nonnegative-number' ).isPrimitive; +var Legend = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Legend, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `gradientLength` property', function test( t ) { + var v; + + v = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( hasOwnProp( v, 'gradientLength' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'gradientLength' ), true, 'returns expected value' ); + t.strictEqual( isUndefined( v.gradientLength ), true, 'returns expected value' ); + + v = new Legend({ + 'fill': 'colorScale', + 'gradientLength': 10 + }); + t.strictEqual( isNonNegativeNumber( v.gradientLength ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the constructor returns an instance having a `gradientLength` property which throws an error if set to an invalid value', function test( t ) { + var values; + var i; + + values = [ + 'beep', + -1, + 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 legend = new Legend({ + 'fill': 'colorScale' + }); + legend.gradientLength = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `gradientLength` property', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( isUndefined( legend.gradientLength ), true, 'returns expected value' ); + + legend = new Legend({ + 'fill': 'colorScale', + 'gradientLength': 10 + }); + t.strictEqual( legend.gradientLength, 10, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `gradientLength` property which can be set to a valid value', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + + legend.gradientLength = 10; + t.strictEqual( legend.gradientLength, 10, 'returns expected value' ); + + legend.gradientLength = 20; + t.strictEqual( legend.gradientLength, 20, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `gradientLength` property is set to a new value', function test( t ) { + var count; + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + count = 0; + + legend.on( 'change', onChange ); + + legend.gradientLength = 10; + t.strictEqual( count, 1, 'returns expected value' ); + + legend.gradientLength = 20; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + legend.gradientLength = 20; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.gradient_opacity.js b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.gradient_opacity.js new file mode 100644 index 000000000000..bd636532d1bf --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.gradient_opacity.js @@ -0,0 +1,144 @@ +/** +* @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 isUndefined = require( '@stdlib/assert/is-undefined' ); +var isNumber = require( '@stdlib/assert/is-number' ).isPrimitive; +var Legend = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Legend, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `gradientOpacity` property', function test( t ) { + var v; + + v = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( hasOwnProp( v, 'gradientOpacity' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'gradientOpacity' ), true, 'returns expected value' ); + t.strictEqual( isUndefined( v.gradientOpacity ), true, 'returns expected value' ); + + v = new Legend({ + 'fill': 'colorScale', + 'gradientOpacity': 10 + }); + t.strictEqual( isNumber( v.gradientOpacity ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the constructor returns an instance having a `gradientOpacity` property which throws an error if set to an invalid value', function test( t ) { + var values; + var i; + + values = [ + 'beep', + 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 legend = new Legend({ + 'fill': 'colorScale' + }); + legend.gradientOpacity = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `gradientOpacity` property', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( isUndefined( legend.gradientOpacity ), true, 'returns expected value' ); + + legend = new Legend({ + 'fill': 'colorScale', + 'gradientOpacity': 10 + }); + t.strictEqual( legend.gradientOpacity, 10, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `gradientOpacity` property which can be set to a valid value', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + + legend.gradientOpacity = 10; + t.strictEqual( legend.gradientOpacity, 10, 'returns expected value' ); + + legend.gradientOpacity = 20; + t.strictEqual( legend.gradientOpacity, 20, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `gradientOpacity` property is set to a new value', function test( t ) { + var count; + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + count = 0; + + legend.on( 'change', onChange ); + + legend.gradientOpacity = 10; + t.strictEqual( count, 1, 'returns expected value' ); + + legend.gradientOpacity = 20; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + legend.gradientOpacity = 20; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.gradient_stroke_color.js b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.gradient_stroke_color.js new file mode 100644 index 000000000000..5335ecd99626 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.gradient_stroke_color.js @@ -0,0 +1,145 @@ +/** +* @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 isUndefined = require( '@stdlib/assert/is-undefined' ); +var isString = require( '@stdlib/assert/is-string' ).isPrimitive; +var Legend = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Legend, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `gradientStrokeColor` property', function test( t ) { + var v; + + v = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( hasOwnProp( v, 'gradientStrokeColor' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'gradientStrokeColor' ), true, 'returns expected value' ); + t.strictEqual( isUndefined( v.gradientStrokeColor ), true, 'returns expected value' ); + + v = new Legend({ + 'fill': 'colorScale', + 'gradientStrokeColor': 'beep' + }); + t.strictEqual( isString( v.gradientStrokeColor ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the constructor returns an instance having a `gradientStrokeColor` 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 legend = new Legend({ + 'fill': 'colorScale' + }); + legend.gradientStrokeColor = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `gradientStrokeColor` property', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( isUndefined( legend.gradientStrokeColor ), true, 'returns expected value' ); + + legend = new Legend({ + 'fill': 'colorScale', + 'gradientStrokeColor': 'testValue' + }); + t.strictEqual( legend.gradientStrokeColor, 'testValue', 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `gradientStrokeColor` property which can be set to a string', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + + legend.gradientStrokeColor = 'beep'; + t.strictEqual( legend.gradientStrokeColor, 'beep', 'returns expected value' ); + + legend.gradientStrokeColor = 'boop'; + t.strictEqual( legend.gradientStrokeColor, 'boop', 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `gradientStrokeColor` property is set to a new value', function test( t ) { + var count; + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + count = 0; + + legend.on( 'change', onChange ); + + legend.gradientStrokeColor = 'beep'; + t.strictEqual( count, 1, 'returns expected value' ); + + legend.gradientStrokeColor = 'boop'; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + legend.gradientStrokeColor = 'boop'; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.gradient_stroke_width.js b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.gradient_stroke_width.js new file mode 100644 index 000000000000..a6b2b5abb277 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.gradient_stroke_width.js @@ -0,0 +1,146 @@ +/** +* @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 isUndefined = require( '@stdlib/assert/is-undefined' ); +var isNonNegativeNumber = require( '@stdlib/assert/is-nonnegative-number' ).isPrimitive; +var Legend = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Legend, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `gradientStrokeWidth` property', function test( t ) { + var v; + + v = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( hasOwnProp( v, 'gradientStrokeWidth' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'gradientStrokeWidth' ), true, 'returns expected value' ); + t.strictEqual( isUndefined( v.gradientStrokeWidth ), true, 'returns expected value' ); + + v = new Legend({ + 'fill': 'colorScale', + 'gradientStrokeWidth': 10 + }); + t.strictEqual( isNonNegativeNumber( v.gradientStrokeWidth ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the constructor returns an instance having a `gradientStrokeWidth` property which throws an error if set to an invalid value', function test( t ) { + var values; + var i; + + values = [ + 'beep', + -1, + 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 legend = new Legend({ + 'fill': 'colorScale' + }); + legend.gradientStrokeWidth = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `gradientStrokeWidth` property', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( isUndefined( legend.gradientStrokeWidth ), true, 'returns expected value' ); + + legend = new Legend({ + 'fill': 'colorScale', + 'gradientStrokeWidth': 10 + }); + t.strictEqual( legend.gradientStrokeWidth, 10, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `gradientStrokeWidth` property which can be set to a valid value', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + + legend.gradientStrokeWidth = 10; + t.strictEqual( legend.gradientStrokeWidth, 10, 'returns expected value' ); + + legend.gradientStrokeWidth = 20; + t.strictEqual( legend.gradientStrokeWidth, 20, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `gradientStrokeWidth` property is set to a new value', function test( t ) { + var count; + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + count = 0; + + legend.on( 'change', onChange ); + + legend.gradientStrokeWidth = 10; + t.strictEqual( count, 1, 'returns expected value' ); + + legend.gradientStrokeWidth = 20; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + legend.gradientStrokeWidth = 20; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.gradient_thickness.js b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.gradient_thickness.js new file mode 100644 index 000000000000..88648a00da78 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.gradient_thickness.js @@ -0,0 +1,146 @@ +/** +* @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 isUndefined = require( '@stdlib/assert/is-undefined' ); +var isNonNegativeNumber = require( '@stdlib/assert/is-nonnegative-number' ).isPrimitive; +var Legend = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Legend, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `gradientThickness` property', function test( t ) { + var v; + + v = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( hasOwnProp( v, 'gradientThickness' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'gradientThickness' ), true, 'returns expected value' ); + t.strictEqual( isUndefined( v.gradientThickness ), true, 'returns expected value' ); + + v = new Legend({ + 'fill': 'colorScale', + 'gradientThickness': 10 + }); + t.strictEqual( isNonNegativeNumber( v.gradientThickness ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the constructor returns an instance having a `gradientThickness` property which throws an error if set to an invalid value', function test( t ) { + var values; + var i; + + values = [ + 'beep', + -1, + 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 legend = new Legend({ + 'fill': 'colorScale' + }); + legend.gradientThickness = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `gradientThickness` property', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( isUndefined( legend.gradientThickness ), true, 'returns expected value' ); + + legend = new Legend({ + 'fill': 'colorScale', + 'gradientThickness': 10 + }); + t.strictEqual( legend.gradientThickness, 10, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `gradientThickness` property which can be set to a valid value', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + + legend.gradientThickness = 10; + t.strictEqual( legend.gradientThickness, 10, 'returns expected value' ); + + legend.gradientThickness = 20; + t.strictEqual( legend.gradientThickness, 20, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `gradientThickness` property is set to a new value', function test( t ) { + var count; + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + count = 0; + + legend.on( 'change', onChange ); + + legend.gradientThickness = 10; + t.strictEqual( count, 1, 'returns expected value' ); + + legend.gradientThickness = 20; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + legend.gradientThickness = 20; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.grid_align.js b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.grid_align.js new file mode 100644 index 000000000000..450f196b8b9f --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.grid_align.js @@ -0,0 +1,144 @@ +/** +* @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' ).isPrimitive; +var Legend = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Legend, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `gridAlign` property', function test( t ) { + var v; + + v = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( hasOwnProp( v, 'gridAlign' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'gridAlign' ), true, 'returns expected value' ); + t.strictEqual( isString( v.gridAlign ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the constructor returns an instance having a `gridAlign` property which throws an error if set to an invalid value', function test( t ) { + var values; + var i; + + values = [ + 'beep', + 'boop', + 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 legend = new Legend({ + 'fill': 'colorScale' + }); + legend.gridAlign = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `gridAlign` property', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( legend.gridAlign, 'each', 'returns expected value' ); + + legend = new Legend({ + 'fill': 'colorScale', + 'gridAlign': 'all' + }); + t.strictEqual( legend.gridAlign, 'all', 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `gridAlign` property which can be set to a valid grid alignment', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + + legend.gridAlign = 'all'; + t.strictEqual( legend.gridAlign, 'all', 'returns expected value' ); + + legend.gridAlign = 'none'; + t.strictEqual( legend.gridAlign, 'none', 'returns expected value' ); + + legend.gridAlign = 'each'; + t.strictEqual( legend.gridAlign, 'each', 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `gridAlign` property is set to a new value', function test( t ) { + var count; + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + count = 0; + + legend.on( 'change', onChange ); + + legend.gridAlign = 'all'; + t.strictEqual( count, 1, 'returns expected value' ); + + legend.gridAlign = 'none'; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + legend.gridAlign = 'none'; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.js b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.js new file mode 100644 index 000000000000..fb7b625abbf4 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.js @@ -0,0 +1,2446 @@ +/** +* @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 EventEmitter = require( 'events' ).EventEmitter; +var tape = require( 'tape' ); +var instanceOf = require( '@stdlib/assert/instance-of' ); +var Legend = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Legend, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function is a constructor', function test( t ) { + var legend = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( instanceOf( legend, Legend ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the constructor does not require the `new` keyword', function test( t ) { + var legend; + var ctor; + + ctor = Legend; + legend = ctor({ + 'fill': 'colorScale' + }); + t.strictEqual( instanceOf( legend, Legend ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the constructor does not require the `new` keyword (options)', function test( t ) { + var legend; + var ctor; + + ctor = Legend; + legend = ctor({ + 'fill': 'colorScale', + 'direction': 'horizontal' + }); + t.strictEqual( instanceOf( legend, Legend ), true, 'returns expected value' ); + t.strictEqual( legend.direction, 'horizontal', '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 legend = new Legend( value ); // eslint-disable-line no-unused-vars + }; + } +}); + +tape( 'the constructor throws an error if not provided at least one legend scale property', function test( t ) { + t.throws( foo, TypeError, 'throws an error' ); + t.end(); + + function foo() { + var legend = new Legend({ // eslint-disable-line no-unused-vars + 'direction': 'vertical' + }); + } +}); + +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 legend = new Legend({ // eslint-disable-line no-unused-vars + 'fill': 'colorScale', + 'aria': value + }); + }; + } +}); + +tape( 'the constructor throws an error if provided an invalid `clipHeight` option', function test( t ) { + var values; + var i; + + values = [ + 'beep', + 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 legend = new Legend({ // eslint-disable-line no-unused-vars + 'fill': 'colorScale', + 'clipHeight': value + }); + }; + } +}); + +tape( 'the constructor throws an error if provided an invalid `columnPadding` option', function test( t ) { + var values; + var i; + + values = [ + 'beep', + 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 legend = new Legend({ // eslint-disable-line no-unused-vars + 'fill': 'colorScale', + 'columnPadding': value + }); + }; + } +}); + +tape( 'the constructor throws an error if provided an invalid `columns` option', function test( t ) { + var values; + var i; + + values = [ + 'beep', + 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 legend = new Legend({ // eslint-disable-line no-unused-vars + 'fill': 'colorScale', + 'columns': value + }); + }; + } +}); + +tape( 'the constructor throws an error if provided an invalid `cornerRadius` option', function test( t ) { + var values; + var i; + + values = [ + 'beep', + 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 legend = new Legend({ // eslint-disable-line no-unused-vars + 'fill': 'colorScale', + 'cornerRadius': value + }); + }; + } +}); + +tape( 'the constructor throws an error if provided an invalid `description` 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 legend = new Legend({ // eslint-disable-line no-unused-vars + 'fill': 'colorScale', + 'description': value + }); + }; + } +}); + +tape( 'the constructor throws an error if provided an invalid `direction` option', function test( t ) { + var values; + var i; + + values = [ + 'beep', + 'boop', + 5, + NaN, + null, + void 0, + 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 legend = new Legend({ // eslint-disable-line no-unused-vars + 'fill': 'colorScale', + 'direction': value + }); + }; + } +}); + +tape( 'the constructor throws an error if provided an invalid `encode` option', function test( t ) { + var values; + var i; + + values = [ + 'beep', + 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 legend = new Legend({ // eslint-disable-line no-unused-vars + 'fill': 'colorScale', + 'encode': value + }); + }; + } +}); + +tape( 'the constructor throws an error if provided an invalid `fill` 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 legend = new Legend({ // eslint-disable-line no-unused-vars + 'fill': value + }); + }; + } +}); + +tape( 'the constructor throws an error if provided an invalid `fillColor` 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 legend = new Legend({ // eslint-disable-line no-unused-vars + 'fill': 'colorScale', + 'fillColor': value + }); + }; + } +}); + +tape( 'the constructor throws an error if provided an invalid `format` 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 legend = new Legend({ // eslint-disable-line no-unused-vars + 'fill': 'colorScale', + 'format': value + }); + }; + } +}); + +tape( 'the constructor throws an error if provided an invalid `formatType` option', function test( t ) { + var values; + var i; + + values = [ + 'beep', + 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 legend = new Legend({ // eslint-disable-line no-unused-vars + 'fill': 'colorScale', + 'formatType': value + }); + }; + } +}); + +tape( 'the constructor throws an error if provided an invalid `gradientLength` option', function test( t ) { + var values; + var i; + + values = [ + 'beep', + 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 legend = new Legend({ // eslint-disable-line no-unused-vars + 'fill': 'colorScale', + 'gradientLength': value + }); + }; + } +}); + +tape( 'the constructor throws an error if provided an invalid `gradientOpacity` option', function test( t ) { + var values; + var i; + + values = [ + 'beep', + 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 legend = new Legend({ // eslint-disable-line no-unused-vars + 'fill': 'colorScale', + 'gradientOpacity': value + }); + }; + } +}); + +tape( 'the constructor throws an error if provided an invalid `gradientStrokeColor` 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 legend = new Legend({ // eslint-disable-line no-unused-vars + 'fill': 'colorScale', + 'gradientStrokeColor': value + }); + }; + } +}); + +tape( 'the constructor throws an error if provided an invalid `gradientStrokeWidth` option', function test( t ) { + var values; + var i; + + values = [ + 'beep', + 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 legend = new Legend({ // eslint-disable-line no-unused-vars + 'fill': 'colorScale', + 'gradientStrokeWidth': value + }); + }; + } +}); + +tape( 'the constructor throws an error if provided an invalid `gradientThickness` option', function test( t ) { + var values; + var i; + + values = [ + 'beep', + 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 legend = new Legend({ // eslint-disable-line no-unused-vars + 'fill': 'colorScale', + 'gradientThickness': value + }); + }; + } +}); + +tape( 'the constructor throws an error if provided an invalid `gridAlign` option', function test( t ) { + var values; + var i; + + values = [ + 'beep', + 'boop', + 5, + NaN, + null, + void 0, + 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 legend = new Legend({ // eslint-disable-line no-unused-vars + 'fill': 'colorScale', + 'gridAlign': value + }); + }; + } +}); + +tape( 'the constructor throws an error if provided an invalid `labelAlign` 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 legend = new Legend({ // eslint-disable-line no-unused-vars + 'fill': 'colorScale', + 'labelAlign': value + }); + }; + } +}); + +tape( 'the constructor throws an error if provided an invalid `labelBaseline` option', function test( t ) { + var values; + var i; + + values = [ + 'beep', + 'boop', + 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 legend = new Legend({ // eslint-disable-line no-unused-vars + 'fill': 'colorScale', + 'labelBaseline': value + }); + }; + } +}); + +tape( 'the constructor throws an error if provided an invalid `labelColor` 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 legend = new Legend({ // eslint-disable-line no-unused-vars + 'fill': 'colorScale', + 'labelColor': value + }); + }; + } +}); + +tape( 'the constructor throws an error if provided an invalid `labelFont` 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 legend = new Legend({ // eslint-disable-line no-unused-vars + 'fill': 'colorScale', + 'labelFont': value + }); + }; + } +}); + +tape( 'the constructor throws an error if provided an invalid `labelFontSize` option', function test( t ) { + var values; + var i; + + values = [ + 'beep', + 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 legend = new Legend({ // eslint-disable-line no-unused-vars + 'fill': 'colorScale', + 'labelFontSize': value + }); + }; + } +}); + +tape( 'the constructor throws an error if provided an invalid `labelFontStyle` 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 legend = new Legend({ // eslint-disable-line no-unused-vars + 'fill': 'colorScale', + 'labelFontStyle': value + }); + }; + } +}); + +tape( 'the constructor throws an error if provided an invalid `labelFontWeight` 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 legend = new Legend({ // eslint-disable-line no-unused-vars + 'fill': 'colorScale', + 'labelFontWeight': value + }); + }; + } +}); + +tape( 'the constructor throws an error if provided an invalid `labelLimit` option', function test( t ) { + var values; + var i; + + values = [ + 'beep', + -1, + 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 legend = new Legend({ // eslint-disable-line no-unused-vars + 'fill': 'colorScale', + 'labelLimit': value + }); + }; + } +}); + +tape( 'the constructor throws an error if provided an invalid `labelOffset` option', function test( t ) { + var values; + var i; + + values = [ + 'beep', + 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 legend = new Legend({ // eslint-disable-line no-unused-vars + 'fill': 'colorScale', + 'labelOffset': value + }); + }; + } +}); + +tape( 'the constructor throws an error if provided an invalid `labelOpacity` option', function test( t ) { + var values; + var i; + + values = [ + 'beep', + 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 legend = new Legend({ // eslint-disable-line no-unused-vars + 'fill': 'colorScale', + 'labelOpacity': value + }); + }; + } +}); + +tape( 'the constructor throws an error if provided an invalid `labelOverlap` option', function test( t ) { + var values; + var i; + + values = [ + 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 legend = new Legend({ // eslint-disable-line no-unused-vars + 'fill': 'colorScale', + 'labelOverlap': value + }); + }; + } +}); + +tape( 'the constructor throws an error if provided an invalid `labelSeparation` option', function test( t ) { + var values; + var i; + + values = [ + 'beep', + -1, + NaN, + null, + void 0, + 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 legend = new Legend({ // eslint-disable-line no-unused-vars + 'fill': 'colorScale', + 'labelSeparation': value + }); + }; + } +}); + +tape( 'the constructor throws an error if provided an invalid `legendX` option', function test( t ) { + var values; + var i; + + values = [ + 'beep', + 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 legend = new Legend({ // eslint-disable-line no-unused-vars + 'fill': 'colorScale', + 'legendX': value + }); + }; + } +}); + +tape( 'the constructor throws an error if provided an invalid `legendY` option', function test( t ) { + var values; + var i; + + values = [ + 'beep', + 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 legend = new Legend({ // eslint-disable-line no-unused-vars + 'fill': 'colorScale', + 'legendY': value + }); + }; + } +}); + +tape( 'the constructor throws an error if provided an invalid `offset` option', function test( t ) { + var values; + var i; + + values = [ + 'beep', + 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 legend = new Legend({ // eslint-disable-line no-unused-vars + 'fill': 'colorScale', + 'offset': value + }); + }; + } +}); + +tape( 'the constructor throws an error if provided an invalid `opacity` 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 legend = new Legend({ // eslint-disable-line no-unused-vars + 'fill': 'colorScale', + 'opacity': value + }); + }; + } +}); + +tape( 'the constructor throws an error if provided an invalid `orient` option', function test( t ) { + var values; + var i; + + values = [ + 'beep', + 'boop', + 'RIGHT', + 5, + NaN, + null, + void 0, + 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 legend = new Legend({ // eslint-disable-line no-unused-vars + 'fill': 'colorScale', + 'orient': value + }); + }; + } +}); + +tape( 'the constructor throws an error if provided an invalid `padding` option', function test( t ) { + var values; + var i; + + values = [ + 'beep', + 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 legend = new Legend({ // eslint-disable-line no-unused-vars + 'fill': 'colorScale', + 'padding': value + }); + }; + } +}); + +tape( 'the constructor throws an error if provided an invalid `rowPadding` option', function test( t ) { + var values; + var i; + + values = [ + 'beep', + 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 legend = new Legend({ // eslint-disable-line no-unused-vars + 'fill': 'colorScale', + 'rowPadding': value + }); + }; + } +}); + +tape( 'the constructor throws an error if provided an invalid `shape` 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 legend = new Legend({ // eslint-disable-line no-unused-vars + 'fill': 'colorScale', + 'shape': value + }); + }; + } +}); + +tape( 'the constructor throws an error if provided an invalid `size` 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 legend = new Legend({ // eslint-disable-line no-unused-vars + 'fill': 'colorScale', + 'size': value + }); + }; + } +}); + +tape( 'the constructor throws an error if provided an invalid `stroke` 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 legend = new Legend({ // eslint-disable-line no-unused-vars + 'fill': 'colorScale', + 'stroke': value + }); + }; + } +}); + +tape( 'the constructor throws an error if provided an invalid `strokeColor` 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 legend = new Legend({ // eslint-disable-line no-unused-vars + 'fill': 'colorScale', + 'strokeColor': value + }); + }; + } +}); + +tape( 'the constructor throws an error if provided an invalid `strokeDash` 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 legend = new Legend({ // eslint-disable-line no-unused-vars + 'fill': 'colorScale', + 'strokeDash': value + }); + }; + } +}); + +tape( 'the constructor throws an error if provided an invalid `strokeWidth` 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 legend = new Legend({ // eslint-disable-line no-unused-vars + 'fill': 'colorScale', + 'strokeWidth': value + }); + }; + } +}); + +tape( 'the constructor throws an error if provided an invalid `symbolDash` option', function test( t ) { + var values; + var i; + + values = [ + 'beep', + 5, + NaN, + null, + void 0, + 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 legend = new Legend({ // eslint-disable-line no-unused-vars + 'fill': 'colorScale', + 'symbolDash': value + }); + }; + } +}); + +tape( 'the constructor throws an error if provided an invalid `symbolDashOffset` option', function test( t ) { + var values; + var i; + + values = [ + 'beep', + 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 legend = new Legend({ // eslint-disable-line no-unused-vars + 'fill': 'colorScale', + 'symbolDashOffset': value + }); + }; + } +}); + +tape( 'the constructor throws an error if provided an invalid `symbolFillColor` 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 legend = new Legend({ // eslint-disable-line no-unused-vars + 'fill': 'colorScale', + 'symbolFillColor': value + }); + }; + } +}); + +tape( 'the constructor throws an error if provided an invalid `symbolLimit` option', function test( t ) { + var values; + var i; + + values = [ + 'beep', + 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 legend = new Legend({ // eslint-disable-line no-unused-vars + 'fill': 'colorScale', + 'symbolLimit': value + }); + }; + } +}); + +tape( 'the constructor throws an error if provided an invalid `symbolOffset` option', function test( t ) { + var values; + var i; + + values = [ + 'beep', + 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 legend = new Legend({ // eslint-disable-line no-unused-vars + 'fill': 'colorScale', + 'symbolOffset': value + }); + }; + } +}); + +tape( 'the constructor throws an error if provided an invalid `symbolOpacity` option', function test( t ) { + var values; + var i; + + values = [ + 'beep', + 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 legend = new Legend({ // eslint-disable-line no-unused-vars + 'fill': 'colorScale', + 'symbolOpacity': value + }); + }; + } +}); + +tape( 'the constructor throws an error if provided an invalid `symbolSize` option', function test( t ) { + var values; + var i; + + values = [ + 'beep', + 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 legend = new Legend({ // eslint-disable-line no-unused-vars + 'fill': 'colorScale', + 'symbolSize': value + }); + }; + } +}); + +tape( 'the constructor throws an error if provided an invalid `symbolStrokeColor` 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 legend = new Legend({ // eslint-disable-line no-unused-vars + 'fill': 'colorScale', + 'symbolStrokeColor': value + }); + }; + } +}); + +tape( 'the constructor throws an error if provided an invalid `symbolStrokeWidth` option', function test( t ) { + var values; + var i; + + values = [ + 'beep', + 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 legend = new Legend({ // eslint-disable-line no-unused-vars + 'fill': 'colorScale', + 'symbolStrokeWidth': value + }); + }; + } +}); + +tape( 'the constructor throws an error if provided an invalid `symbolType` option', function test( t ) { + var values; + var i; + + values = [ + 'beep', + 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 legend = new Legend({ // eslint-disable-line no-unused-vars + 'fill': 'colorScale', + 'symbolType': value + }); + }; + } +}); + +tape( 'the constructor throws an error if provided an invalid `tickCount` 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 legend = new Legend({ // eslint-disable-line no-unused-vars + 'fill': 'colorScale', + 'tickCount': value + }); + }; + } +}); + +tape( 'the constructor throws an error if provided an invalid `tickMinStep` option', function test( t ) { + var values; + var i; + + values = [ + 'beep', + 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 legend = new Legend({ // eslint-disable-line no-unused-vars + 'fill': 'colorScale', + 'tickMinStep': value + }); + }; + } +}); + +tape( 'the constructor throws an error if provided an invalid `title` option', function test( t ) { + var values; + var i; + + values = [ + 5, + NaN, + null, + void 0, + 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 legend = new Legend({ // eslint-disable-line no-unused-vars + 'fill': 'colorScale', + 'title': value + }); + }; + } +}); + +tape( 'the constructor throws an error if provided an invalid `titleAlign` option', function test( t ) { + var values; + var i; + + values = [ + 'beep', + 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 legend = new Legend({ // eslint-disable-line no-unused-vars + 'fill': 'colorScale', + 'titleAlign': value + }); + }; + } +}); + +tape( 'the constructor throws an error if provided an invalid `titleAnchor` option', function test( t ) { + var values; + var i; + + values = [ + 'beep', + 5, + NaN, + void 0, + 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 legend = new Legend({ // eslint-disable-line no-unused-vars + 'fill': 'colorScale', + 'titleAnchor': value + }); + }; + } +}); + +tape( 'the constructor throws an error if provided an invalid `titleBaseline` option', function test( t ) { + var values; + var i; + + values = [ + 'beep', + 'boop', + 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 legend = new Legend({ // eslint-disable-line no-unused-vars + 'fill': 'colorScale', + 'titleBaseline': value + }); + }; + } +}); + +tape( 'the constructor throws an error if provided an invalid `titleColor` 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 legend = new Legend({ // eslint-disable-line no-unused-vars + 'fill': 'colorScale', + 'titleColor': value + }); + }; + } +}); + +tape( 'the constructor throws an error if provided an invalid `titleFont` 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 legend = new Legend({ // eslint-disable-line no-unused-vars + 'fill': 'colorScale', + 'titleFont': value + }); + }; + } +}); + +tape( 'the constructor throws an error if provided an invalid `titleFontSize` option', function test( t ) { + var values; + var i; + + values = [ + 'beep', + 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 legend = new Legend({ // eslint-disable-line no-unused-vars + 'fill': 'colorScale', + 'titleFontSize': value + }); + }; + } +}); + +tape( 'the constructor throws an error if provided an invalid `titleFontStyle` 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 legend = new Legend({ // eslint-disable-line no-unused-vars + 'fill': 'colorScale', + 'titleFontStyle': value + }); + }; + } +}); + +tape( 'the constructor throws an error if provided an invalid `titleFontWeight` 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 legend = new Legend({ // eslint-disable-line no-unused-vars + 'fill': 'colorScale', + 'titleFontWeight': value + }); + }; + } +}); + +tape( 'the constructor throws an error if provided an invalid `titleLimit` option', function test( t ) { + var values; + var i; + + values = [ + 'beep', + -1, + 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 legend = new Legend({ // eslint-disable-line no-unused-vars + 'fill': 'colorScale', + 'titleLimit': value + }); + }; + } +}); + +tape( 'the constructor throws an error if provided an invalid `titleLineHeight` option', function test( t ) { + var values; + var i; + + values = [ + 'beep', + 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 legend = new Legend({ // eslint-disable-line no-unused-vars + 'fill': 'colorScale', + 'titleLineHeight': value + }); + }; + } +}); + +tape( 'the constructor throws an error if provided an invalid `titleOpacity` option', function test( t ) { + var values; + var i; + + values = [ + 'beep', + 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 legend = new Legend({ // eslint-disable-line no-unused-vars + 'fill': 'colorScale', + 'titleOpacity': value + }); + }; + } +}); + +tape( 'the constructor throws an error if provided an invalid `titleOrient` option', function test( t ) { + var values; + var i; + + values = [ + 'beep', + 'boop', + 5, + NaN, + null, + void 0, + 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 legend = new Legend({ // eslint-disable-line no-unused-vars + 'fill': 'colorScale', + 'titleOrient': value + }); + }; + } +}); + +tape( 'the constructor throws an error if provided an invalid `titlePadding` option', function test( t ) { + var values; + var i; + + values = [ + 'beep', + 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 legend = new Legend({ // eslint-disable-line no-unused-vars + 'fill': 'colorScale', + 'titlePadding': value + }); + }; + } +}); + +tape( 'the constructor throws an error if provided an invalid `type` option', function test( t ) { + var values; + var i; + + values = [ + 'beep', + 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 legend = new Legend({ // eslint-disable-line no-unused-vars + 'fill': 'colorScale', + 'type': value + }); + }; + } +}); + +tape( 'the constructor throws an error if provided an invalid `values` option', function test( t ) { + var values; + var i; + + values = [ + 'beep', + 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 legend = new Legend({ // eslint-disable-line no-unused-vars + 'fill': 'colorScale', + 'values': value + }); + }; + } +}); + +tape( 'the constructor throws an error if provided an invalid `zindex` option', function test( t ) { + var values; + var i; + + values = [ + 'beep', + null, + void 0, + 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 legend = new Legend({ // eslint-disable-line no-unused-vars + 'fill': 'colorScale', + 'zindex': value + }); + }; + } +}); + +tape( 'the constructor has a read-only `name` property', function test( t ) { + t.strictEqual( Legend.name, 'Legend', '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 legend; + var json; + + legend = new Legend({ + 'fill': 'colorScale' + }); + json = legend.toJSON(); + + expected = { + 'aria': true, + 'columns': 1, + 'direction': 'vertical', + 'fill': 'colorScale', + 'gridAlign': 'each', + 'labelBaseline': 'alphabetic', + 'labelOverlap': true, + 'labelSeparation': 0, + 'orient': 'right', + 'symbolDash': [], + 'title': [ '' ], + 'titleAnchor': null, + 'titleBaseline': 'alphabetic', + 'titleOrient': 'top', + '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 legend; + var json; + + legend = new Legend({ + 'fill': 'colorScale', + 'aria': false, + 'clipHeight': 20, + 'columnPadding': 10, + 'columns': 2, + 'cornerRadius': 3, + 'description': 'Color legend', + 'direction': 'horizontal', + 'encode': { + 'labels': { + 'enter': { + 'fontSize': { 'value': 12 } + } + } + }, + 'fillColor': '#fff', + 'format': '.1f', + 'formatType': 'number', + 'gradientLength': 200, + 'gradientOpacity': 0.5, + 'gradientStrokeColor': '#ccc', + 'gradientStrokeWidth': 1, + 'gradientThickness': 16, + 'gridAlign': 'all', + 'labelAlign': 'left', + 'labelBaseline': 'top', + 'labelColor': 'steelblue', + 'labelFont': 'Arial', + 'labelFontSize': 12, + 'labelFontStyle': 'italic', + 'labelFontWeight': 'bold', + 'labelLimit': 200, + 'labelOffset': 4, + 'labelOpacity': 0.8, + 'labelOverlap': 'parity', + 'labelSeparation': 2, + 'legendX': 10, + 'legendY': 20, + 'offset': 5, + 'opacity': 'opacityScale', + 'orient': 'top', + 'padding': 8, + 'rowPadding': 4, + 'shape': 'shapeScale', + 'size': 'sizeScale', + 'stroke': 'strokeScale', + 'strokeColor': '#000', + 'strokeDash': 'dashScale', + 'strokeWidth': 'widthScale', + 'symbolDash': [ 2, 4 ], + 'symbolDashOffset': 1, + 'symbolFillColor': 'red', + 'symbolLimit': 30, + 'symbolOffset': 2, + 'symbolOpacity': 0.9, + 'symbolSize': 100, + 'symbolStrokeColor': 'blue', + 'symbolStrokeWidth': 1, + 'symbolType': 'circle', + 'tickCount': 10, + 'tickMinStep': 1, + 'title': 'Legend Title', + 'titleAlign': 'center', + 'titleAnchor': 'start', + 'titleBaseline': 'bottom', + 'titleColor': 'black', + 'titleFont': 'Helvetica', + 'titleFontSize': 14, + 'titleFontStyle': 'normal', + 'titleFontWeight': 'bold', + 'titleLimit': 300, + 'titleLineHeight': 18, + 'titleOpacity': 0.9, + 'titleOrient': 'left', + 'titlePadding': 8, + 'type': 'gradient', + 'values': [ 1, 2, 3 ], + 'zindex': 2 + }); + json = legend.toJSON(); + + expected = { + 'aria': false, + 'clipHeight': 20, + 'columnPadding': 10, + 'columns': 2, + 'cornerRadius': 3, + 'description': 'Color legend', + 'direction': 'horizontal', + 'encode': { + 'labels': { + 'enter': { + 'fontSize': { 'value': 12 } + } + } + }, + 'fill': 'colorScale', + 'fillColor': '#fff', + 'format': '.1f', + 'formatType': 'number', + 'gradientLength': 200, + 'gradientOpacity': 0.5, + 'gradientStrokeColor': '#ccc', + 'gradientStrokeWidth': 1, + 'gradientThickness': 16, + 'gridAlign': 'all', + 'labelAlign': 'left', + 'labelBaseline': 'top', + 'labelColor': 'steelblue', + 'labelFont': 'Arial', + 'labelFontSize': 12, + 'labelFontStyle': 'italic', + 'labelFontWeight': 'bold', + 'labelLimit': 200, + 'labelOffset': 4, + 'labelOpacity': 0.8, + 'labelOverlap': 'parity', + 'labelSeparation': 2, + 'legendX': 10, + 'legendY': 20, + 'offset': 5, + 'opacity': 'opacityScale', + 'orient': 'top', + 'padding': 8, + 'rowPadding': 4, + 'shape': 'shapeScale', + 'size': 'sizeScale', + 'stroke': 'strokeScale', + 'strokeColor': '#000', + 'strokeDash': 'dashScale', + 'strokeWidth': 'widthScale', + 'symbolDash': [ 2, 4 ], + 'symbolDashOffset': 1, + 'symbolFillColor': 'red', + 'symbolLimit': 30, + 'symbolOffset': 2, + 'symbolOpacity': 0.9, + 'symbolSize': 100, + 'symbolStrokeColor': 'blue', + 'symbolStrokeWidth': 1, + 'symbolType': 'circle', + 'tickCount': 10, + 'tickMinStep': 1, + 'title': [ 'Legend Title' ], + 'titleAlign': 'center', + 'titleAnchor': 'start', + 'titleBaseline': 'bottom', + 'titleColor': 'black', + 'titleFont': 'Helvetica', + 'titleFontSize': 14, + 'titleFontStyle': 'normal', + 'titleFontWeight': 'bold', + 'titleLimit': 300, + 'titleLineHeight': 18, + 'titleOpacity': 0.9, + 'titleOrient': 'left', + 'titlePadding': 8, + 'type': 'gradient', + 'values': [ 1, 2, 3 ], + '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 legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + + expected = { + 'aria': true, + 'columns': 1, + 'direction': 'vertical', + 'fill': 'colorScale', + 'gridAlign': 'each', + 'labelBaseline': 'alphabetic', + 'labelOverlap': true, + 'labelSeparation': 0, + 'orient': 'right', + 'symbolDash': [], + 'title': [ '' ], + 'titleAnchor': null, + 'titleBaseline': 'alphabetic', + 'titleOrient': 'top', + 'zindex': 0 + }; + t.strictEqual( JSON.stringify( legend ), JSON.stringify( expected ), 'returns expected value' ); + t.end(); +}); + +tape( 'the constructor returns an instance which is an EventEmitter', function test( t ) { + var legend = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( instanceOf( legend, EventEmitter ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the constructor ignores unrecognized options', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale', + 'beep': 'boop', + 'foo': 'bar' + }); + + t.strictEqual( legend.fill, 'colorScale', 'returns expected value' ); + t.strictEqual( legend.beep, void 0, 'returns expected value' ); + t.strictEqual( legend.foo, void 0, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.label_align.js b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.label_align.js new file mode 100644 index 000000000000..3166bb6d0ec9 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.label_align.js @@ -0,0 +1,145 @@ +/** +* @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 isUndefined = require( '@stdlib/assert/is-undefined' ); +var isString = require( '@stdlib/assert/is-string' ).isPrimitive; +var Legend = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Legend, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `labelAlign` property', function test( t ) { + var v; + + v = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( hasOwnProp( v, 'labelAlign' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'labelAlign' ), true, 'returns expected value' ); + t.strictEqual( isUndefined( v.labelAlign ), true, 'returns expected value' ); + + v = new Legend({ + 'fill': 'colorScale', + 'labelAlign': 'left' + }); + t.strictEqual( isString( v.labelAlign ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the constructor returns an instance having a `labelAlign` 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 legend = new Legend({ + 'fill': 'colorScale' + }); + legend.labelAlign = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `labelAlign` property', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( isUndefined( legend.labelAlign ), true, 'returns expected value' ); + + legend = new Legend({ + 'fill': 'colorScale', + 'labelAlign': 'left' + }); + t.strictEqual( legend.labelAlign, 'left', 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `labelAlign` property which can be set to a valid value', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + + legend.labelAlign = 'left'; + t.strictEqual( legend.labelAlign, 'left', 'returns expected value' ); + + legend.labelAlign = 'center'; + t.strictEqual( legend.labelAlign, 'center', 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `labelAlign` property is set to a new value', function test( t ) { + var count; + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + count = 0; + + legend.on( 'change', onChange ); + + legend.labelAlign = 'left'; + t.strictEqual( count, 1, 'returns expected value' ); + + legend.labelAlign = 'center'; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + legend.labelAlign = 'center'; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.label_baseline.js b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.label_baseline.js new file mode 100644 index 000000000000..567e2dfbc389 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.label_baseline.js @@ -0,0 +1,140 @@ +/** +* @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' ).isPrimitive; +var Legend = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Legend, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `labelBaseline` property', function test( t ) { + var v; + + v = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( hasOwnProp( v, 'labelBaseline' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'labelBaseline' ), true, 'returns expected value' ); + t.strictEqual( isString( v.labelBaseline ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the constructor returns an instance having a `labelBaseline` property which throws an error if set to an invalid value', function test( t ) { + var values; + var i; + + values = [ + 'beep', + 'boop', + 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 legend = new Legend({ + 'fill': 'colorScale' + }); + legend.labelBaseline = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `labelBaseline` property', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( legend.labelBaseline, 'alphabetic', 'returns expected value' ); + + legend = new Legend({ + 'fill': 'colorScale', + 'labelBaseline': 'top' + }); + t.strictEqual( legend.labelBaseline, 'top', 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `labelBaseline` property which can be set to a valid baseline', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + + legend.labelBaseline = 'top'; + t.strictEqual( legend.labelBaseline, 'top', 'returns expected value' ); + + legend.labelBaseline = 'middle'; + t.strictEqual( legend.labelBaseline, 'middle', 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `labelBaseline` property is set to a new value', function test( t ) { + var count; + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + count = 0; + + legend.on( 'change', onChange ); + + legend.labelBaseline = 'top'; + t.strictEqual( count, 1, 'returns expected value' ); + + legend.labelBaseline = 'middle'; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + legend.labelBaseline = 'middle'; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.label_color.js b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.label_color.js new file mode 100644 index 000000000000..9fdb9f0cb8c6 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.label_color.js @@ -0,0 +1,145 @@ +/** +* @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 isUndefined = require( '@stdlib/assert/is-undefined' ); +var isString = require( '@stdlib/assert/is-string' ).isPrimitive; +var Legend = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Legend, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `labelColor` property', function test( t ) { + var v; + + v = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( hasOwnProp( v, 'labelColor' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'labelColor' ), true, 'returns expected value' ); + t.strictEqual( isUndefined( v.labelColor ), true, 'returns expected value' ); + + v = new Legend({ + 'fill': 'colorScale', + 'labelColor': 'beep' + }); + t.strictEqual( isString( v.labelColor ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the constructor returns an instance having a `labelColor` 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 legend = new Legend({ + 'fill': 'colorScale' + }); + legend.labelColor = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `labelColor` property', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( isUndefined( legend.labelColor ), true, 'returns expected value' ); + + legend = new Legend({ + 'fill': 'colorScale', + 'labelColor': 'testValue' + }); + t.strictEqual( legend.labelColor, 'testValue', 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `labelColor` property which can be set to a string', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + + legend.labelColor = 'beep'; + t.strictEqual( legend.labelColor, 'beep', 'returns expected value' ); + + legend.labelColor = 'boop'; + t.strictEqual( legend.labelColor, 'boop', 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `labelColor` property is set to a new value', function test( t ) { + var count; + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + count = 0; + + legend.on( 'change', onChange ); + + legend.labelColor = 'beep'; + t.strictEqual( count, 1, 'returns expected value' ); + + legend.labelColor = 'boop'; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + legend.labelColor = 'boop'; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.label_font.js b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.label_font.js new file mode 100644 index 000000000000..735203beb2e9 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.label_font.js @@ -0,0 +1,145 @@ +/** +* @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 isUndefined = require( '@stdlib/assert/is-undefined' ); +var isString = require( '@stdlib/assert/is-string' ).isPrimitive; +var Legend = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Legend, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `labelFont` property', function test( t ) { + var v; + + v = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( hasOwnProp( v, 'labelFont' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'labelFont' ), true, 'returns expected value' ); + t.strictEqual( isUndefined( v.labelFont ), true, 'returns expected value' ); + + v = new Legend({ + 'fill': 'colorScale', + 'labelFont': 'beep' + }); + t.strictEqual( isString( v.labelFont ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the constructor returns an instance having a `labelFont` 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 legend = new Legend({ + 'fill': 'colorScale' + }); + legend.labelFont = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `labelFont` property', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( isUndefined( legend.labelFont ), true, 'returns expected value' ); + + legend = new Legend({ + 'fill': 'colorScale', + 'labelFont': 'testValue' + }); + t.strictEqual( legend.labelFont, 'testValue', 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `labelFont` property which can be set to a string', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + + legend.labelFont = 'beep'; + t.strictEqual( legend.labelFont, 'beep', 'returns expected value' ); + + legend.labelFont = 'boop'; + t.strictEqual( legend.labelFont, 'boop', 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `labelFont` property is set to a new value', function test( t ) { + var count; + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + count = 0; + + legend.on( 'change', onChange ); + + legend.labelFont = 'beep'; + t.strictEqual( count, 1, 'returns expected value' ); + + legend.labelFont = 'boop'; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + legend.labelFont = 'boop'; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.label_font_size.js b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.label_font_size.js new file mode 100644 index 000000000000..c4e0c9bc7acf --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.label_font_size.js @@ -0,0 +1,146 @@ +/** +* @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 isUndefined = require( '@stdlib/assert/is-undefined' ); +var isNonNegativeNumber = require( '@stdlib/assert/is-nonnegative-number' ).isPrimitive; +var Legend = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Legend, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `labelFontSize` property', function test( t ) { + var v; + + v = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( hasOwnProp( v, 'labelFontSize' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'labelFontSize' ), true, 'returns expected value' ); + t.strictEqual( isUndefined( v.labelFontSize ), true, 'returns expected value' ); + + v = new Legend({ + 'fill': 'colorScale', + 'labelFontSize': 10 + }); + t.strictEqual( isNonNegativeNumber( v.labelFontSize ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the constructor returns an instance having a `labelFontSize` property which throws an error if set to an invalid value', function test( t ) { + var values; + var i; + + values = [ + 'beep', + -1, + 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 legend = new Legend({ + 'fill': 'colorScale' + }); + legend.labelFontSize = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `labelFontSize` property', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( isUndefined( legend.labelFontSize ), true, 'returns expected value' ); + + legend = new Legend({ + 'fill': 'colorScale', + 'labelFontSize': 10 + }); + t.strictEqual( legend.labelFontSize, 10, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `labelFontSize` property which can be set to a valid value', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + + legend.labelFontSize = 10; + t.strictEqual( legend.labelFontSize, 10, 'returns expected value' ); + + legend.labelFontSize = 20; + t.strictEqual( legend.labelFontSize, 20, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `labelFontSize` property is set to a new value', function test( t ) { + var count; + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + count = 0; + + legend.on( 'change', onChange ); + + legend.labelFontSize = 10; + t.strictEqual( count, 1, 'returns expected value' ); + + legend.labelFontSize = 20; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + legend.labelFontSize = 20; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.label_font_style.js b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.label_font_style.js new file mode 100644 index 000000000000..8de9be74dd34 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.label_font_style.js @@ -0,0 +1,145 @@ +/** +* @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 isUndefined = require( '@stdlib/assert/is-undefined' ); +var isString = require( '@stdlib/assert/is-string' ).isPrimitive; +var Legend = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Legend, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `labelFontStyle` property', function test( t ) { + var v; + + v = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( hasOwnProp( v, 'labelFontStyle' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'labelFontStyle' ), true, 'returns expected value' ); + t.strictEqual( isUndefined( v.labelFontStyle ), true, 'returns expected value' ); + + v = new Legend({ + 'fill': 'colorScale', + 'labelFontStyle': 'normal' + }); + t.strictEqual( isString( v.labelFontStyle ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the constructor returns an instance having a `labelFontStyle` 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 legend = new Legend({ + 'fill': 'colorScale' + }); + legend.labelFontStyle = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `labelFontStyle` property', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( isUndefined( legend.labelFontStyle ), true, 'returns expected value' ); + + legend = new Legend({ + 'fill': 'colorScale', + 'labelFontStyle': 'italic' + }); + t.strictEqual( legend.labelFontStyle, 'italic', 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `labelFontStyle` property which can be set to a string', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + + legend.labelFontStyle = 'normal'; + t.strictEqual( legend.labelFontStyle, 'normal', 'returns expected value' ); + + legend.labelFontStyle = 'italic'; + t.strictEqual( legend.labelFontStyle, 'italic', 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `labelFontStyle` property is set to a new value', function test( t ) { + var count; + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + count = 0; + + legend.on( 'change', onChange ); + + legend.labelFontStyle = 'normal'; + t.strictEqual( count, 1, 'returns expected value' ); + + legend.labelFontStyle = 'italic'; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + legend.labelFontStyle = 'italic'; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.label_font_weight.js b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.label_font_weight.js new file mode 100644 index 000000000000..45b43e048987 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.label_font_weight.js @@ -0,0 +1,199 @@ +/** +* @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 isUndefined = require( '@stdlib/assert/is-undefined' ); +var isString = require( '@stdlib/assert/is-string' ).isPrimitive; +var Legend = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Legend, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `labelFontWeight` property', function test( t ) { + var v; + + v = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( hasOwnProp( v, 'labelFontWeight' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'labelFontWeight' ), true, 'returns expected value' ); + t.strictEqual( isUndefined( v.labelFontWeight ), true, 'returns expected value' ); + + v = new Legend({ + 'fill': 'colorScale', + 'labelFontWeight': 'bold' + }); + t.strictEqual( isString( v.labelFontWeight ), true, 'returns expected value' ); + + v = new Legend({ + 'fill': 'colorScale', + 'labelFontWeight': 200 + }); + t.strictEqual( isString( v.labelFontWeight ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the constructor returns an instance having a `labelFontWeight` 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 legend = new Legend({ + 'fill': 'colorScale' + }); + legend.labelFontWeight = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `labelFontWeight` property', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( isUndefined( legend.labelFontWeight ), true, 'returns expected value' ); + + legend = new Legend({ + 'fill': 'colorScale', + 'labelFontWeight': 'bold' + }); + t.strictEqual( legend.labelFontWeight, 'bold', 'returns expected value' ); + + legend = new Legend({ + 'fill': 'colorScale', + 'labelFontWeight': 200 + }); + t.strictEqual( legend.labelFontWeight, '200', 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `labelFontWeight` property which can be set to a valid string value', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + + legend.labelFontWeight = 'bold'; + t.strictEqual( legend.labelFontWeight, 'bold', 'returns expected value' ); + + legend.labelFontWeight = 'normal'; + t.strictEqual( legend.labelFontWeight, 'normal', 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `labelFontWeight` property which can be set to a valid numeric value', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + + legend.labelFontWeight = 100; + t.strictEqual( legend.labelFontWeight, '100', 'returns expected value' ); + + legend.labelFontWeight = 900; + t.strictEqual( legend.labelFontWeight, '900', 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `labelFontWeight` property is set to a new value (string)', function test( t ) { + var count; + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + count = 0; + + legend.on( 'change', onChange ); + + legend.labelFontWeight = 'bold'; + t.strictEqual( count, 1, 'returns expected value' ); + + legend.labelFontWeight = 'normal'; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + legend.labelFontWeight = 'normal'; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); + +tape( 'the constructor returns an instance which emits an event when the `labelFontWeight` property is set to a new value (number)', function test( t ) { + var count; + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + count = 0; + + legend.on( 'change', onChange ); + + legend.labelFontWeight = 100; + t.strictEqual( count, 1, 'returns expected value' ); + + legend.labelFontWeight = 900; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + legend.labelFontWeight = 900; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.label_limit.js b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.label_limit.js new file mode 100644 index 000000000000..13197e65885b --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.label_limit.js @@ -0,0 +1,146 @@ +/** +* @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 isUndefined = require( '@stdlib/assert/is-undefined' ); +var isNonNegativeNumber = require( '@stdlib/assert/is-nonnegative-number' ).isPrimitive; +var Legend = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Legend, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `labelLimit` property', function test( t ) { + var v; + + v = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( hasOwnProp( v, 'labelLimit' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'labelLimit' ), true, 'returns expected value' ); + t.strictEqual( isUndefined( v.labelLimit ), true, 'returns expected value' ); + + v = new Legend({ + 'fill': 'colorScale', + 'labelLimit': 10 + }); + t.strictEqual( isNonNegativeNumber( v.labelLimit ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the constructor returns an instance having a `labelLimit` property which throws an error if set to an invalid value', function test( t ) { + var values; + var i; + + values = [ + 'beep', + -1, + 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 legend = new Legend({ + 'fill': 'colorScale' + }); + legend.labelLimit = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `labelLimit` property', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( isUndefined( legend.labelLimit ), true, 'returns expected value' ); + + legend = new Legend({ + 'fill': 'colorScale', + 'labelLimit': 10 + }); + t.strictEqual( legend.labelLimit, 10, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `labelLimit` property which can be set to a valid value', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + + legend.labelLimit = 10; + t.strictEqual( legend.labelLimit, 10, 'returns expected value' ); + + legend.labelLimit = 20; + t.strictEqual( legend.labelLimit, 20, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `labelLimit` property is set to a new value', function test( t ) { + var count; + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + count = 0; + + legend.on( 'change', onChange ); + + legend.labelLimit = 10; + t.strictEqual( count, 1, 'returns expected value' ); + + legend.labelLimit = 20; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + legend.labelLimit = 20; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.label_offset.js b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.label_offset.js new file mode 100644 index 000000000000..c8f9a4f18f17 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.label_offset.js @@ -0,0 +1,144 @@ +/** +* @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 isUndefined = require( '@stdlib/assert/is-undefined' ); +var isNumber = require( '@stdlib/assert/is-number' ).isPrimitive; +var Legend = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Legend, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `labelOffset` property', function test( t ) { + var v; + + v = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( hasOwnProp( v, 'labelOffset' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'labelOffset' ), true, 'returns expected value' ); + t.strictEqual( isUndefined( v.labelOffset ), true, 'returns expected value' ); + + v = new Legend({ + 'fill': 'colorScale', + 'labelOffset': 10 + }); + t.strictEqual( isNumber( v.labelOffset ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the constructor returns an instance having a `labelOffset` property which throws an error if set to an invalid value', function test( t ) { + var values; + var i; + + values = [ + 'beep', + 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 legend = new Legend({ + 'fill': 'colorScale' + }); + legend.labelOffset = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `labelOffset` property', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( isUndefined( legend.labelOffset ), true, 'returns expected value' ); + + legend = new Legend({ + 'fill': 'colorScale', + 'labelOffset': 10 + }); + t.strictEqual( legend.labelOffset, 10, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `labelOffset` property which can be set to a valid value', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + + legend.labelOffset = 10; + t.strictEqual( legend.labelOffset, 10, 'returns expected value' ); + + legend.labelOffset = 20; + t.strictEqual( legend.labelOffset, 20, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `labelOffset` property is set to a new value', function test( t ) { + var count; + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + count = 0; + + legend.on( 'change', onChange ); + + legend.labelOffset = 10; + t.strictEqual( count, 1, 'returns expected value' ); + + legend.labelOffset = 20; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + legend.labelOffset = 20; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.label_opacity.js b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.label_opacity.js new file mode 100644 index 000000000000..6b21dc62167a --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.label_opacity.js @@ -0,0 +1,144 @@ +/** +* @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 isUndefined = require( '@stdlib/assert/is-undefined' ); +var isNumber = require( '@stdlib/assert/is-number' ).isPrimitive; +var Legend = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Legend, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `labelOpacity` property', function test( t ) { + var v; + + v = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( hasOwnProp( v, 'labelOpacity' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'labelOpacity' ), true, 'returns expected value' ); + t.strictEqual( isUndefined( v.labelOpacity ), true, 'returns expected value' ); + + v = new Legend({ + 'fill': 'colorScale', + 'labelOpacity': 10 + }); + t.strictEqual( isNumber( v.labelOpacity ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the constructor returns an instance having a `labelOpacity` property which throws an error if set to an invalid value', function test( t ) { + var values; + var i; + + values = [ + 'beep', + 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 legend = new Legend({ + 'fill': 'colorScale' + }); + legend.labelOpacity = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `labelOpacity` property', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( isUndefined( legend.labelOpacity ), true, 'returns expected value' ); + + legend = new Legend({ + 'fill': 'colorScale', + 'labelOpacity': 10 + }); + t.strictEqual( legend.labelOpacity, 10, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `labelOpacity` property which can be set to a valid value', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + + legend.labelOpacity = 10; + t.strictEqual( legend.labelOpacity, 10, 'returns expected value' ); + + legend.labelOpacity = 20; + t.strictEqual( legend.labelOpacity, 20, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `labelOpacity` property is set to a new value', function test( t ) { + var count; + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + count = 0; + + legend.on( 'change', onChange ); + + legend.labelOpacity = 10; + t.strictEqual( count, 1, 'returns expected value' ); + + legend.labelOpacity = 20; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + legend.labelOpacity = 20; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.label_overlap.js b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.label_overlap.js new file mode 100644 index 000000000000..b35488cfe190 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.label_overlap.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 isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; +var isString = require( '@stdlib/assert/is-string' ).isPrimitive; +var Legend = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Legend, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `labelOverlap` property', function test( t ) { + var v; + + v = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( hasOwnProp( v, 'labelOverlap' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'labelOverlap' ), true, 'returns expected value' ); + + v = new Legend({ + 'fill': 'colorScale', + 'labelOverlap': true + }); + t.strictEqual( isBoolean( v.labelOverlap ), true, 'returns expected value' ); + + v = new Legend({ + 'fill': 'colorScale', + 'labelOverlap': 'parity' + }); + t.strictEqual( isString( v.labelOverlap ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the constructor returns an instance having a `labelOverlap` property which throws an error if set to an invalid value', function test( t ) { + var values; + var i; + + values = [ + 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 legend = new Legend({ + 'fill': 'colorScale' + }); + legend.labelOverlap = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `labelOverlap` property', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( legend.labelOverlap, true, 'returns expected value' ); + + legend = new Legend({ + 'fill': 'colorScale', + 'labelOverlap': true + }); + t.strictEqual( legend.labelOverlap, true, 'returns expected value' ); + + legend = new Legend({ + 'fill': 'colorScale', + 'labelOverlap': 'parity' + }); + t.strictEqual( legend.labelOverlap, 'parity', 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `labelOverlap` property which can be set to a valid value', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + + legend.labelOverlap = true; + t.strictEqual( legend.labelOverlap, true, 'returns expected value' ); + + legend.labelOverlap = 'parity'; + t.strictEqual( legend.labelOverlap, 'parity', 'returns expected value' ); + + legend.labelOverlap = 'greedy'; + t.strictEqual( legend.labelOverlap, 'greedy', 'returns expected value' ); + + legend.labelOverlap = false; + t.strictEqual( legend.labelOverlap, false, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `labelOverlap` property is set to a new value', function test( t ) { + var count; + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + count = 0; + + legend.on( 'change', onChange ); + + legend.labelOverlap = false; + t.strictEqual( count, 1, 'returns expected value' ); + + legend.labelOverlap = 'parity'; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + legend.labelOverlap = 'parity'; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.label_separation.js b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.label_separation.js new file mode 100644 index 000000000000..b96b8204bf16 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.label_separation.js @@ -0,0 +1,140 @@ +/** +* @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 isNonNegativeNumber = require( '@stdlib/assert/is-nonnegative-number' ).isPrimitive; +var Legend = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Legend, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `labelSeparation` property', function test( t ) { + var v; + + v = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( hasOwnProp( v, 'labelSeparation' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'labelSeparation' ), true, 'returns expected value' ); + t.strictEqual( isNonNegativeNumber( v.labelSeparation ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the constructor returns an instance having a `labelSeparation` property which throws an error if set to an invalid value', function test( t ) { + var values; + var i; + + values = [ + 'beep', + -1, + 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 legend = new Legend({ + 'fill': 'colorScale' + }); + legend.labelSeparation = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `labelSeparation` property', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( legend.labelSeparation, 0, 'returns expected value' ); + + legend = new Legend({ + 'fill': 'colorScale', + 'labelSeparation': 5 + }); + t.strictEqual( legend.labelSeparation, 5, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `labelSeparation` property which can be set to a valid value', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + + legend.labelSeparation = 5; + t.strictEqual( legend.labelSeparation, 5, 'returns expected value' ); + + legend.labelSeparation = 10; + t.strictEqual( legend.labelSeparation, 10, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `labelSeparation` property is set to a new value', function test( t ) { + var count; + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + count = 0; + + legend.on( 'change', onChange ); + + legend.labelSeparation = 5; + t.strictEqual( count, 1, 'returns expected value' ); + + legend.labelSeparation = 10; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + legend.labelSeparation = 10; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.legend_x.js b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.legend_x.js new file mode 100644 index 000000000000..d1dd4dd651ba --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.legend_x.js @@ -0,0 +1,144 @@ +/** +* @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 isUndefined = require( '@stdlib/assert/is-undefined' ); +var isNumber = require( '@stdlib/assert/is-number' ).isPrimitive; +var Legend = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Legend, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `legendX` property', function test( t ) { + var v; + + v = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( hasOwnProp( v, 'legendX' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'legendX' ), true, 'returns expected value' ); + t.strictEqual( isUndefined( v.legendX ), true, 'returns expected value' ); + + v = new Legend({ + 'fill': 'colorScale', + 'legendX': 10 + }); + t.strictEqual( isNumber( v.legendX ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the constructor returns an instance having a `legendX` property which throws an error if set to an invalid value', function test( t ) { + var values; + var i; + + values = [ + 'beep', + 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 legend = new Legend({ + 'fill': 'colorScale' + }); + legend.legendX = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `legendX` property', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( isUndefined( legend.legendX ), true, 'returns expected value' ); + + legend = new Legend({ + 'fill': 'colorScale', + 'legendX': 10 + }); + t.strictEqual( legend.legendX, 10, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `legendX` property which can be set to a valid value', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + + legend.legendX = 10; + t.strictEqual( legend.legendX, 10, 'returns expected value' ); + + legend.legendX = 20; + t.strictEqual( legend.legendX, 20, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `legendX` property is set to a new value', function test( t ) { + var count; + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + count = 0; + + legend.on( 'change', onChange ); + + legend.legendX = 10; + t.strictEqual( count, 1, 'returns expected value' ); + + legend.legendX = 20; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + legend.legendX = 20; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.legend_y.js b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.legend_y.js new file mode 100644 index 000000000000..908e129fa8f1 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.legend_y.js @@ -0,0 +1,144 @@ +/** +* @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 isUndefined = require( '@stdlib/assert/is-undefined' ); +var isNumber = require( '@stdlib/assert/is-number' ).isPrimitive; +var Legend = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Legend, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `legendY` property', function test( t ) { + var v; + + v = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( hasOwnProp( v, 'legendY' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'legendY' ), true, 'returns expected value' ); + t.strictEqual( isUndefined( v.legendY ), true, 'returns expected value' ); + + v = new Legend({ + 'fill': 'colorScale', + 'legendY': 10 + }); + t.strictEqual( isNumber( v.legendY ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the constructor returns an instance having a `legendY` property which throws an error if set to an invalid value', function test( t ) { + var values; + var i; + + values = [ + 'beep', + 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 legend = new Legend({ + 'fill': 'colorScale' + }); + legend.legendY = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `legendY` property', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( isUndefined( legend.legendY ), true, 'returns expected value' ); + + legend = new Legend({ + 'fill': 'colorScale', + 'legendY': 10 + }); + t.strictEqual( legend.legendY, 10, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `legendY` property which can be set to a valid value', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + + legend.legendY = 10; + t.strictEqual( legend.legendY, 10, 'returns expected value' ); + + legend.legendY = 20; + t.strictEqual( legend.legendY, 20, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `legendY` property is set to a new value', function test( t ) { + var count; + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + count = 0; + + legend.on( 'change', onChange ); + + legend.legendY = 10; + t.strictEqual( count, 1, 'returns expected value' ); + + legend.legendY = 20; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + legend.legendY = 20; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.offset.js b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.offset.js new file mode 100644 index 000000000000..153bc0e7b874 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.offset.js @@ -0,0 +1,144 @@ +/** +* @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 isUndefined = require( '@stdlib/assert/is-undefined' ); +var isNumber = require( '@stdlib/assert/is-number' ).isPrimitive; +var Legend = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Legend, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has an `offset` property', function test( t ) { + var v; + + v = new Legend({ + 'fill': 'colorScale' + }); + 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 Legend({ + 'fill': 'colorScale', + 'offset': 10 + }); + t.strictEqual( isNumber( v.offset ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the constructor returns an instance having an `offset` property which throws an error if set to an invalid value', function test( t ) { + var values; + var i; + + values = [ + 'beep', + 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 legend = new Legend({ + 'fill': 'colorScale' + }); + legend.offset = value; + }; + } +}); + +tape( 'the constructor returns an instance having an `offset` property', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( isUndefined( legend.offset ), true, 'returns expected value' ); + + legend = new Legend({ + 'fill': 'colorScale', + 'offset': 10 + }); + t.strictEqual( legend.offset, 10, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having an `offset` property which can be set to a valid value', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + + legend.offset = 10; + t.strictEqual( legend.offset, 10, 'returns expected value' ); + + legend.offset = 20; + t.strictEqual( legend.offset, 20, '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 count; + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + count = 0; + + legend.on( 'change', onChange ); + + legend.offset = 10; + t.strictEqual( count, 1, 'returns expected value' ); + + legend.offset = 20; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + legend.offset = 20; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.opacity.js b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.opacity.js new file mode 100644 index 000000000000..f54bd04af139 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.opacity.js @@ -0,0 +1,145 @@ +/** +* @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 isUndefined = require( '@stdlib/assert/is-undefined' ); +var isString = require( '@stdlib/assert/is-string' ).isPrimitive; +var Legend = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Legend, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has an `opacity` property', function test( t ) { + var v; + + v = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( hasOwnProp( v, 'opacity' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'opacity' ), true, 'returns expected value' ); + t.strictEqual( isUndefined( v.opacity ), true, 'returns expected value' ); + + v = new Legend({ + 'fill': 'colorScale', + 'opacity': 'beep' + }); + t.strictEqual( isString( v.opacity ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the constructor returns an instance having an `opacity` 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 legend = new Legend({ + 'fill': 'colorScale' + }); + legend.opacity = value; + }; + } +}); + +tape( 'the constructor returns an instance having an `opacity` property', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( isUndefined( legend.opacity ), true, 'returns expected value' ); + + legend = new Legend({ + 'fill': 'colorScale', + 'opacity': 'testValue' + }); + t.strictEqual( legend.opacity, 'testValue', 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having an `opacity` property which can be set to a string', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + + legend.opacity = 'beep'; + t.strictEqual( legend.opacity, 'beep', 'returns expected value' ); + + legend.opacity = 'boop'; + t.strictEqual( legend.opacity, 'boop', 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `opacity` property is set to a new value', function test( t ) { + var count; + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + count = 0; + + legend.on( 'change', onChange ); + + legend.opacity = 'beep'; + t.strictEqual( count, 1, 'returns expected value' ); + + legend.opacity = 'boop'; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + legend.opacity = 'boop'; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.orient.js b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.orient.js new file mode 100644 index 000000000000..5cb01d67c7f7 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.orient.js @@ -0,0 +1,151 @@ +/** +* @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' ).isPrimitive; +var Legend = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Legend, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has an `orient` property', function test( t ) { + var v; + + v = new Legend({ + 'fill': 'colorScale' + }); + 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 returns an instance having an `orient` property which throws an error if set to an invalid value', function test( t ) { + var values; + var i; + + values = [ + 'beep', + 'boop', + 'RIGHT', + 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 legend = new Legend({ + 'fill': 'colorScale' + }); + legend.orient = value; + }; + } +}); + +tape( 'the constructor returns an instance having an `orient` property', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( legend.orient, 'right', 'returns expected value' ); + + legend = new Legend({ + 'fill': 'colorScale', + 'orient': 'top' + }); + t.strictEqual( legend.orient, 'top', 'returns expected value' ); + + legend = new Legend({ + 'fill': 'colorScale', + 'orient': 'left' + }); + t.strictEqual( legend.orient, 'left', 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having an `orient` property which can be set to a valid orientation', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + + legend.orient = 'left'; + t.strictEqual( legend.orient, 'left', 'returns expected value' ); + + legend.orient = 'top'; + t.strictEqual( legend.orient, 'top', 'returns expected value' ); + + legend.orient = 'right'; + t.strictEqual( legend.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 count; + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + count = 0; + + legend.on( 'change', onChange ); + + legend.orient = 'left'; + t.strictEqual( count, 1, 'returns expected value' ); + + legend.orient = 'top'; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + legend.orient = 'top'; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.padding.js b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.padding.js new file mode 100644 index 000000000000..edced4952fed --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.padding.js @@ -0,0 +1,144 @@ +/** +* @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 isUndefined = require( '@stdlib/assert/is-undefined' ); +var isNumber = require( '@stdlib/assert/is-number' ).isPrimitive; +var Legend = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Legend, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `padding` property', function test( t ) { + var v; + + v = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( hasOwnProp( v, 'padding' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'padding' ), true, 'returns expected value' ); + t.strictEqual( isUndefined( v.padding ), true, 'returns expected value' ); + + v = new Legend({ + 'fill': 'colorScale', + 'padding': 10 + }); + t.strictEqual( isNumber( v.padding ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the constructor returns an instance having a `padding` property which throws an error if set to an invalid value', function test( t ) { + var values; + var i; + + values = [ + 'beep', + 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 legend = new Legend({ + 'fill': 'colorScale' + }); + legend.padding = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `padding` property', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( isUndefined( legend.padding ), true, 'returns expected value' ); + + legend = new Legend({ + 'fill': 'colorScale', + 'padding': 10 + }); + t.strictEqual( legend.padding, 10, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `padding` property which can be set to a valid value', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + + legend.padding = 10; + t.strictEqual( legend.padding, 10, 'returns expected value' ); + + legend.padding = 20; + t.strictEqual( legend.padding, 20, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `padding` property is set to a new value', function test( t ) { + var count; + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + count = 0; + + legend.on( 'change', onChange ); + + legend.padding = 10; + t.strictEqual( count, 1, 'returns expected value' ); + + legend.padding = 20; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + legend.padding = 20; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.properties.js b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.properties.js new file mode 100644 index 000000000000..0d3bee86601f --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.properties.js @@ -0,0 +1,156 @@ +/** +* @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 Legend = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Legend, '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 Legend({ + 'fill': 'colorScale' + }); + 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 props; + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + props = legend.properties; + + t.strictEqual( isArray( props ), true, 'returns expected value' ); + + expected = [ + 'aria', + 'clipHeight', + 'columnPadding', + 'columns', + 'cornerRadius', + 'description', + 'direction', + 'encode', + 'fill', + 'fillColor', + 'format', + 'formatType', + 'gradientLength', + 'gradientOpacity', + 'gradientStrokeColor', + 'gradientStrokeWidth', + 'gradientThickness', + 'gridAlign', + 'labelAlign', + 'labelBaseline', + 'labelColor', + 'labelFont', + 'labelFontSize', + 'labelFontStyle', + 'labelFontWeight', + 'labelLimit', + 'labelOffset', + 'labelOpacity', + 'labelOverlap', + 'labelSeparation', + 'legendX', + 'legendY', + 'offset', + 'opacity', + 'orient', + 'padding', + 'rowPadding', + 'shape', + 'size', + 'stroke', + 'strokeColor', + 'strokeDash', + 'strokeWidth', + 'symbolDash', + 'symbolDashOffset', + 'symbolFillColor', + 'symbolLimit', + 'symbolOffset', + 'symbolOpacity', + 'symbolSize', + 'symbolStrokeColor', + 'symbolStrokeWidth', + 'symbolType', + 'tickCount', + 'tickMinStep', + 'title', + 'titleAlign', + 'titleAnchor', + 'titleBaseline', + 'titleColor', + 'titleFont', + 'titleFontSize', + 'titleFontStyle', + 'titleFontWeight', + 'titleLimit', + 'titleLineHeight', + 'titleOpacity', + 'titleOrient', + 'titlePadding', + 'type', + 'values', + '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 legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + props1 = legend.properties; + props2 = legend.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/legend/ctor/test/test.row_padding.js b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.row_padding.js new file mode 100644 index 000000000000..7f0c39af5935 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.row_padding.js @@ -0,0 +1,144 @@ +/** +* @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 isUndefined = require( '@stdlib/assert/is-undefined' ); +var isNumber = require( '@stdlib/assert/is-number' ).isPrimitive; +var Legend = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Legend, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `rowPadding` property', function test( t ) { + var v; + + v = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( hasOwnProp( v, 'rowPadding' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'rowPadding' ), true, 'returns expected value' ); + t.strictEqual( isUndefined( v.rowPadding ), true, 'returns expected value' ); + + v = new Legend({ + 'fill': 'colorScale', + 'rowPadding': 10 + }); + t.strictEqual( isNumber( v.rowPadding ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the constructor returns an instance having a `rowPadding` property which throws an error if set to an invalid value', function test( t ) { + var values; + var i; + + values = [ + 'beep', + 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 legend = new Legend({ + 'fill': 'colorScale' + }); + legend.rowPadding = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `rowPadding` property', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( isUndefined( legend.rowPadding ), true, 'returns expected value' ); + + legend = new Legend({ + 'fill': 'colorScale', + 'rowPadding': 10 + }); + t.strictEqual( legend.rowPadding, 10, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `rowPadding` property which can be set to a valid value', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + + legend.rowPadding = 10; + t.strictEqual( legend.rowPadding, 10, 'returns expected value' ); + + legend.rowPadding = 20; + t.strictEqual( legend.rowPadding, 20, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `rowPadding` property is set to a new value', function test( t ) { + var count; + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + count = 0; + + legend.on( 'change', onChange ); + + legend.rowPadding = 10; + t.strictEqual( count, 1, 'returns expected value' ); + + legend.rowPadding = 20; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + legend.rowPadding = 20; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.shape.js b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.shape.js new file mode 100644 index 000000000000..a709d628b765 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.shape.js @@ -0,0 +1,145 @@ +/** +* @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 isUndefined = require( '@stdlib/assert/is-undefined' ); +var isString = require( '@stdlib/assert/is-string' ).isPrimitive; +var Legend = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Legend, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `shape` property', function test( t ) { + var v; + + v = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( hasOwnProp( v, 'shape' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'shape' ), true, 'returns expected value' ); + t.strictEqual( isUndefined( v.shape ), true, 'returns expected value' ); + + v = new Legend({ + 'fill': 'colorScale', + 'shape': 'beep' + }); + t.strictEqual( isString( v.shape ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the constructor returns an instance having a `shape` 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 legend = new Legend({ + 'fill': 'colorScale' + }); + legend.shape = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `shape` property', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( isUndefined( legend.shape ), true, 'returns expected value' ); + + legend = new Legend({ + 'fill': 'colorScale', + 'shape': 'testValue' + }); + t.strictEqual( legend.shape, 'testValue', 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `shape` property which can be set to a string', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + + legend.shape = 'beep'; + t.strictEqual( legend.shape, 'beep', 'returns expected value' ); + + legend.shape = 'boop'; + t.strictEqual( legend.shape, 'boop', 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `shape` property is set to a new value', function test( t ) { + var count; + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + count = 0; + + legend.on( 'change', onChange ); + + legend.shape = 'beep'; + t.strictEqual( count, 1, 'returns expected value' ); + + legend.shape = 'boop'; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + legend.shape = 'boop'; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.size.js b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.size.js new file mode 100644 index 000000000000..4c410ccb0221 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.size.js @@ -0,0 +1,145 @@ +/** +* @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 isUndefined = require( '@stdlib/assert/is-undefined' ); +var isString = require( '@stdlib/assert/is-string' ).isPrimitive; +var Legend = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Legend, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `size` property', function test( t ) { + var v; + + v = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( hasOwnProp( v, 'size' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'size' ), true, 'returns expected value' ); + t.strictEqual( isUndefined( v.size ), true, 'returns expected value' ); + + v = new Legend({ + 'fill': 'colorScale', + 'size': 'beep' + }); + t.strictEqual( isString( v.size ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the constructor returns an instance having a `size` 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 legend = new Legend({ + 'fill': 'colorScale' + }); + legend.size = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `size` property', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( isUndefined( legend.size ), true, 'returns expected value' ); + + legend = new Legend({ + 'fill': 'colorScale', + 'size': 'testValue' + }); + t.strictEqual( legend.size, 'testValue', 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `size` property which can be set to a string', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + + legend.size = 'beep'; + t.strictEqual( legend.size, 'beep', 'returns expected value' ); + + legend.size = 'boop'; + t.strictEqual( legend.size, 'boop', 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `size` property is set to a new value', function test( t ) { + var count; + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + count = 0; + + legend.on( 'change', onChange ); + + legend.size = 'beep'; + t.strictEqual( count, 1, 'returns expected value' ); + + legend.size = 'boop'; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + legend.size = 'boop'; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.stroke.js b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.stroke.js new file mode 100644 index 000000000000..fc1eedfb08be --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.stroke.js @@ -0,0 +1,145 @@ +/** +* @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 isUndefined = require( '@stdlib/assert/is-undefined' ); +var isString = require( '@stdlib/assert/is-string' ).isPrimitive; +var Legend = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Legend, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `stroke` property', function test( t ) { + var v; + + v = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( hasOwnProp( v, 'stroke' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'stroke' ), true, 'returns expected value' ); + t.strictEqual( isUndefined( v.stroke ), true, 'returns expected value' ); + + v = new Legend({ + 'fill': 'colorScale', + 'stroke': 'beep' + }); + t.strictEqual( isString( v.stroke ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the constructor returns an instance having a `stroke` 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 legend = new Legend({ + 'fill': 'colorScale' + }); + legend.stroke = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `stroke` property', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( isUndefined( legend.stroke ), true, 'returns expected value' ); + + legend = new Legend({ + 'fill': 'colorScale', + 'stroke': 'testValue' + }); + t.strictEqual( legend.stroke, 'testValue', 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `stroke` property which can be set to a string', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + + legend.stroke = 'beep'; + t.strictEqual( legend.stroke, 'beep', 'returns expected value' ); + + legend.stroke = 'boop'; + t.strictEqual( legend.stroke, 'boop', 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `stroke` property is set to a new value', function test( t ) { + var count; + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + count = 0; + + legend.on( 'change', onChange ); + + legend.stroke = 'beep'; + t.strictEqual( count, 1, 'returns expected value' ); + + legend.stroke = 'boop'; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + legend.stroke = 'boop'; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.stroke_color.js b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.stroke_color.js new file mode 100644 index 000000000000..61ccf3e7103e --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.stroke_color.js @@ -0,0 +1,145 @@ +/** +* @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 isUndefined = require( '@stdlib/assert/is-undefined' ); +var isString = require( '@stdlib/assert/is-string' ).isPrimitive; +var Legend = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Legend, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `strokeColor` property', function test( t ) { + var v; + + v = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( hasOwnProp( v, 'strokeColor' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'strokeColor' ), true, 'returns expected value' ); + t.strictEqual( isUndefined( v.strokeColor ), true, 'returns expected value' ); + + v = new Legend({ + 'fill': 'colorScale', + 'strokeColor': 'beep' + }); + t.strictEqual( isString( v.strokeColor ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the constructor returns an instance having a `strokeColor` 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 legend = new Legend({ + 'fill': 'colorScale' + }); + legend.strokeColor = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `strokeColor` property', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( isUndefined( legend.strokeColor ), true, 'returns expected value' ); + + legend = new Legend({ + 'fill': 'colorScale', + 'strokeColor': 'testValue' + }); + t.strictEqual( legend.strokeColor, 'testValue', 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `strokeColor` property which can be set to a string', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + + legend.strokeColor = 'beep'; + t.strictEqual( legend.strokeColor, 'beep', 'returns expected value' ); + + legend.strokeColor = 'boop'; + t.strictEqual( legend.strokeColor, 'boop', 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `strokeColor` property is set to a new value', function test( t ) { + var count; + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + count = 0; + + legend.on( 'change', onChange ); + + legend.strokeColor = 'beep'; + t.strictEqual( count, 1, 'returns expected value' ); + + legend.strokeColor = 'boop'; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + legend.strokeColor = 'boop'; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.stroke_dash.js b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.stroke_dash.js new file mode 100644 index 000000000000..a13ba90943dd --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.stroke_dash.js @@ -0,0 +1,145 @@ +/** +* @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 isUndefined = require( '@stdlib/assert/is-undefined' ); +var isString = require( '@stdlib/assert/is-string' ).isPrimitive; +var Legend = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Legend, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `strokeDash` property', function test( t ) { + var v; + + v = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( hasOwnProp( v, 'strokeDash' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'strokeDash' ), true, 'returns expected value' ); + t.strictEqual( isUndefined( v.strokeDash ), true, 'returns expected value' ); + + v = new Legend({ + 'fill': 'colorScale', + 'strokeDash': 'beep' + }); + t.strictEqual( isString( v.strokeDash ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the constructor returns an instance having a `strokeDash` 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 legend = new Legend({ + 'fill': 'colorScale' + }); + legend.strokeDash = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `strokeDash` property', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( isUndefined( legend.strokeDash ), true, 'returns expected value' ); + + legend = new Legend({ + 'fill': 'colorScale', + 'strokeDash': 'testValue' + }); + t.strictEqual( legend.strokeDash, 'testValue', 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `strokeDash` property which can be set to a string', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + + legend.strokeDash = 'beep'; + t.strictEqual( legend.strokeDash, 'beep', 'returns expected value' ); + + legend.strokeDash = 'boop'; + t.strictEqual( legend.strokeDash, 'boop', 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `strokeDash` property is set to a new value', function test( t ) { + var count; + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + count = 0; + + legend.on( 'change', onChange ); + + legend.strokeDash = 'beep'; + t.strictEqual( count, 1, 'returns expected value' ); + + legend.strokeDash = 'boop'; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + legend.strokeDash = 'boop'; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.stroke_width.js b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.stroke_width.js new file mode 100644 index 000000000000..47cc504aac2a --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.stroke_width.js @@ -0,0 +1,145 @@ +/** +* @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 isUndefined = require( '@stdlib/assert/is-undefined' ); +var isString = require( '@stdlib/assert/is-string' ).isPrimitive; +var Legend = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Legend, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `strokeWidth` property', function test( t ) { + var v; + + v = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( hasOwnProp( v, 'strokeWidth' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'strokeWidth' ), true, 'returns expected value' ); + t.strictEqual( isUndefined( v.strokeWidth ), true, 'returns expected value' ); + + v = new Legend({ + 'fill': 'colorScale', + 'strokeWidth': 'beep' + }); + t.strictEqual( isString( v.strokeWidth ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the constructor returns an instance having a `strokeWidth` 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 legend = new Legend({ + 'fill': 'colorScale' + }); + legend.strokeWidth = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `strokeWidth` property', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( isUndefined( legend.strokeWidth ), true, 'returns expected value' ); + + legend = new Legend({ + 'fill': 'colorScale', + 'strokeWidth': 'testValue' + }); + t.strictEqual( legend.strokeWidth, 'testValue', 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `strokeWidth` property which can be set to a string', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + + legend.strokeWidth = 'beep'; + t.strictEqual( legend.strokeWidth, 'beep', 'returns expected value' ); + + legend.strokeWidth = 'boop'; + t.strictEqual( legend.strokeWidth, 'boop', 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `strokeWidth` property is set to a new value', function test( t ) { + var count; + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + count = 0; + + legend.on( 'change', onChange ); + + legend.strokeWidth = 'beep'; + t.strictEqual( count, 1, 'returns expected value' ); + + legend.strokeWidth = 'boop'; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + legend.strokeWidth = 'boop'; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.symbol_dash.js b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.symbol_dash.js new file mode 100644 index 000000000000..ef1aa1b9053c --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.symbol_dash.js @@ -0,0 +1,139 @@ +/** +* @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 Legend = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Legend, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `symbolDash` property', function test( t ) { + var v; + + v = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( hasOwnProp( v, 'symbolDash' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'symbolDash' ), true, 'returns expected value' ); + t.strictEqual( isArray( v.symbolDash ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the constructor returns an instance having a `symbolDash` property which throws an error if set to an invalid value', function test( t ) { + var values; + var i; + + values = [ + 'beep', + 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 legend = new Legend({ + 'fill': 'colorScale' + }); + legend.symbolDash = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `symbolDash` property', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + t.deepEqual( legend.symbolDash, [], 'returns expected value' ); + + legend = new Legend({ + 'fill': 'colorScale', + 'symbolDash': [ 2, 4 ] + }); + t.deepEqual( legend.symbolDash, [ 2, 4 ], 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `symbolDash` property which can be set to a valid value', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + + legend.symbolDash = [ 2, 4 ]; + t.deepEqual( legend.symbolDash, [ 2, 4 ], 'returns expected value' ); + + legend.symbolDash = [ 6, 2 ]; + t.deepEqual( legend.symbolDash, [ 6, 2 ], 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `symbolDash` property is set to a new value', function test( t ) { + var count; + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + count = 0; + + legend.on( 'change', onChange ); + + legend.symbolDash = [ 2, 4 ]; + t.strictEqual( count, 1, 'returns expected value' ); + + legend.symbolDash = [ 6, 2 ]; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + legend.symbolDash = [ 6, 2 ]; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.symbol_dash_offset.js b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.symbol_dash_offset.js new file mode 100644 index 000000000000..97758d9257fe --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.symbol_dash_offset.js @@ -0,0 +1,144 @@ +/** +* @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 isUndefined = require( '@stdlib/assert/is-undefined' ); +var isNumber = require( '@stdlib/assert/is-number' ).isPrimitive; +var Legend = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Legend, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `symbolDashOffset` property', function test( t ) { + var v; + + v = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( hasOwnProp( v, 'symbolDashOffset' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'symbolDashOffset' ), true, 'returns expected value' ); + t.strictEqual( isUndefined( v.symbolDashOffset ), true, 'returns expected value' ); + + v = new Legend({ + 'fill': 'colorScale', + 'symbolDashOffset': 10 + }); + t.strictEqual( isNumber( v.symbolDashOffset ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the constructor returns an instance having a `symbolDashOffset` property which throws an error if set to an invalid value', function test( t ) { + var values; + var i; + + values = [ + 'beep', + 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 legend = new Legend({ + 'fill': 'colorScale' + }); + legend.symbolDashOffset = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `symbolDashOffset` property', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( isUndefined( legend.symbolDashOffset ), true, 'returns expected value' ); + + legend = new Legend({ + 'fill': 'colorScale', + 'symbolDashOffset': 10 + }); + t.strictEqual( legend.symbolDashOffset, 10, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `symbolDashOffset` property which can be set to a valid value', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + + legend.symbolDashOffset = 10; + t.strictEqual( legend.symbolDashOffset, 10, 'returns expected value' ); + + legend.symbolDashOffset = 20; + t.strictEqual( legend.symbolDashOffset, 20, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `symbolDashOffset` property is set to a new value', function test( t ) { + var count; + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + count = 0; + + legend.on( 'change', onChange ); + + legend.symbolDashOffset = 10; + t.strictEqual( count, 1, 'returns expected value' ); + + legend.symbolDashOffset = 20; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + legend.symbolDashOffset = 20; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.symbol_fill_color.js b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.symbol_fill_color.js new file mode 100644 index 000000000000..a1b9bcf69d06 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.symbol_fill_color.js @@ -0,0 +1,145 @@ +/** +* @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 isUndefined = require( '@stdlib/assert/is-undefined' ); +var isString = require( '@stdlib/assert/is-string' ).isPrimitive; +var Legend = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Legend, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `symbolFillColor` property', function test( t ) { + var v; + + v = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( hasOwnProp( v, 'symbolFillColor' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'symbolFillColor' ), true, 'returns expected value' ); + t.strictEqual( isUndefined( v.symbolFillColor ), true, 'returns expected value' ); + + v = new Legend({ + 'fill': 'colorScale', + 'symbolFillColor': 'beep' + }); + t.strictEqual( isString( v.symbolFillColor ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the constructor returns an instance having a `symbolFillColor` 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 legend = new Legend({ + 'fill': 'colorScale' + }); + legend.symbolFillColor = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `symbolFillColor` property', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( isUndefined( legend.symbolFillColor ), true, 'returns expected value' ); + + legend = new Legend({ + 'fill': 'colorScale', + 'symbolFillColor': 'testValue' + }); + t.strictEqual( legend.symbolFillColor, 'testValue', 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `symbolFillColor` property which can be set to a string', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + + legend.symbolFillColor = 'beep'; + t.strictEqual( legend.symbolFillColor, 'beep', 'returns expected value' ); + + legend.symbolFillColor = 'boop'; + t.strictEqual( legend.symbolFillColor, 'boop', 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `symbolFillColor` property is set to a new value', function test( t ) { + var count; + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + count = 0; + + legend.on( 'change', onChange ); + + legend.symbolFillColor = 'beep'; + t.strictEqual( count, 1, 'returns expected value' ); + + legend.symbolFillColor = 'boop'; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + legend.symbolFillColor = 'boop'; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.symbol_limit.js b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.symbol_limit.js new file mode 100644 index 000000000000..cb95458adca2 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.symbol_limit.js @@ -0,0 +1,144 @@ +/** +* @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 isUndefined = require( '@stdlib/assert/is-undefined' ); +var isNumber = require( '@stdlib/assert/is-number' ).isPrimitive; +var Legend = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Legend, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `symbolLimit` property', function test( t ) { + var v; + + v = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( hasOwnProp( v, 'symbolLimit' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'symbolLimit' ), true, 'returns expected value' ); + t.strictEqual( isUndefined( v.symbolLimit ), true, 'returns expected value' ); + + v = new Legend({ + 'fill': 'colorScale', + 'symbolLimit': 10 + }); + t.strictEqual( isNumber( v.symbolLimit ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the constructor returns an instance having a `symbolLimit` property which throws an error if set to an invalid value', function test( t ) { + var values; + var i; + + values = [ + 'beep', + 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 legend = new Legend({ + 'fill': 'colorScale' + }); + legend.symbolLimit = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `symbolLimit` property', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( isUndefined( legend.symbolLimit ), true, 'returns expected value' ); + + legend = new Legend({ + 'fill': 'colorScale', + 'symbolLimit': 10 + }); + t.strictEqual( legend.symbolLimit, 10, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `symbolLimit` property which can be set to a valid value', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + + legend.symbolLimit = 10; + t.strictEqual( legend.symbolLimit, 10, 'returns expected value' ); + + legend.symbolLimit = 20; + t.strictEqual( legend.symbolLimit, 20, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `symbolLimit` property is set to a new value', function test( t ) { + var count; + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + count = 0; + + legend.on( 'change', onChange ); + + legend.symbolLimit = 10; + t.strictEqual( count, 1, 'returns expected value' ); + + legend.symbolLimit = 20; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + legend.symbolLimit = 20; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.symbol_offset.js b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.symbol_offset.js new file mode 100644 index 000000000000..e751ac4d29f6 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.symbol_offset.js @@ -0,0 +1,144 @@ +/** +* @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 isUndefined = require( '@stdlib/assert/is-undefined' ); +var isNumber = require( '@stdlib/assert/is-number' ).isPrimitive; +var Legend = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Legend, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `symbolOffset` property', function test( t ) { + var v; + + v = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( hasOwnProp( v, 'symbolOffset' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'symbolOffset' ), true, 'returns expected value' ); + t.strictEqual( isUndefined( v.symbolOffset ), true, 'returns expected value' ); + + v = new Legend({ + 'fill': 'colorScale', + 'symbolOffset': 10 + }); + t.strictEqual( isNumber( v.symbolOffset ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the constructor returns an instance having a `symbolOffset` property which throws an error if set to an invalid value', function test( t ) { + var values; + var i; + + values = [ + 'beep', + 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 legend = new Legend({ + 'fill': 'colorScale' + }); + legend.symbolOffset = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `symbolOffset` property', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( isUndefined( legend.symbolOffset ), true, 'returns expected value' ); + + legend = new Legend({ + 'fill': 'colorScale', + 'symbolOffset': 10 + }); + t.strictEqual( legend.symbolOffset, 10, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `symbolOffset` property which can be set to a valid value', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + + legend.symbolOffset = 10; + t.strictEqual( legend.symbolOffset, 10, 'returns expected value' ); + + legend.symbolOffset = 20; + t.strictEqual( legend.symbolOffset, 20, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `symbolOffset` property is set to a new value', function test( t ) { + var count; + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + count = 0; + + legend.on( 'change', onChange ); + + legend.symbolOffset = 10; + t.strictEqual( count, 1, 'returns expected value' ); + + legend.symbolOffset = 20; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + legend.symbolOffset = 20; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.symbol_opacity.js b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.symbol_opacity.js new file mode 100644 index 000000000000..faf36c1e5fb8 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.symbol_opacity.js @@ -0,0 +1,144 @@ +/** +* @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 isUndefined = require( '@stdlib/assert/is-undefined' ); +var isNumber = require( '@stdlib/assert/is-number' ).isPrimitive; +var Legend = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Legend, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `symbolOpacity` property', function test( t ) { + var v; + + v = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( hasOwnProp( v, 'symbolOpacity' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'symbolOpacity' ), true, 'returns expected value' ); + t.strictEqual( isUndefined( v.symbolOpacity ), true, 'returns expected value' ); + + v = new Legend({ + 'fill': 'colorScale', + 'symbolOpacity': 10 + }); + t.strictEqual( isNumber( v.symbolOpacity ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the constructor returns an instance having a `symbolOpacity` property which throws an error if set to an invalid value', function test( t ) { + var values; + var i; + + values = [ + 'beep', + 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 legend = new Legend({ + 'fill': 'colorScale' + }); + legend.symbolOpacity = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `symbolOpacity` property', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( isUndefined( legend.symbolOpacity ), true, 'returns expected value' ); + + legend = new Legend({ + 'fill': 'colorScale', + 'symbolOpacity': 10 + }); + t.strictEqual( legend.symbolOpacity, 10, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `symbolOpacity` property which can be set to a valid value', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + + legend.symbolOpacity = 10; + t.strictEqual( legend.symbolOpacity, 10, 'returns expected value' ); + + legend.symbolOpacity = 20; + t.strictEqual( legend.symbolOpacity, 20, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `symbolOpacity` property is set to a new value', function test( t ) { + var count; + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + count = 0; + + legend.on( 'change', onChange ); + + legend.symbolOpacity = 10; + t.strictEqual( count, 1, 'returns expected value' ); + + legend.symbolOpacity = 20; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + legend.symbolOpacity = 20; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.symbol_size.js b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.symbol_size.js new file mode 100644 index 000000000000..ca657964accb --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.symbol_size.js @@ -0,0 +1,146 @@ +/** +* @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 isUndefined = require( '@stdlib/assert/is-undefined' ); +var isNonNegativeNumber = require( '@stdlib/assert/is-nonnegative-number' ).isPrimitive; +var Legend = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Legend, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `symbolSize` property', function test( t ) { + var v; + + v = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( hasOwnProp( v, 'symbolSize' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'symbolSize' ), true, 'returns expected value' ); + t.strictEqual( isUndefined( v.symbolSize ), true, 'returns expected value' ); + + v = new Legend({ + 'fill': 'colorScale', + 'symbolSize': 10 + }); + t.strictEqual( isNonNegativeNumber( v.symbolSize ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the constructor returns an instance having a `symbolSize` property which throws an error if set to an invalid value', function test( t ) { + var values; + var i; + + values = [ + 'beep', + -1, + 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 legend = new Legend({ + 'fill': 'colorScale' + }); + legend.symbolSize = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `symbolSize` property', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( isUndefined( legend.symbolSize ), true, 'returns expected value' ); + + legend = new Legend({ + 'fill': 'colorScale', + 'symbolSize': 10 + }); + t.strictEqual( legend.symbolSize, 10, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `symbolSize` property which can be set to a valid value', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + + legend.symbolSize = 10; + t.strictEqual( legend.symbolSize, 10, 'returns expected value' ); + + legend.symbolSize = 20; + t.strictEqual( legend.symbolSize, 20, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `symbolSize` property is set to a new value', function test( t ) { + var count; + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + count = 0; + + legend.on( 'change', onChange ); + + legend.symbolSize = 10; + t.strictEqual( count, 1, 'returns expected value' ); + + legend.symbolSize = 20; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + legend.symbolSize = 20; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.symbol_stroke_color.js b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.symbol_stroke_color.js new file mode 100644 index 000000000000..85535d37454f --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.symbol_stroke_color.js @@ -0,0 +1,145 @@ +/** +* @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 isUndefined = require( '@stdlib/assert/is-undefined' ); +var isString = require( '@stdlib/assert/is-string' ).isPrimitive; +var Legend = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Legend, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `symbolStrokeColor` property', function test( t ) { + var v; + + v = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( hasOwnProp( v, 'symbolStrokeColor' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'symbolStrokeColor' ), true, 'returns expected value' ); + t.strictEqual( isUndefined( v.symbolStrokeColor ), true, 'returns expected value' ); + + v = new Legend({ + 'fill': 'colorScale', + 'symbolStrokeColor': 'beep' + }); + t.strictEqual( isString( v.symbolStrokeColor ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the constructor returns an instance having a `symbolStrokeColor` 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 legend = new Legend({ + 'fill': 'colorScale' + }); + legend.symbolStrokeColor = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `symbolStrokeColor` property', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( isUndefined( legend.symbolStrokeColor ), true, 'returns expected value' ); + + legend = new Legend({ + 'fill': 'colorScale', + 'symbolStrokeColor': 'testValue' + }); + t.strictEqual( legend.symbolStrokeColor, 'testValue', 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `symbolStrokeColor` property which can be set to a string', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + + legend.symbolStrokeColor = 'beep'; + t.strictEqual( legend.symbolStrokeColor, 'beep', 'returns expected value' ); + + legend.symbolStrokeColor = 'boop'; + t.strictEqual( legend.symbolStrokeColor, 'boop', 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `symbolStrokeColor` property is set to a new value', function test( t ) { + var count; + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + count = 0; + + legend.on( 'change', onChange ); + + legend.symbolStrokeColor = 'beep'; + t.strictEqual( count, 1, 'returns expected value' ); + + legend.symbolStrokeColor = 'boop'; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + legend.symbolStrokeColor = 'boop'; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.symbol_stroke_width.js b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.symbol_stroke_width.js new file mode 100644 index 000000000000..432cdfda06cb --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.symbol_stroke_width.js @@ -0,0 +1,146 @@ +/** +* @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 isUndefined = require( '@stdlib/assert/is-undefined' ); +var isNonNegativeNumber = require( '@stdlib/assert/is-nonnegative-number' ).isPrimitive; +var Legend = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Legend, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `symbolStrokeWidth` property', function test( t ) { + var v; + + v = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( hasOwnProp( v, 'symbolStrokeWidth' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'symbolStrokeWidth' ), true, 'returns expected value' ); + t.strictEqual( isUndefined( v.symbolStrokeWidth ), true, 'returns expected value' ); + + v = new Legend({ + 'fill': 'colorScale', + 'symbolStrokeWidth': 10 + }); + t.strictEqual( isNonNegativeNumber( v.symbolStrokeWidth ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the constructor returns an instance having a `symbolStrokeWidth` property which throws an error if set to an invalid value', function test( t ) { + var values; + var i; + + values = [ + 'beep', + -1, + 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 legend = new Legend({ + 'fill': 'colorScale' + }); + legend.symbolStrokeWidth = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `symbolStrokeWidth` property', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( isUndefined( legend.symbolStrokeWidth ), true, 'returns expected value' ); + + legend = new Legend({ + 'fill': 'colorScale', + 'symbolStrokeWidth': 10 + }); + t.strictEqual( legend.symbolStrokeWidth, 10, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `symbolStrokeWidth` property which can be set to a valid value', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + + legend.symbolStrokeWidth = 10; + t.strictEqual( legend.symbolStrokeWidth, 10, 'returns expected value' ); + + legend.symbolStrokeWidth = 20; + t.strictEqual( legend.symbolStrokeWidth, 20, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `symbolStrokeWidth` property is set to a new value', function test( t ) { + var count; + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + count = 0; + + legend.on( 'change', onChange ); + + legend.symbolStrokeWidth = 10; + t.strictEqual( count, 1, 'returns expected value' ); + + legend.symbolStrokeWidth = 20; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + legend.symbolStrokeWidth = 20; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.symbol_type.js b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.symbol_type.js new file mode 100644 index 000000000000..702155719091 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.symbol_type.js @@ -0,0 +1,146 @@ +/** +* @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 isUndefined = require( '@stdlib/assert/is-undefined' ); +var isString = require( '@stdlib/assert/is-string' ).isPrimitive; +var Legend = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Legend, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `symbolType` property', function test( t ) { + var v; + + v = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( hasOwnProp( v, 'symbolType' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'symbolType' ), true, 'returns expected value' ); + t.strictEqual( isUndefined( v.symbolType ), true, 'returns expected value' ); + + v = new Legend({ + 'fill': 'colorScale', + 'symbolType': 'circle' + }); + t.strictEqual( isString( v.symbolType ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the constructor returns an instance having a `symbolType` property which throws an error if set to an invalid value', function test( t ) { + var values; + var i; + + values = [ + 'beep', + 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 legend = new Legend({ + 'fill': 'colorScale' + }); + legend.symbolType = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `symbolType` property', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( isUndefined( legend.symbolType ), true, 'returns expected value' ); + + legend = new Legend({ + 'fill': 'colorScale', + 'symbolType': 'circle' + }); + t.strictEqual( legend.symbolType, 'circle', 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `symbolType` property which can be set to a valid value', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + + legend.symbolType = 'circle'; + t.strictEqual( legend.symbolType, 'circle', 'returns expected value' ); + + legend.symbolType = 'square'; + t.strictEqual( legend.symbolType, 'square', 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `symbolType` property is set to a new value', function test( t ) { + var count; + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + count = 0; + + legend.on( 'change', onChange ); + + legend.symbolType = 'circle'; + t.strictEqual( count, 1, 'returns expected value' ); + + legend.symbolType = 'square'; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + legend.symbolType = 'square'; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.tick_count.js b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.tick_count.js new file mode 100644 index 000000000000..9308c25db331 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.tick_count.js @@ -0,0 +1,163 @@ +/** +* @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 isUndefined = require( '@stdlib/assert/is-undefined' ); +var isString = require( '@stdlib/assert/is-string' ).isPrimitive; +var isNumber = require( '@stdlib/assert/is-number' ).isPrimitive; +var isObject = require( '@stdlib/assert/is-object' ); +var Legend = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Legend, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `tickCount` property', function test( t ) { + var v; + + v = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( hasOwnProp( v, 'tickCount' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'tickCount' ), true, 'returns expected value' ); + t.strictEqual( isUndefined( v.tickCount ), true, 'returns expected value' ); + + v = new Legend({ + 'fill': 'colorScale', + 'tickCount': 10 + }); + t.strictEqual( isNumber( v.tickCount ), true, 'returns expected value' ); + + v = new Legend({ + 'fill': 'colorScale', + 'tickCount': 'day' + }); + t.strictEqual( isString( v.tickCount ), true, 'returns expected value' ); + + v = new Legend({ + 'fill': 'colorScale', + 'tickCount': { + 'interval': 'Month' + } + }); + t.strictEqual( isObject( v.tickCount ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the constructor returns an instance having a `tickCount` 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 legend = new Legend({ + 'fill': 'colorScale' + }); + legend.tickCount = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `tickCount` property', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( isUndefined( legend.tickCount ), true, 'returns expected value' ); + + legend = new Legend({ + 'fill': 'colorScale', + 'tickCount': 10 + }); + t.strictEqual( legend.tickCount, 10, 'returns expected value' ); + + legend = new Legend({ + 'fill': 'colorScale', + 'tickCount': 'day' + }); + t.strictEqual( legend.tickCount, 'day', 'returns expected value' ); + t.end(); +}); + +tape( 'the constructor returns an instance having a `tickCount` property which can be set to a valid value', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + + legend.tickCount = 10; + t.strictEqual( legend.tickCount, 10, 'returns expected value' ); + + legend.tickCount = 'day'; + t.strictEqual( legend.tickCount, 'day', 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `tickCount` property is set to a new value', function test( t ) { + var count; + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + count = 0; + + legend.on( 'change', onChange ); + + legend.tickCount = 10; + t.strictEqual( count, 1, 'returns expected value' ); + + legend.tickCount = 20; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + legend.tickCount = 20; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.tick_min_step.js b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.tick_min_step.js new file mode 100644 index 000000000000..e392ebebda51 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.tick_min_step.js @@ -0,0 +1,144 @@ +/** +* @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 isUndefined = require( '@stdlib/assert/is-undefined' ); +var isNumber = require( '@stdlib/assert/is-number' ).isPrimitive; +var Legend = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Legend, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `tickMinStep` property', function test( t ) { + var v; + + v = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( hasOwnProp( v, 'tickMinStep' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'tickMinStep' ), true, 'returns expected value' ); + t.strictEqual( isUndefined( v.tickMinStep ), true, 'returns expected value' ); + + v = new Legend({ + 'fill': 'colorScale', + 'tickMinStep': 10 + }); + t.strictEqual( isNumber( v.tickMinStep ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the constructor returns an instance having a `tickMinStep` property which throws an error if set to an invalid value', function test( t ) { + var values; + var i; + + values = [ + 'beep', + 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 legend = new Legend({ + 'fill': 'colorScale' + }); + legend.tickMinStep = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `tickMinStep` property', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( isUndefined( legend.tickMinStep ), true, 'returns expected value' ); + + legend = new Legend({ + 'fill': 'colorScale', + 'tickMinStep': 10 + }); + t.strictEqual( legend.tickMinStep, 10, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `tickMinStep` property which can be set to a valid value', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + + legend.tickMinStep = 10; + t.strictEqual( legend.tickMinStep, 10, 'returns expected value' ); + + legend.tickMinStep = 20; + t.strictEqual( legend.tickMinStep, 20, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `tickMinStep` property is set to a new value', function test( t ) { + var count; + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + count = 0; + + legend.on( 'change', onChange ); + + legend.tickMinStep = 10; + t.strictEqual( count, 1, 'returns expected value' ); + + legend.tickMinStep = 20; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + legend.tickMinStep = 20; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.title.js b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.title.js new file mode 100644 index 000000000000..fd43c4a0b98c --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.title.js @@ -0,0 +1,145 @@ +/** +* @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 Legend = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Legend, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `title` property', function test( t ) { + var v; + + v = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( hasOwnProp( v, 'title' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'title' ), true, 'returns expected value' ); + t.strictEqual( isArray( v.title ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the constructor returns an instance having a `title` property which throws an error if set to an invalid value', function test( t ) { + var values; + var i; + + values = [ + 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 legend = new Legend({ + 'fill': 'colorScale' + }); + legend.title = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `title` property', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + t.deepEqual( legend.title, [ '' ], 'returns expected value' ); + + legend = new Legend({ + 'fill': 'colorScale', + 'title': 'Legend Title' + }); + t.deepEqual( legend.title, [ 'Legend Title' ], 'returns expected value' ); + + legend = new Legend({ + 'fill': 'colorScale', + 'title': [ 'Line 1', 'Line 2' ] + }); + t.deepEqual( legend.title, [ 'Line 1', 'Line 2' ], 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `title` property which can be set to a valid value', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + + legend.title = 'Legend Title'; + t.deepEqual( legend.title, [ 'Legend Title' ], 'returns expected value' ); + + legend.title = [ 'Line 1', 'Line 2' ]; + t.deepEqual( legend.title, [ 'Line 1', 'Line 2' ], 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `title` property is set to a new value', function test( t ) { + var count; + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + count = 0; + + legend.on( 'change', onChange ); + + legend.title = 'Legend Title'; + t.strictEqual( count, 1, 'returns expected value' ); + + legend.title = [ 'Line 1', 'Line 2' ]; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + legend.title = [ 'Line 1', 'Line 2' ]; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.title_align.js b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.title_align.js new file mode 100644 index 000000000000..8fbbb05a4cfc --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.title_align.js @@ -0,0 +1,146 @@ +/** +* @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 isUndefined = require( '@stdlib/assert/is-undefined' ); +var isString = require( '@stdlib/assert/is-string' ).isPrimitive; +var Legend = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Legend, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `titleAlign` property', function test( t ) { + var v; + + v = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( hasOwnProp( v, 'titleAlign' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'titleAlign' ), true, 'returns expected value' ); + t.strictEqual( isUndefined( v.titleAlign ), true, 'returns expected value' ); + + v = new Legend({ + 'fill': 'colorScale', + 'titleAlign': 'left' + }); + t.strictEqual( isString( v.titleAlign ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the constructor returns an instance having a `titleAlign` property which throws an error if set to an invalid value', function test( t ) { + var values; + var i; + + values = [ + 'beep', + 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 legend = new Legend({ + 'fill': 'colorScale' + }); + legend.titleAlign = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `titleAlign` property', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( isUndefined( legend.titleAlign ), true, 'returns expected value' ); + + legend = new Legend({ + 'fill': 'colorScale', + 'titleAlign': 'left' + }); + t.strictEqual( legend.titleAlign, 'left', 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `titleAlign` property which can be set to a valid value', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + + legend.titleAlign = 'left'; + t.strictEqual( legend.titleAlign, 'left', 'returns expected value' ); + + legend.titleAlign = 'center'; + t.strictEqual( legend.titleAlign, 'center', 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `titleAlign` property is set to a new value', function test( t ) { + var count; + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + count = 0; + + legend.on( 'change', onChange ); + + legend.titleAlign = 'left'; + t.strictEqual( count, 1, 'returns expected value' ); + + legend.titleAlign = 'center'; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + legend.titleAlign = 'center'; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.title_anchor.js b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.title_anchor.js new file mode 100644 index 000000000000..bd2abfe3cb30 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.title_anchor.js @@ -0,0 +1,145 @@ +/** +* @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 isNull = require( '@stdlib/assert/is-null' ); +var Legend = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Legend, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `titleAnchor` property', function test( t ) { + var v; + + v = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( hasOwnProp( v, 'titleAnchor' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'titleAnchor' ), true, 'returns expected value' ); + t.strictEqual( isNull( v.titleAnchor ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the constructor returns an instance having a `titleAnchor` property which throws an error if set to an invalid value', function test( t ) { + var values; + var i; + + values = [ + 'beep', + 5, + NaN, + 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 legend = new Legend({ + 'fill': 'colorScale' + }); + legend.titleAnchor = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `titleAnchor` property', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( legend.titleAnchor, null, 'returns expected value' ); + + legend = new Legend({ + 'fill': 'colorScale', + 'titleAnchor': 'start' + }); + t.strictEqual( legend.titleAnchor, 'start', 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `titleAnchor` property which can be set to a valid value', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + + legend.titleAnchor = 'start'; + t.strictEqual( legend.titleAnchor, 'start', 'returns expected value' ); + + legend.titleAnchor = 'middle'; + t.strictEqual( legend.titleAnchor, 'middle', 'returns expected value' ); + + legend.titleAnchor = 'end'; + t.strictEqual( legend.titleAnchor, 'end', 'returns expected value' ); + + legend.titleAnchor = null; + t.strictEqual( legend.titleAnchor, null, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `titleAnchor` property is set to a new value', function test( t ) { + var count; + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + count = 0; + + legend.on( 'change', onChange ); + + legend.titleAnchor = 'start'; + t.strictEqual( count, 1, 'returns expected value' ); + + legend.titleAnchor = 'end'; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + legend.titleAnchor = 'end'; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.title_baseline.js b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.title_baseline.js new file mode 100644 index 000000000000..d4b8e21d6314 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.title_baseline.js @@ -0,0 +1,140 @@ +/** +* @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' ).isPrimitive; +var Legend = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Legend, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `titleBaseline` property', function test( t ) { + var v; + + v = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( hasOwnProp( v, 'titleBaseline' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'titleBaseline' ), true, 'returns expected value' ); + t.strictEqual( isString( v.titleBaseline ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the constructor returns an instance having a `titleBaseline` property which throws an error if set to an invalid value', function test( t ) { + var values; + var i; + + values = [ + 'beep', + 'boop', + 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 legend = new Legend({ + 'fill': 'colorScale' + }); + legend.titleBaseline = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `titleBaseline` property', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( legend.titleBaseline, 'alphabetic', 'returns expected value' ); + + legend = new Legend({ + 'fill': 'colorScale', + 'titleBaseline': 'top' + }); + t.strictEqual( legend.titleBaseline, 'top', 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `titleBaseline` property which can be set to a valid baseline', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + + legend.titleBaseline = 'top'; + t.strictEqual( legend.titleBaseline, 'top', 'returns expected value' ); + + legend.titleBaseline = 'bottom'; + t.strictEqual( legend.titleBaseline, 'bottom', 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `titleBaseline` property is set to a new value', function test( t ) { + var count; + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + count = 0; + + legend.on( 'change', onChange ); + + legend.titleBaseline = 'top'; + t.strictEqual( count, 1, 'returns expected value' ); + + legend.titleBaseline = 'bottom'; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + legend.titleBaseline = 'bottom'; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.title_color.js b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.title_color.js new file mode 100644 index 000000000000..459dfe2997da --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.title_color.js @@ -0,0 +1,145 @@ +/** +* @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 isUndefined = require( '@stdlib/assert/is-undefined' ); +var isString = require( '@stdlib/assert/is-string' ).isPrimitive; +var Legend = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Legend, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `titleColor` property', function test( t ) { + var v; + + v = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( hasOwnProp( v, 'titleColor' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'titleColor' ), true, 'returns expected value' ); + t.strictEqual( isUndefined( v.titleColor ), true, 'returns expected value' ); + + v = new Legend({ + 'fill': 'colorScale', + 'titleColor': 'beep' + }); + t.strictEqual( isString( v.titleColor ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the constructor returns an instance having a `titleColor` 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 legend = new Legend({ + 'fill': 'colorScale' + }); + legend.titleColor = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `titleColor` property', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( isUndefined( legend.titleColor ), true, 'returns expected value' ); + + legend = new Legend({ + 'fill': 'colorScale', + 'titleColor': 'testValue' + }); + t.strictEqual( legend.titleColor, 'testValue', 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `titleColor` property which can be set to a string', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + + legend.titleColor = 'beep'; + t.strictEqual( legend.titleColor, 'beep', 'returns expected value' ); + + legend.titleColor = 'boop'; + t.strictEqual( legend.titleColor, 'boop', 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `titleColor` property is set to a new value', function test( t ) { + var count; + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + count = 0; + + legend.on( 'change', onChange ); + + legend.titleColor = 'beep'; + t.strictEqual( count, 1, 'returns expected value' ); + + legend.titleColor = 'boop'; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + legend.titleColor = 'boop'; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.title_font.js b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.title_font.js new file mode 100644 index 000000000000..232a83a65bea --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.title_font.js @@ -0,0 +1,145 @@ +/** +* @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 isUndefined = require( '@stdlib/assert/is-undefined' ); +var isString = require( '@stdlib/assert/is-string' ).isPrimitive; +var Legend = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Legend, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `titleFont` property', function test( t ) { + var v; + + v = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( hasOwnProp( v, 'titleFont' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'titleFont' ), true, 'returns expected value' ); + t.strictEqual( isUndefined( v.titleFont ), true, 'returns expected value' ); + + v = new Legend({ + 'fill': 'colorScale', + 'titleFont': 'beep' + }); + t.strictEqual( isString( v.titleFont ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the constructor returns an instance having a `titleFont` 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 legend = new Legend({ + 'fill': 'colorScale' + }); + legend.titleFont = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `titleFont` property', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( isUndefined( legend.titleFont ), true, 'returns expected value' ); + + legend = new Legend({ + 'fill': 'colorScale', + 'titleFont': 'testValue' + }); + t.strictEqual( legend.titleFont, 'testValue', 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `titleFont` property which can be set to a string', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + + legend.titleFont = 'beep'; + t.strictEqual( legend.titleFont, 'beep', 'returns expected value' ); + + legend.titleFont = 'boop'; + t.strictEqual( legend.titleFont, 'boop', 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `titleFont` property is set to a new value', function test( t ) { + var count; + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + count = 0; + + legend.on( 'change', onChange ); + + legend.titleFont = 'beep'; + t.strictEqual( count, 1, 'returns expected value' ); + + legend.titleFont = 'boop'; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + legend.titleFont = 'boop'; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.title_font_size.js b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.title_font_size.js new file mode 100644 index 000000000000..9b4ebce4559d --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.title_font_size.js @@ -0,0 +1,146 @@ +/** +* @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 isUndefined = require( '@stdlib/assert/is-undefined' ); +var isNonNegativeNumber = require( '@stdlib/assert/is-nonnegative-number' ).isPrimitive; +var Legend = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Legend, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `titleFontSize` property', function test( t ) { + var v; + + v = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( hasOwnProp( v, 'titleFontSize' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'titleFontSize' ), true, 'returns expected value' ); + t.strictEqual( isUndefined( v.titleFontSize ), true, 'returns expected value' ); + + v = new Legend({ + 'fill': 'colorScale', + 'titleFontSize': 10 + }); + t.strictEqual( isNonNegativeNumber( v.titleFontSize ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the constructor returns an instance having a `titleFontSize` property which throws an error if set to an invalid value', function test( t ) { + var values; + var i; + + values = [ + 'beep', + -1, + 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 legend = new Legend({ + 'fill': 'colorScale' + }); + legend.titleFontSize = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `titleFontSize` property', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( isUndefined( legend.titleFontSize ), true, 'returns expected value' ); + + legend = new Legend({ + 'fill': 'colorScale', + 'titleFontSize': 10 + }); + t.strictEqual( legend.titleFontSize, 10, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `titleFontSize` property which can be set to a valid value', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + + legend.titleFontSize = 10; + t.strictEqual( legend.titleFontSize, 10, 'returns expected value' ); + + legend.titleFontSize = 20; + t.strictEqual( legend.titleFontSize, 20, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `titleFontSize` property is set to a new value', function test( t ) { + var count; + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + count = 0; + + legend.on( 'change', onChange ); + + legend.titleFontSize = 10; + t.strictEqual( count, 1, 'returns expected value' ); + + legend.titleFontSize = 20; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + legend.titleFontSize = 20; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.title_font_style.js b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.title_font_style.js new file mode 100644 index 000000000000..0d9169c83b13 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.title_font_style.js @@ -0,0 +1,145 @@ +/** +* @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 isUndefined = require( '@stdlib/assert/is-undefined' ); +var isString = require( '@stdlib/assert/is-string' ).isPrimitive; +var Legend = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Legend, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `titleFontStyle` property', function test( t ) { + var v; + + v = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( hasOwnProp( v, 'titleFontStyle' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'titleFontStyle' ), true, 'returns expected value' ); + t.strictEqual( isUndefined( v.titleFontStyle ), true, 'returns expected value' ); + + v = new Legend({ + 'fill': 'colorScale', + 'titleFontStyle': 'normal' + }); + t.strictEqual( isString( v.titleFontStyle ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the constructor returns an instance having a `titleFontStyle` 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 legend = new Legend({ + 'fill': 'colorScale' + }); + legend.titleFontStyle = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `titleFontStyle` property', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( isUndefined( legend.titleFontStyle ), true, 'returns expected value' ); + + legend = new Legend({ + 'fill': 'colorScale', + 'titleFontStyle': 'italic' + }); + t.strictEqual( legend.titleFontStyle, 'italic', 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `titleFontStyle` property which can be set to a string', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + + legend.titleFontStyle = 'normal'; + t.strictEqual( legend.titleFontStyle, 'normal', 'returns expected value' ); + + legend.titleFontStyle = 'italic'; + t.strictEqual( legend.titleFontStyle, 'italic', 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `titleFontStyle` property is set to a new value', function test( t ) { + var count; + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + count = 0; + + legend.on( 'change', onChange ); + + legend.titleFontStyle = 'normal'; + t.strictEqual( count, 1, 'returns expected value' ); + + legend.titleFontStyle = 'italic'; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + legend.titleFontStyle = 'italic'; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.title_font_weight.js b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.title_font_weight.js new file mode 100644 index 000000000000..04b48a45fe75 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.title_font_weight.js @@ -0,0 +1,199 @@ +/** +* @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 isUndefined = require( '@stdlib/assert/is-undefined' ); +var isString = require( '@stdlib/assert/is-string' ).isPrimitive; +var Legend = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Legend, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `titleFontWeight` property', function test( t ) { + var v; + + v = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( hasOwnProp( v, 'titleFontWeight' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'titleFontWeight' ), true, 'returns expected value' ); + t.strictEqual( isUndefined( v.titleFontWeight ), true, 'returns expected value' ); + + v = new Legend({ + 'fill': 'colorScale', + 'titleFontWeight': 'bold' + }); + t.strictEqual( isString( v.titleFontWeight ), true, 'returns expected value' ); + + v = new Legend({ + 'fill': 'colorScale', + 'titleFontWeight': 200 + }); + t.strictEqual( isString( v.titleFontWeight ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the constructor returns an instance having a `titleFontWeight` 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 legend = new Legend({ + 'fill': 'colorScale' + }); + legend.titleFontWeight = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `titleFontWeight` property', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( isUndefined( legend.titleFontWeight ), true, 'returns expected value' ); + + legend = new Legend({ + 'fill': 'colorScale', + 'titleFontWeight': 'bold' + }); + t.strictEqual( legend.titleFontWeight, 'bold', 'returns expected value' ); + + legend = new Legend({ + 'fill': 'colorScale', + 'titleFontWeight': 200 + }); + t.strictEqual( legend.titleFontWeight, '200', 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `titleFontWeight` property which can be set to a valid string value', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + + legend.titleFontWeight = 'bold'; + t.strictEqual( legend.titleFontWeight, 'bold', 'returns expected value' ); + + legend.titleFontWeight = 'normal'; + t.strictEqual( legend.titleFontWeight, 'normal', 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `titleFontWeight` property which can be set to a valid numeric value', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + + legend.titleFontWeight = 100; + t.strictEqual( legend.titleFontWeight, '100', 'returns expected value' ); + + legend.titleFontWeight = 900; + t.strictEqual( legend.titleFontWeight, '900', 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `titleFontWeight` property is set to a new value (string)', function test( t ) { + var count; + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + count = 0; + + legend.on( 'change', onChange ); + + legend.titleFontWeight = 'bold'; + t.strictEqual( count, 1, 'returns expected value' ); + + legend.titleFontWeight = 'normal'; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + legend.titleFontWeight = 'normal'; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); + +tape( 'the constructor returns an instance which emits an event when the `titleFontWeight` property is set to a new value (number)', function test( t ) { + var count; + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + count = 0; + + legend.on( 'change', onChange ); + + legend.titleFontWeight = 100; + t.strictEqual( count, 1, 'returns expected value' ); + + legend.titleFontWeight = 900; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + legend.titleFontWeight = 900; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.title_limit.js b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.title_limit.js new file mode 100644 index 000000000000..122c3b60f5ba --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.title_limit.js @@ -0,0 +1,146 @@ +/** +* @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 isUndefined = require( '@stdlib/assert/is-undefined' ); +var isNonNegativeNumber = require( '@stdlib/assert/is-nonnegative-number' ).isPrimitive; +var Legend = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Legend, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `titleLimit` property', function test( t ) { + var v; + + v = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( hasOwnProp( v, 'titleLimit' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'titleLimit' ), true, 'returns expected value' ); + t.strictEqual( isUndefined( v.titleLimit ), true, 'returns expected value' ); + + v = new Legend({ + 'fill': 'colorScale', + 'titleLimit': 10 + }); + t.strictEqual( isNonNegativeNumber( v.titleLimit ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the constructor returns an instance having a `titleLimit` property which throws an error if set to an invalid value', function test( t ) { + var values; + var i; + + values = [ + 'beep', + -1, + 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 legend = new Legend({ + 'fill': 'colorScale' + }); + legend.titleLimit = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `titleLimit` property', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( isUndefined( legend.titleLimit ), true, 'returns expected value' ); + + legend = new Legend({ + 'fill': 'colorScale', + 'titleLimit': 10 + }); + t.strictEqual( legend.titleLimit, 10, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `titleLimit` property which can be set to a valid value', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + + legend.titleLimit = 10; + t.strictEqual( legend.titleLimit, 10, 'returns expected value' ); + + legend.titleLimit = 20; + t.strictEqual( legend.titleLimit, 20, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `titleLimit` property is set to a new value', function test( t ) { + var count; + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + count = 0; + + legend.on( 'change', onChange ); + + legend.titleLimit = 10; + t.strictEqual( count, 1, 'returns expected value' ); + + legend.titleLimit = 20; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + legend.titleLimit = 20; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.title_line_height.js b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.title_line_height.js new file mode 100644 index 000000000000..b2bbaf6002fc --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.title_line_height.js @@ -0,0 +1,146 @@ +/** +* @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 isUndefined = require( '@stdlib/assert/is-undefined' ); +var isNonNegativeNumber = require( '@stdlib/assert/is-nonnegative-number' ).isPrimitive; +var Legend = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Legend, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `titleLineHeight` property', function test( t ) { + var v; + + v = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( hasOwnProp( v, 'titleLineHeight' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'titleLineHeight' ), true, 'returns expected value' ); + t.strictEqual( isUndefined( v.titleLineHeight ), true, 'returns expected value' ); + + v = new Legend({ + 'fill': 'colorScale', + 'titleLineHeight': 10 + }); + t.strictEqual( isNonNegativeNumber( v.titleLineHeight ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the constructor returns an instance having a `titleLineHeight` property which throws an error if set to an invalid value', function test( t ) { + var values; + var i; + + values = [ + 'beep', + -1, + 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 legend = new Legend({ + 'fill': 'colorScale' + }); + legend.titleLineHeight = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `titleLineHeight` property', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( isUndefined( legend.titleLineHeight ), true, 'returns expected value' ); + + legend = new Legend({ + 'fill': 'colorScale', + 'titleLineHeight': 10 + }); + t.strictEqual( legend.titleLineHeight, 10, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `titleLineHeight` property which can be set to a valid value', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + + legend.titleLineHeight = 10; + t.strictEqual( legend.titleLineHeight, 10, 'returns expected value' ); + + legend.titleLineHeight = 20; + t.strictEqual( legend.titleLineHeight, 20, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `titleLineHeight` property is set to a new value', function test( t ) { + var count; + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + count = 0; + + legend.on( 'change', onChange ); + + legend.titleLineHeight = 10; + t.strictEqual( count, 1, 'returns expected value' ); + + legend.titleLineHeight = 20; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + legend.titleLineHeight = 20; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.title_opacity.js b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.title_opacity.js new file mode 100644 index 000000000000..c25403b68da1 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.title_opacity.js @@ -0,0 +1,144 @@ +/** +* @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 isUndefined = require( '@stdlib/assert/is-undefined' ); +var isNumber = require( '@stdlib/assert/is-number' ).isPrimitive; +var Legend = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Legend, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `titleOpacity` property', function test( t ) { + var v; + + v = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( hasOwnProp( v, 'titleOpacity' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'titleOpacity' ), true, 'returns expected value' ); + t.strictEqual( isUndefined( v.titleOpacity ), true, 'returns expected value' ); + + v = new Legend({ + 'fill': 'colorScale', + 'titleOpacity': 10 + }); + t.strictEqual( isNumber( v.titleOpacity ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the constructor returns an instance having a `titleOpacity` property which throws an error if set to an invalid value', function test( t ) { + var values; + var i; + + values = [ + 'beep', + 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 legend = new Legend({ + 'fill': 'colorScale' + }); + legend.titleOpacity = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `titleOpacity` property', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( isUndefined( legend.titleOpacity ), true, 'returns expected value' ); + + legend = new Legend({ + 'fill': 'colorScale', + 'titleOpacity': 10 + }); + t.strictEqual( legend.titleOpacity, 10, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `titleOpacity` property which can be set to a valid value', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + + legend.titleOpacity = 10; + t.strictEqual( legend.titleOpacity, 10, 'returns expected value' ); + + legend.titleOpacity = 20; + t.strictEqual( legend.titleOpacity, 20, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `titleOpacity` property is set to a new value', function test( t ) { + var count; + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + count = 0; + + legend.on( 'change', onChange ); + + legend.titleOpacity = 10; + t.strictEqual( count, 1, 'returns expected value' ); + + legend.titleOpacity = 20; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + legend.titleOpacity = 20; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.title_orient.js b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.title_orient.js new file mode 100644 index 000000000000..610b4256b6d4 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.title_orient.js @@ -0,0 +1,144 @@ +/** +* @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' ).isPrimitive; +var Legend = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Legend, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `titleOrient` property', function test( t ) { + var v; + + v = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( hasOwnProp( v, 'titleOrient' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'titleOrient' ), true, 'returns expected value' ); + t.strictEqual( isString( v.titleOrient ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the constructor returns an instance having a `titleOrient` property which throws an error if set to an invalid value', function test( t ) { + var values; + var i; + + values = [ + 'beep', + 'boop', + 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 legend = new Legend({ + 'fill': 'colorScale' + }); + legend.titleOrient = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `titleOrient` property', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( legend.titleOrient, 'top', 'returns expected value' ); + + legend = new Legend({ + 'fill': 'colorScale', + 'titleOrient': 'left' + }); + t.strictEqual( legend.titleOrient, 'left', 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `titleOrient` property which can be set to a valid title orientation', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + + legend.titleOrient = 'left'; + t.strictEqual( legend.titleOrient, 'left', 'returns expected value' ); + + legend.titleOrient = 'bottom'; + t.strictEqual( legend.titleOrient, 'bottom', 'returns expected value' ); + + legend.titleOrient = 'top'; + t.strictEqual( legend.titleOrient, 'top', 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `titleOrient` property is set to a new value', function test( t ) { + var count; + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + count = 0; + + legend.on( 'change', onChange ); + + legend.titleOrient = 'left'; + t.strictEqual( count, 1, 'returns expected value' ); + + legend.titleOrient = 'bottom'; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + legend.titleOrient = 'bottom'; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.title_padding.js b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.title_padding.js new file mode 100644 index 000000000000..8353f682e8a1 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.title_padding.js @@ -0,0 +1,144 @@ +/** +* @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 isUndefined = require( '@stdlib/assert/is-undefined' ); +var isNumber = require( '@stdlib/assert/is-number' ).isPrimitive; +var Legend = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Legend, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `titlePadding` property', function test( t ) { + var v; + + v = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( hasOwnProp( v, 'titlePadding' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'titlePadding' ), true, 'returns expected value' ); + t.strictEqual( isUndefined( v.titlePadding ), true, 'returns expected value' ); + + v = new Legend({ + 'fill': 'colorScale', + 'titlePadding': 10 + }); + t.strictEqual( isNumber( v.titlePadding ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the constructor returns an instance having a `titlePadding` property which throws an error if set to an invalid value', function test( t ) { + var values; + var i; + + values = [ + 'beep', + 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 legend = new Legend({ + 'fill': 'colorScale' + }); + legend.titlePadding = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `titlePadding` property', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( isUndefined( legend.titlePadding ), true, 'returns expected value' ); + + legend = new Legend({ + 'fill': 'colorScale', + 'titlePadding': 10 + }); + t.strictEqual( legend.titlePadding, 10, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `titlePadding` property which can be set to a valid value', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + + legend.titlePadding = 10; + t.strictEqual( legend.titlePadding, 10, 'returns expected value' ); + + legend.titlePadding = 20; + t.strictEqual( legend.titlePadding, 20, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `titlePadding` property is set to a new value', function test( t ) { + var count; + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + count = 0; + + legend.on( 'change', onChange ); + + legend.titlePadding = 10; + t.strictEqual( count, 1, 'returns expected value' ); + + legend.titlePadding = 20; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + legend.titlePadding = 20; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.type.js b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.type.js new file mode 100644 index 000000000000..8d6c1a492c75 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.type.js @@ -0,0 +1,146 @@ +/** +* @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 isUndefined = require( '@stdlib/assert/is-undefined' ); +var isString = require( '@stdlib/assert/is-string' ).isPrimitive; +var Legend = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Legend, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `type` property', function test( t ) { + var v; + + v = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( hasOwnProp( v, 'type' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'type' ), true, 'returns expected value' ); + t.strictEqual( isUndefined( v.type ), true, 'returns expected value' ); + + v = new Legend({ + 'fill': 'colorScale', + 'type': 'gradient' + }); + t.strictEqual( isString( v.type ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the constructor returns an instance having a `type` property which throws an error if set to an invalid value', function test( t ) { + var values; + var i; + + values = [ + 'beep', + 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 legend = new Legend({ + 'fill': 'colorScale' + }); + legend.type = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `type` property', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( isUndefined( legend.type ), true, 'returns expected value' ); + + legend = new Legend({ + 'fill': 'colorScale', + 'type': 'gradient' + }); + t.strictEqual( legend.type, 'gradient', 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `type` property which can be set to a valid value', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + + legend.type = 'gradient'; + t.strictEqual( legend.type, 'gradient', 'returns expected value' ); + + legend.type = 'symbol'; + t.strictEqual( legend.type, 'symbol', 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `type` property is set to a new value', function test( t ) { + var count; + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + count = 0; + + legend.on( 'change', onChange ); + + legend.type = 'gradient'; + t.strictEqual( count, 1, 'returns expected value' ); + + legend.type = 'symbol'; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + legend.type = 'symbol'; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.values.js b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.values.js new file mode 100644 index 000000000000..0612f23a8b6c --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.values.js @@ -0,0 +1,143 @@ +/** +* @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 isUndefined = require( '@stdlib/assert/is-undefined' ); +var isArray = require( '@stdlib/assert/is-array' ); +var Legend = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Legend, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `values` property', function test( t ) { + var v; + + v = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( hasOwnProp( v, 'values' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'values' ), true, 'returns expected value' ); + t.strictEqual( isUndefined( v.values ), true, 'returns expected value' ); + + v = new Legend({ + 'fill': 'colorScale', + 'values': [ 1, 2, 3 ] + }); + t.strictEqual( isArray( v.values ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the constructor returns an instance having a `values` property which throws an error if set to an invalid value', function test( t ) { + var values; + var i; + + values = [ + 'beep', + 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 legend = new Legend({ + 'fill': 'colorScale' + }); + legend.values = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `values` property', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( isUndefined( legend.values ), true, 'returns expected value' ); + + legend = new Legend({ + 'fill': 'colorScale', + 'values': [ 1, 2, 3 ] + }); + t.deepEqual( legend.values, [ 1, 2, 3 ], 'returns expected value' ); + t.end(); +}); + +tape( 'the constructor returns an instance having a `values` property which can be set to a valid value', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + + legend.values = [ 1, 2, 3 ]; + t.deepEqual( legend.values, [ 1, 2, 3 ], 'returns expected value' ); + + legend.values = [ 4, 5 ]; + t.deepEqual( legend.values, [ 4, 5 ], 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `values` property is set to a new value', function test( t ) { + var count; + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + count = 0; + + legend.on( 'change', onChange ); + + legend.values = [ 1, 2, 3 ]; + t.strictEqual( count, 1, 'returns expected value' ); + + legend.values = [ 4, 5 ]; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to a different array always emits since arrays are compared by reference: + legend.values = [ 4, 5 ]; + t.strictEqual( count, 3, 'returns expected value' ); + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.zindex.js b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.zindex.js new file mode 100644 index 000000000000..ac9bf35ec8db --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/legend/ctor/test/test.zindex.js @@ -0,0 +1,138 @@ +/** +* @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' ).isPrimitive; +var Legend = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Legend, '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 Legend({ + 'fill': 'colorScale' + }); + 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 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', + 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 legend = new Legend({ + 'fill': 'colorScale' + }); + legend.zindex = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `zindex` property', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + t.strictEqual( legend.zindex, 0, 'returns expected value' ); + + legend = new Legend({ + 'fill': 'colorScale', + 'zindex': 5 + }); + t.strictEqual( legend.zindex, 5, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `zindex` property which can be set to a valid value', function test( t ) { + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + + legend.zindex = 5; + t.strictEqual( legend.zindex, 5, 'returns expected value' ); + + legend.zindex = 10; + t.strictEqual( legend.zindex, 10, '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 count; + var legend; + + legend = new Legend({ + 'fill': 'colorScale' + }); + count = 0; + + legend.on( 'change', onChange ); + + legend.zindex = 5; + t.strictEqual( count, 1, 'returns expected value' ); + + legend.zindex = 10; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + legend.zindex = 10; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +});