From 2e023435e30d0351840017238ccbd806652276e3 Mon Sep 17 00:00:00 2001 From: orthodox-64 Date: Sun, 22 Feb 2026 03:30:01 +0530 Subject: [PATCH] test: add tests for Axis constructor and properties --- .../plot/vega/axis/ctor/test/test.aria.js | 181 ++++++++ .../vega/axis/ctor/test/test.band_position.js | 182 ++++++++ .../vega/axis/ctor/test/test.description.js | 176 ++++++++ .../plot/vega/axis/ctor/test/test.domain.js | 174 ++++++++ .../vega/axis/ctor/test/test.domain_cap.js | 190 ++++++++ .../vega/axis/ctor/test/test.domain_color.js | 183 ++++++++ .../vega/axis/ctor/test/test.domain_dash.js | 176 ++++++++ .../axis/ctor/test/test.domain_dash_offset.js | 181 ++++++++ .../axis/ctor/test/test.domain_opacity.js | 175 ++++++++ .../vega/axis/ctor/test/test.domain_width.js | 185 ++++++++ .../plot/vega/axis/ctor/test/test.format.js | 172 ++++++++ .../vega/axis/ctor/test/test.format_type.js | 179 ++++++++ .../plot/vega/axis/ctor/test/test.grid.js | 174 ++++++++ .../plot/vega/axis/ctor/test/test.grid_cap.js | 190 ++++++++ .../vega/axis/ctor/test/test.grid_color.js | 183 ++++++++ .../vega/axis/ctor/test/test.grid_dash.js | 176 ++++++++ .../axis/ctor/test/test.grid_dash_offset.js | 181 ++++++++ .../vega/axis/ctor/test/test.grid_opacity.js | 175 ++++++++ .../vega/axis/ctor/test/test.grid_scale.js | 183 ++++++++ .../vega/axis/ctor/test/test.grid_width.js | 185 ++++++++ .../@stdlib/plot/vega/axis/ctor/test/test.js | 415 ++++++++++++++++++ .../vega/axis/ctor/test/test.label_align.js | 183 ++++++++ .../vega/axis/ctor/test/test.label_angle.js | 181 ++++++++ .../axis/ctor/test/test.label_baseline.js | 181 ++++++++ .../vega/axis/ctor/test/test.label_bound.js | 178 ++++++++ .../vega/axis/ctor/test/test.label_color.js | 183 ++++++++ .../vega/axis/ctor/test/test.label_flush.js | 178 ++++++++ .../axis/ctor/test/test.label_flush_offset.js | 174 ++++++++ .../vega/axis/ctor/test/test.label_font.js | 183 ++++++++ .../axis/ctor/test/test.label_font_size.js | 181 ++++++++ .../axis/ctor/test/test.label_font_style.js | 183 ++++++++ .../axis/ctor/test/test.label_font_weight.js | 180 ++++++++ .../vega/axis/ctor/test/test.label_limit.js | 176 ++++++++ .../axis/ctor/test/test.label_line_height.js | 181 ++++++++ .../vega/axis/ctor/test/test.label_offset.js | 181 ++++++++ .../vega/axis/ctor/test/test.label_opacity.js | 175 ++++++++ .../vega/axis/ctor/test/test.label_overlap.js | 185 ++++++++ .../vega/axis/ctor/test/test.label_padding.js | 181 ++++++++ .../axis/ctor/test/test.label_separation.js | 178 ++++++++ .../plot/vega/axis/ctor/test/test.labels.js | 174 ++++++++ .../vega/axis/ctor/test/test.max_extent.js | 185 ++++++++ .../vega/axis/ctor/test/test.min_extent.js | 185 ++++++++ .../plot/vega/axis/ctor/test/test.offset.js | 181 ++++++++ .../plot/vega/axis/ctor/test/test.orient.js | 198 +++++++++ .../plot/vega/axis/ctor/test/test.position.js | 174 ++++++++ .../vega/axis/ctor/test/test.properties.js | 86 ++++ .../plot/vega/axis/ctor/test/test.scale.js | 174 ++++++++ .../vega/axis/ctor/test/test.tick_band.js | 185 ++++++++ .../plot/vega/axis/ctor/test/test.tick_cap.js | 190 ++++++++ .../vega/axis/ctor/test/test.tick_color.js | 183 ++++++++ .../vega/axis/ctor/test/test.tick_count.js | 175 ++++++++ .../vega/axis/ctor/test/test.tick_dash.js | 176 ++++++++ .../axis/ctor/test/test.tick_dash_offset.js | 181 ++++++++ .../vega/axis/ctor/test/test.tick_extra.js | 179 ++++++++ .../vega/axis/ctor/test/test.tick_min_step.js | 181 ++++++++ .../vega/axis/ctor/test/test.tick_offset.js | 181 ++++++++ .../vega/axis/ctor/test/test.tick_opacity.js | 175 ++++++++ .../vega/axis/ctor/test/test.tick_round.js | 179 ++++++++ .../vega/axis/ctor/test/test.tick_size.js | 185 ++++++++ .../vega/axis/ctor/test/test.tick_width.js | 185 ++++++++ .../plot/vega/axis/ctor/test/test.ticks.js | 174 ++++++++ .../plot/vega/axis/ctor/test/test.title.js | 183 ++++++++ .../vega/axis/ctor/test/test.title_align.js | 179 ++++++++ .../vega/axis/ctor/test/test.title_anchor.js | 178 ++++++++ .../vega/axis/ctor/test/test.title_angle.js | 181 ++++++++ .../axis/ctor/test/test.title_baseline.js | 181 ++++++++ .../vega/axis/ctor/test/test.title_color.js | 183 ++++++++ .../vega/axis/ctor/test/test.title_font.js | 183 ++++++++ .../axis/ctor/test/test.title_font_size.js | 181 ++++++++ .../axis/ctor/test/test.title_font_style.js | 183 ++++++++ .../axis/ctor/test/test.title_font_weight.js | 180 ++++++++ .../vega/axis/ctor/test/test.title_limit.js | 176 ++++++++ .../axis/ctor/test/test.title_line_height.js | 181 ++++++++ .../vega/axis/ctor/test/test.title_opacity.js | 175 ++++++++ .../vega/axis/ctor/test/test.title_padding.js | 181 ++++++++ .../plot/vega/axis/ctor/test/test.title_x.js | 181 ++++++++ .../plot/vega/axis/ctor/test/test.title_y.js | 181 ++++++++ .../vega/axis/ctor/test/test.translate.js | 174 ++++++++ .../plot/vega/axis/ctor/test/test.zindex.js | 174 ++++++++ 79 files changed, 14379 insertions(+) create mode 100644 lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.aria.js create mode 100644 lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.band_position.js create mode 100644 lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.description.js create mode 100644 lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.domain.js create mode 100644 lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.domain_cap.js create mode 100644 lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.domain_color.js create mode 100644 lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.domain_dash.js create mode 100644 lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.domain_dash_offset.js create mode 100644 lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.domain_opacity.js create mode 100644 lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.domain_width.js create mode 100644 lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.format.js create mode 100644 lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.format_type.js create mode 100644 lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.grid.js create mode 100644 lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.grid_cap.js create mode 100644 lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.grid_color.js create mode 100644 lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.grid_dash.js create mode 100644 lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.grid_dash_offset.js create mode 100644 lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.grid_opacity.js create mode 100644 lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.grid_scale.js create mode 100644 lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.grid_width.js create mode 100644 lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.js create mode 100644 lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.label_align.js create mode 100644 lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.label_angle.js create mode 100644 lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.label_baseline.js create mode 100644 lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.label_bound.js create mode 100644 lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.label_color.js create mode 100644 lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.label_flush.js create mode 100644 lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.label_flush_offset.js create mode 100644 lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.label_font.js create mode 100644 lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.label_font_size.js create mode 100644 lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.label_font_style.js create mode 100644 lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.label_font_weight.js create mode 100644 lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.label_limit.js create mode 100644 lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.label_line_height.js create mode 100644 lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.label_offset.js create mode 100644 lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.label_opacity.js create mode 100644 lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.label_overlap.js create mode 100644 lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.label_padding.js create mode 100644 lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.label_separation.js create mode 100644 lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.labels.js create mode 100644 lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.max_extent.js create mode 100644 lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.min_extent.js create mode 100644 lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.offset.js create mode 100644 lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.orient.js create mode 100644 lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.position.js create mode 100644 lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.properties.js create mode 100644 lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.scale.js create mode 100644 lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.tick_band.js create mode 100644 lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.tick_cap.js create mode 100644 lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.tick_color.js create mode 100644 lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.tick_count.js create mode 100644 lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.tick_dash.js create mode 100644 lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.tick_dash_offset.js create mode 100644 lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.tick_extra.js create mode 100644 lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.tick_min_step.js create mode 100644 lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.tick_offset.js create mode 100644 lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.tick_opacity.js create mode 100644 lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.tick_round.js create mode 100644 lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.tick_size.js create mode 100644 lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.tick_width.js create mode 100644 lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.ticks.js create mode 100644 lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.title.js create mode 100644 lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.title_align.js create mode 100644 lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.title_anchor.js create mode 100644 lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.title_angle.js create mode 100644 lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.title_baseline.js create mode 100644 lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.title_color.js create mode 100644 lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.title_font.js create mode 100644 lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.title_font_size.js create mode 100644 lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.title_font_style.js create mode 100644 lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.title_font_weight.js create mode 100644 lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.title_limit.js create mode 100644 lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.title_line_height.js create mode 100644 lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.title_opacity.js create mode 100644 lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.title_padding.js create mode 100644 lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.title_x.js create mode 100644 lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.title_y.js create mode 100644 lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.translate.js create mode 100644 lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.zindex.js diff --git a/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.aria.js b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.aria.js new file mode 100644 index 000000000000..688abf2e5a4b --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.aria.js @@ -0,0 +1,181 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var hasProp = require( '@stdlib/assert/has-property' ); +var isBoolean = require( '@stdlib/assert/is-boolean' ); +var Axis = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Axis, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `aria` property', function test( t ) { + var v; + + v = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + t.strictEqual( hasOwnProp( v, 'aria' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'aria' ), true, 'returns expected value' ); + t.strictEqual( isBoolean( v.aria ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the constructor throws an error if provided an invalid `aria` option', function test( t ) { + var values; + var i; + + values = [ + '5', + 5, + NaN, + null, + void 0, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + var axis = new Axis({ // eslint-disable-line no-unused-vars + 'scale': 'xScale', + 'orient': 'bottom', + 'aria': value + }); + }; + } +}); + +tape( 'the constructor returns an instance having a `aria` property which throws an error if set to a non-boolean value', function test( t ) { + var values; + var i; + + values = [ + '5', + 5, + NaN, + null, + void 0, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + var axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + axis.aria = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `aria` property', function test( t ) { + var axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + t.strictEqual( axis.aria, true, 'returns expected value' ); + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom', + 'aria': false + }); + t.strictEqual( axis.aria, false, 'returns expected value' ); + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom', + 'aria': true + }); + t.strictEqual( axis.aria, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `aria` property which can be set to a boolean', function test( t ) { + var axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + + axis.aria = true; + t.strictEqual( axis.aria, true, 'returns expected value' ); + + axis.aria = false; + t.strictEqual( axis.aria, false, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `aria` property is set to a new value', function test( t ) { + var axis; + var count; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + count = 0; + + axis.on( 'change', onChange ); + + axis.aria = false; + t.strictEqual( count, 1, 'returns expected value' ); + + axis.aria = true; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + axis.aria = true; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.band_position.js b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.band_position.js new file mode 100644 index 000000000000..25c26578a2ac --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.band_position.js @@ -0,0 +1,182 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isUndefined = require( '@stdlib/assert/is-undefined' ); +var hasProp = require( '@stdlib/assert/has-property' ); +var isNumber = require( '@stdlib/assert/is-number' ); +var Axis = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Axis, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `bandPosition` property', function test( t ) { + var v; + + v = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + t.strictEqual( hasOwnProp( v, 'bandPosition' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'bandPosition' ), true, 'returns expected value' ); + t.strictEqual( isUndefined( v.bandPosition ), true, 'returns expected value' ); + + v = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom', + 'bandPosition': 0.5 + }); + t.strictEqual( isNumber( v.bandPosition ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor throws an error if provided an invalid `bandPosition` option', function test( t ) { + var values; + var i; + + values = [ + 'beep', + -0.1, + 1.1, + NaN, + {}, + 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 axis = new Axis({ // eslint-disable-line no-unused-vars + 'scale': 'xScale', + 'orient': 'bottom', + 'bandPosition': value + }); + }; + } +}); + +tape( 'the constructor returns an instance having a `bandPosition` property which throws an error if set to an invalid value', function test( t ) { + var values; + var i; + + values = [ + 'beep', + -0.1, + 1.1, + NaN, + {}, + 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 axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + axis.bandPosition = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `bandPosition` property', function test( t ) { + var axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + t.strictEqual( isUndefined( axis.bandPosition ), true, 'returns expected value' ); + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom', + 'bandPosition': 0.5 + }); + t.strictEqual( axis.bandPosition, 0.5, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `bandPosition` property which can be set to a valid value', function test( t ) { + var axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + + axis.bandPosition = 0.5; + t.strictEqual( axis.bandPosition, 0.5, 'returns expected value' ); + + axis.bandPosition = 0; + t.strictEqual( axis.bandPosition, 0, 'returns expected value' ); + + axis.bandPosition = 1; + t.strictEqual( axis.bandPosition, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `bandPosition` property is set to a new value', function test( t ) { + var axis; + var count; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + count = 0; + + axis.on( 'change', onChange ); + + axis.bandPosition = 0.5; + t.strictEqual( count, 1, 'returns expected value' ); + + axis.bandPosition = 0.3; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + axis.bandPosition = 0.3; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.description.js b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.description.js new file mode 100644 index 000000000000..71a0977e15e2 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.description.js @@ -0,0 +1,176 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var hasProp = require( '@stdlib/assert/has-property' ); +var isString = require( '@stdlib/assert/is-string' ); +var Axis = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Axis, '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 Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + t.strictEqual( hasOwnProp( v, 'description' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'description' ), true, 'returns expected value' ); + t.strictEqual( isString( v.description ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the constructor throws an error if provided an invalid `description` 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 axis = new Axis({ // eslint-disable-line no-unused-vars + 'scale': 'xScale', + 'orient': 'bottom', + 'description': value + }); + }; + } +}); + +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, + 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 axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + axis.description = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `description` property', function test( t ) { + var axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + t.strictEqual( axis.description, '', 'returns expected value' ); + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom', + 'description': 'An axis' + }); + t.strictEqual( axis.description, 'An axis', '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 axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + + axis.description = 'An axis'; + t.strictEqual( axis.description, 'An axis', 'returns expected value' ); + + axis.description = 'Another axis'; + t.strictEqual( axis.description, 'Another axis', '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 axis; + var count; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + count = 0; + + axis.on( 'change', onChange ); + + axis.description = 'An axis'; + t.strictEqual( count, 1, 'returns expected value' ); + + axis.description = 'Another axis'; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + axis.description = 'Another axis'; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.domain.js b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.domain.js new file mode 100644 index 000000000000..43c0812d657a --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.domain.js @@ -0,0 +1,174 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var hasProp = require( '@stdlib/assert/has-property' ); +var isBoolean = require( '@stdlib/assert/is-boolean' ); +var Axis = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Axis, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `domain` property', function test( t ) { + var v; + + v = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + t.strictEqual( hasOwnProp( v, 'domain' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'domain' ), true, 'returns expected value' ); + t.strictEqual( isBoolean( v.domain ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the constructor throws an error if provided an invalid `domain` 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 axis = new Axis({ // eslint-disable-line no-unused-vars + 'scale': 'xScale', + 'orient': 'bottom', + 'domain': value + }); + }; + } +}); + +tape( 'the constructor returns an instance having a `domain` property which throws an error if set to a non-boolean value', function test( t ) { + var values; + var i; + + values = [ + '5', + 5, + NaN, + null, + void 0, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + var axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + axis.domain = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `domain` property', function test( t ) { + var axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + t.strictEqual( axis.domain, true, 'returns expected value' ); + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom', + 'domain': false + }); + t.strictEqual( axis.domain, false, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `domain` property which can be set to a boolean', function test( t ) { + var axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + + axis.domain = false; + t.strictEqual( axis.domain, false, 'returns expected value' ); + + axis.domain = true; + t.strictEqual( axis.domain, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `domain` property is set to a new value', function test( t ) { + var axis; + var count; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + count = 0; + + axis.on( 'change', onChange ); + + axis.domain = false; + t.strictEqual( count, 1, 'returns expected value' ); + + axis.domain = true; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + axis.domain = true; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.domain_cap.js b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.domain_cap.js new file mode 100644 index 000000000000..880f0eb24f01 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.domain_cap.js @@ -0,0 +1,190 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var hasProp = require( '@stdlib/assert/has-property' ); +var isString = require( '@stdlib/assert/is-string' ); +var Axis = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Axis, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `domainCap` property', function test( t ) { + var v; + + v = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + t.strictEqual( hasOwnProp( v, 'domainCap' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'domainCap' ), true, 'returns expected value' ); + t.strictEqual( isString( v.domainCap ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the constructor throws an error if provided an invalid `domainCap` 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 axis = new Axis({ // eslint-disable-line no-unused-vars + 'scale': 'xScale', + 'orient': 'bottom', + 'domainCap': value + }); + }; + } +}); + +tape( 'the constructor returns an instance having a `domainCap` 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 axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + axis.domainCap = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `domainCap` property', function test( t ) { + var axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + t.strictEqual( axis.domainCap, 'butt', 'returns expected value' ); + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom', + 'domainCap': 'round' + }); + t.strictEqual( axis.domainCap, 'round', 'returns expected value' ); + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom', + 'domainCap': 'square' + }); + t.strictEqual( axis.domainCap, 'square', 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `domainCap` property which can be set to a valid value', function test( t ) { + var axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + + axis.domainCap = 'round'; + t.strictEqual( axis.domainCap, 'round', 'returns expected value' ); + + axis.domainCap = 'square'; + t.strictEqual( axis.domainCap, 'square', 'returns expected value' ); + + axis.domainCap = 'butt'; + t.strictEqual( axis.domainCap, 'butt', 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `domainCap` property is set to a new value', function test( t ) { + var axis; + var count; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + count = 0; + + axis.on( 'change', onChange ); + + axis.domainCap = 'round'; + t.strictEqual( count, 1, 'returns expected value' ); + + axis.domainCap = 'square'; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + axis.domainCap = 'square'; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.domain_color.js b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.domain_color.js new file mode 100644 index 000000000000..d2f8f3ceaf7f --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.domain_color.js @@ -0,0 +1,183 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isUndefined = require( '@stdlib/assert/is-undefined' ); +var hasProp = require( '@stdlib/assert/has-property' ); +var isString = require( '@stdlib/assert/is-string' ); +var Axis = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Axis, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `domainColor` property', function test( t ) { + var v; + + v = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + t.strictEqual( hasOwnProp( v, 'domainColor' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'domainColor' ), true, 'returns expected value' ); + t.strictEqual( isUndefined( v.domainColor ), true, 'returns expected value' ); + + v = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom', + 'domainColor': 'steelblue' + }); + t.strictEqual( isString( v.domainColor ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor throws an error if provided an invalid `domainColor` 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 axis = new Axis({ // eslint-disable-line no-unused-vars + 'scale': 'xScale', + 'orient': 'bottom', + 'domainColor': value + }); + }; + } +}); + +tape( 'the constructor returns an instance having a `domainColor` 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 axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + axis.domainColor = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `domainColor` property', function test( t ) { + var axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + t.strictEqual( isUndefined( axis.domainColor ), true, 'returns expected value' ); + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom', + 'domainColor': 'steelblue' + }); + t.strictEqual( axis.domainColor, 'steelblue', 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `domainColor` property which can be set to a valid value', function test( t ) { + var axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + + axis.domainColor = 'steelblue'; + t.strictEqual( axis.domainColor, 'steelblue', 'returns expected value' ); + + axis.domainColor = 'red'; + t.strictEqual( axis.domainColor, 'red', 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `domainColor` property is set to a new value', function test( t ) { + var axis; + var count; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + count = 0; + + axis.on( 'change', onChange ); + + axis.domainColor = 'steelblue'; + t.strictEqual( count, 1, 'returns expected value' ); + + axis.domainColor = 'red'; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + axis.domainColor = 'red'; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.domain_dash.js b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.domain_dash.js new file mode 100644 index 000000000000..4b55762db3a9 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.domain_dash.js @@ -0,0 +1,176 @@ +/** +* @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 Axis = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Axis, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `domainDash` property', function test( t ) { + var v; + + v = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + t.strictEqual( hasOwnProp( v, 'domainDash' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'domainDash' ), true, 'returns expected value' ); + t.strictEqual( isArray( v.domainDash ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the constructor throws an error if provided an invalid `domainDash` 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 axis = new Axis({ // eslint-disable-line no-unused-vars + 'scale': 'xScale', + 'orient': 'bottom', + 'domainDash': value + }); + }; + } +}); + +tape( 'the constructor returns an instance having a `domainDash` 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 axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + axis.domainDash = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `domainDash` property', function test( t ) { + var axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + t.deepEqual( axis.domainDash, [], 'returns expected value' ); + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom', + 'domainDash': [ 2, 4 ] + }); + t.deepEqual( axis.domainDash, [ 2, 4 ], 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `domainDash` property which can be set to a valid value', function test( t ) { + var axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + + axis.domainDash = [ 2, 4 ]; + t.deepEqual( axis.domainDash, [ 2, 4 ], 'returns expected value' ); + + axis.domainDash = []; + t.deepEqual( axis.domainDash, [], 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `domainDash` property is set to a new value', function test( t ) { + var axis; + var count; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + count = 0; + + axis.on( 'change', onChange ); + + axis.domainDash = [ 2, 4 ]; + t.strictEqual( count, 1, 'returns expected value' ); + + axis.domainDash = [ 1, 2 ]; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + axis.domainDash = [ 1, 2 ]; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.domain_dash_offset.js b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.domain_dash_offset.js new file mode 100644 index 000000000000..864895387d30 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.domain_dash_offset.js @@ -0,0 +1,181 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isUndefined = require( '@stdlib/assert/is-undefined' ); +var hasProp = require( '@stdlib/assert/has-property' ); +var isNumber = require( '@stdlib/assert/is-number' ); +var Axis = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Axis, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `domainDashOffset` property', function test( t ) { + var v; + + v = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + t.strictEqual( hasOwnProp( v, 'domainDashOffset' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'domainDashOffset' ), true, 'returns expected value' ); + t.strictEqual( isUndefined( v.domainDashOffset ), true, 'returns expected value' ); + + v = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom', + 'domainDashOffset': 1 + }); + t.strictEqual( isNumber( v.domainDashOffset ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor throws an error if provided an invalid `domainDashOffset` 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 axis = new Axis({ // eslint-disable-line no-unused-vars + 'scale': 'xScale', + 'orient': 'bottom', + 'domainDashOffset': value + }); + }; + } +}); + +tape( 'the constructor returns an instance having a `domainDashOffset` 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 axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + axis.domainDashOffset = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `domainDashOffset` property', function test( t ) { + var axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + t.strictEqual( isUndefined( axis.domainDashOffset ), true, 'returns expected value' ); + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom', + 'domainDashOffset': 1 + }); + t.strictEqual( axis.domainDashOffset, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `domainDashOffset` property which can be set to a valid value', function test( t ) { + var axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + + axis.domainDashOffset = 1; + t.strictEqual( axis.domainDashOffset, 1, 'returns expected value' ); + + axis.domainDashOffset = 2; + t.strictEqual( axis.domainDashOffset, 2, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `domainDashOffset` property is set to a new value', function test( t ) { + var axis; + var count; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + count = 0; + + axis.on( 'change', onChange ); + + axis.domainDashOffset = 1; + t.strictEqual( count, 1, 'returns expected value' ); + + axis.domainDashOffset = 2; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + axis.domainDashOffset = 2; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.domain_opacity.js b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.domain_opacity.js new file mode 100644 index 000000000000..4698682ab495 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.domain_opacity.js @@ -0,0 +1,175 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var hasProp = require( '@stdlib/assert/has-property' ); +var isNumber = require( '@stdlib/assert/is-number' ); +var Axis = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Axis, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `domainOpacity` property', function test( t ) { + var v; + + v = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + t.strictEqual( hasOwnProp( v, 'domainOpacity' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'domainOpacity' ), true, 'returns expected value' ); + t.strictEqual( isNumber( v.domainOpacity ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the constructor throws an error if provided an invalid `domainOpacity` option', function test( t ) { + var values; + var i; + + values = [ + 'beep', + -1, + 2, + NaN, + 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 axis = new Axis({ // eslint-disable-line no-unused-vars + 'scale': 'xScale', + 'orient': 'bottom', + 'domainOpacity': value + }); + }; + } +}); + +tape( 'the constructor returns an instance having a `domainOpacity` property which throws an error if set to an invalid value', function test( t ) { + var values; + var i; + + values = [ + 'beep', + -1, + 2, + NaN, + 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 axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + axis.domainOpacity = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `domainOpacity` property', function test( t ) { + var axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + t.strictEqual( axis.domainOpacity, 1, 'returns expected value' ); + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom', + 'domainOpacity': 0.5 + }); + t.strictEqual( axis.domainOpacity, 0.5, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `domainOpacity` property which can be set to a valid value', function test( t ) { + var axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + + axis.domainOpacity = 0.5; + t.strictEqual( axis.domainOpacity, 0.5, 'returns expected value' ); + + axis.domainOpacity = 0; + t.strictEqual( axis.domainOpacity, 0, 'returns expected value' ); + + axis.domainOpacity = 1; + t.strictEqual( axis.domainOpacity, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `domainOpacity` property is set to a new value', function test( t ) { + var axis; + var count; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + count = 0; + + axis.on( 'change', onChange ); + + axis.domainOpacity = 0.5; + t.strictEqual( count, 1, 'returns expected value' ); + + axis.domainOpacity = 0; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + axis.domainOpacity = 0; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.domain_width.js b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.domain_width.js new file mode 100644 index 000000000000..7e8cda71604d --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.domain_width.js @@ -0,0 +1,185 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isUndefined = require( '@stdlib/assert/is-undefined' ); +var hasProp = require( '@stdlib/assert/has-property' ); +var isNumber = require( '@stdlib/assert/is-number' ); +var Axis = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Axis, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `domainWidth` property', function test( t ) { + var v; + + v = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + t.strictEqual( hasOwnProp( v, 'domainWidth' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'domainWidth' ), true, 'returns expected value' ); + t.strictEqual( isUndefined( v.domainWidth ), true, 'returns expected value' ); + + v = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom', + 'domainWidth': 2 + }); + t.strictEqual( isNumber( v.domainWidth ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor throws an error if provided an invalid `domainWidth` 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 axis = new Axis({ // eslint-disable-line no-unused-vars + 'scale': 'xScale', + 'orient': 'bottom', + 'domainWidth': value + }); + }; + } +}); + +tape( 'the constructor returns an instance having a `domainWidth` 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 axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + axis.domainWidth = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `domainWidth` property', function test( t ) { + var axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + t.strictEqual( isUndefined( axis.domainWidth ), true, 'returns expected value' ); + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom', + 'domainWidth': 2 + }); + t.strictEqual( axis.domainWidth, 2, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `domainWidth` property which can be set to a valid value', function test( t ) { + var axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + + axis.domainWidth = 2; + t.strictEqual( axis.domainWidth, 2, 'returns expected value' ); + + axis.domainWidth = 0; + t.strictEqual( axis.domainWidth, 0, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `domainWidth` property is set to a new value', function test( t ) { + var axis; + var count; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + count = 0; + + axis.on( 'change', onChange ); + + axis.domainWidth = 2; + t.strictEqual( count, 1, 'returns expected value' ); + + axis.domainWidth = 3; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + axis.domainWidth = 3; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.format.js b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.format.js new file mode 100644 index 000000000000..6aa9ba15ded6 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.format.js @@ -0,0 +1,172 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isUndefined = require( '@stdlib/assert/is-undefined' ); +var hasProp = require( '@stdlib/assert/has-property' ); +var Axis = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Axis, '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 Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + 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' ); + t.end(); +}); + +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 axis = new Axis({ // eslint-disable-line no-unused-vars + 'scale': 'xScale', + 'orient': 'bottom', + 'format': value + }); + }; + } +}); + +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 axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + axis.format = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `format` property', function test( t ) { + var axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + t.strictEqual( isUndefined( axis.format ), true, 'returns expected value' ); + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom', + 'format': '.2f' + }); + t.strictEqual( axis.format, '.2f', '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 axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + + axis.format = '.2f'; + t.strictEqual( axis.format, '.2f', 'returns expected value' ); + + axis.format = '.0%'; + t.strictEqual( axis.format, '.0%', '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 axis; + var count; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + count = 0; + + axis.on( 'change', onChange ); + + axis.format = '.2f'; + t.strictEqual( count, 1, 'returns expected value' ); + + axis.format = '.0%'; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + axis.format = '.0%'; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.format_type.js b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.format_type.js new file mode 100644 index 000000000000..597033bea804 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.format_type.js @@ -0,0 +1,179 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isUndefined = require( '@stdlib/assert/is-undefined' ); +var hasProp = require( '@stdlib/assert/has-property' ); +var Axis = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Axis, '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 Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + 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' ); + t.end(); +}); + +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 axis = new Axis({ // eslint-disable-line no-unused-vars + 'scale': 'xScale', + 'orient': 'bottom', + 'formatType': value + }); + }; + } +}); + +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 axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + axis.formatType = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `formatType` property', function test( t ) { + var axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + t.strictEqual( isUndefined( axis.formatType ), true, 'returns expected value' ); + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom', + 'formatType': 'number' + }); + t.strictEqual( axis.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 axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + + axis.formatType = 'number'; + t.strictEqual( axis.formatType, 'number', 'returns expected value' ); + + axis.formatType = 'time'; + t.strictEqual( axis.formatType, 'time', 'returns expected value' ); + + axis.formatType = 'utc'; + t.strictEqual( axis.formatType, 'utc', '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 axis; + var count; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + count = 0; + + axis.on( 'change', onChange ); + + axis.formatType = 'number'; + t.strictEqual( count, 1, 'returns expected value' ); + + axis.formatType = 'time'; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + axis.formatType = 'time'; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.grid.js b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.grid.js new file mode 100644 index 000000000000..dea2ca0ad1b0 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.grid.js @@ -0,0 +1,174 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var hasProp = require( '@stdlib/assert/has-property' ); +var isBoolean = require( '@stdlib/assert/is-boolean' ); +var Axis = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Axis, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `grid` property', function test( t ) { + var v; + + v = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + t.strictEqual( hasOwnProp( v, 'grid' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'grid' ), true, 'returns expected value' ); + t.strictEqual( isBoolean( v.grid ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the constructor throws an error if provided an invalid `grid` 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 axis = new Axis({ // eslint-disable-line no-unused-vars + 'scale': 'xScale', + 'orient': 'bottom', + 'grid': value + }); + }; + } +}); + +tape( 'the constructor returns an instance having a `grid` property which throws an error if set to a non-boolean value', function test( t ) { + var values; + var i; + + values = [ + '5', + 5, + NaN, + null, + void 0, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + var axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + axis.grid = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `grid` property', function test( t ) { + var axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + t.strictEqual( axis.grid, false, 'returns expected value' ); + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom', + 'grid': true + }); + t.strictEqual( axis.grid, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `grid` property which can be set to a boolean', function test( t ) { + var axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + + axis.grid = true; + t.strictEqual( axis.grid, true, 'returns expected value' ); + + axis.grid = false; + t.strictEqual( axis.grid, false, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `grid` property is set to a new value', function test( t ) { + var axis; + var count; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + count = 0; + + axis.on( 'change', onChange ); + + axis.grid = true; + t.strictEqual( count, 1, 'returns expected value' ); + + axis.grid = false; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + axis.grid = false; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.grid_cap.js b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.grid_cap.js new file mode 100644 index 000000000000..27a088212c01 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.grid_cap.js @@ -0,0 +1,190 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var hasProp = require( '@stdlib/assert/has-property' ); +var isString = require( '@stdlib/assert/is-string' ); +var Axis = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Axis, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `gridCap` property', function test( t ) { + var v; + + v = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + t.strictEqual( hasOwnProp( v, 'gridCap' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'gridCap' ), true, 'returns expected value' ); + t.strictEqual( isString( v.gridCap ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the constructor throws an error if provided an invalid `gridCap` 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 axis = new Axis({ // eslint-disable-line no-unused-vars + 'scale': 'xScale', + 'orient': 'bottom', + 'gridCap': value + }); + }; + } +}); + +tape( 'the constructor returns an instance having a `gridCap` 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 axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + axis.gridCap = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `gridCap` property', function test( t ) { + var axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + t.strictEqual( axis.gridCap, 'butt', 'returns expected value' ); + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom', + 'gridCap': 'round' + }); + t.strictEqual( axis.gridCap, 'round', 'returns expected value' ); + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom', + 'gridCap': 'square' + }); + t.strictEqual( axis.gridCap, 'square', 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `gridCap` property which can be set to a valid value', function test( t ) { + var axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + + axis.gridCap = 'round'; + t.strictEqual( axis.gridCap, 'round', 'returns expected value' ); + + axis.gridCap = 'square'; + t.strictEqual( axis.gridCap, 'square', 'returns expected value' ); + + axis.gridCap = 'butt'; + t.strictEqual( axis.gridCap, 'butt', 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `gridCap` property is set to a new value', function test( t ) { + var axis; + var count; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + count = 0; + + axis.on( 'change', onChange ); + + axis.gridCap = 'round'; + t.strictEqual( count, 1, 'returns expected value' ); + + axis.gridCap = 'square'; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + axis.gridCap = 'square'; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.grid_color.js b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.grid_color.js new file mode 100644 index 000000000000..20bc2e654f92 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.grid_color.js @@ -0,0 +1,183 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isUndefined = require( '@stdlib/assert/is-undefined' ); +var hasProp = require( '@stdlib/assert/has-property' ); +var isString = require( '@stdlib/assert/is-string' ); +var Axis = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Axis, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `gridColor` property', function test( t ) { + var v; + + v = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + t.strictEqual( hasOwnProp( v, 'gridColor' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'gridColor' ), true, 'returns expected value' ); + t.strictEqual( isUndefined( v.gridColor ), true, 'returns expected value' ); + + v = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom', + 'gridColor': 'steelblue' + }); + t.strictEqual( isString( v.gridColor ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor throws an error if provided an invalid `gridColor` 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 axis = new Axis({ // eslint-disable-line no-unused-vars + 'scale': 'xScale', + 'orient': 'bottom', + 'gridColor': value + }); + }; + } +}); + +tape( 'the constructor returns an instance having a `gridColor` 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 axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + axis.gridColor = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `gridColor` property', function test( t ) { + var axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + t.strictEqual( isUndefined( axis.gridColor ), true, 'returns expected value' ); + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom', + 'gridColor': 'steelblue' + }); + t.strictEqual( axis.gridColor, 'steelblue', 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `gridColor` property which can be set to a valid value', function test( t ) { + var axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + + axis.gridColor = 'steelblue'; + t.strictEqual( axis.gridColor, 'steelblue', 'returns expected value' ); + + axis.gridColor = 'red'; + t.strictEqual( axis.gridColor, 'red', 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `gridColor` property is set to a new value', function test( t ) { + var axis; + var count; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + count = 0; + + axis.on( 'change', onChange ); + + axis.gridColor = 'steelblue'; + t.strictEqual( count, 1, 'returns expected value' ); + + axis.gridColor = 'red'; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + axis.gridColor = 'red'; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.grid_dash.js b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.grid_dash.js new file mode 100644 index 000000000000..e02b47153868 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.grid_dash.js @@ -0,0 +1,176 @@ +/** +* @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 Axis = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Axis, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `gridDash` property', function test( t ) { + var v; + + v = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + t.strictEqual( hasOwnProp( v, 'gridDash' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'gridDash' ), true, 'returns expected value' ); + t.strictEqual( isArray( v.gridDash ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the constructor throws an error if provided an invalid `gridDash` 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 axis = new Axis({ // eslint-disable-line no-unused-vars + 'scale': 'xScale', + 'orient': 'bottom', + 'gridDash': value + }); + }; + } +}); + +tape( 'the constructor returns an instance having a `gridDash` 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 axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + axis.gridDash = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `gridDash` property', function test( t ) { + var axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + t.deepEqual( axis.gridDash, [], 'returns expected value' ); + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom', + 'gridDash': [ 2, 4 ] + }); + t.deepEqual( axis.gridDash, [ 2, 4 ], 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `gridDash` property which can be set to a valid value', function test( t ) { + var axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + + axis.gridDash = [ 2, 4 ]; + t.deepEqual( axis.gridDash, [ 2, 4 ], 'returns expected value' ); + + axis.gridDash = []; + t.deepEqual( axis.gridDash, [], 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `gridDash` property is set to a new value', function test( t ) { + var axis; + var count; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + count = 0; + + axis.on( 'change', onChange ); + + axis.gridDash = [ 2, 4 ]; + t.strictEqual( count, 1, 'returns expected value' ); + + axis.gridDash = [ 1, 2 ]; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + axis.gridDash = [ 1, 2 ]; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.grid_dash_offset.js b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.grid_dash_offset.js new file mode 100644 index 000000000000..2341e6d453a8 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.grid_dash_offset.js @@ -0,0 +1,181 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isUndefined = require( '@stdlib/assert/is-undefined' ); +var hasProp = require( '@stdlib/assert/has-property' ); +var isNumber = require( '@stdlib/assert/is-number' ); +var Axis = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Axis, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `gridDashOffset` property', function test( t ) { + var v; + + v = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + t.strictEqual( hasOwnProp( v, 'gridDashOffset' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'gridDashOffset' ), true, 'returns expected value' ); + t.strictEqual( isUndefined( v.gridDashOffset ), true, 'returns expected value' ); + + v = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom', + 'gridDashOffset': 1 + }); + t.strictEqual( isNumber( v.gridDashOffset ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor throws an error if provided an invalid `gridDashOffset` 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 axis = new Axis({ // eslint-disable-line no-unused-vars + 'scale': 'xScale', + 'orient': 'bottom', + 'gridDashOffset': value + }); + }; + } +}); + +tape( 'the constructor returns an instance having a `gridDashOffset` 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 axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + axis.gridDashOffset = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `gridDashOffset` property', function test( t ) { + var axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + t.strictEqual( isUndefined( axis.gridDashOffset ), true, 'returns expected value' ); + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom', + 'gridDashOffset': 1 + }); + t.strictEqual( axis.gridDashOffset, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `gridDashOffset` property which can be set to a valid value', function test( t ) { + var axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + + axis.gridDashOffset = 1; + t.strictEqual( axis.gridDashOffset, 1, 'returns expected value' ); + + axis.gridDashOffset = 2; + t.strictEqual( axis.gridDashOffset, 2, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `gridDashOffset` property is set to a new value', function test( t ) { + var axis; + var count; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + count = 0; + + axis.on( 'change', onChange ); + + axis.gridDashOffset = 1; + t.strictEqual( count, 1, 'returns expected value' ); + + axis.gridDashOffset = 2; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + axis.gridDashOffset = 2; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.grid_opacity.js b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.grid_opacity.js new file mode 100644 index 000000000000..813a5ceeaf91 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.grid_opacity.js @@ -0,0 +1,175 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var hasProp = require( '@stdlib/assert/has-property' ); +var isNumber = require( '@stdlib/assert/is-number' ); +var Axis = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Axis, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `gridOpacity` property', function test( t ) { + var v; + + v = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + t.strictEqual( hasOwnProp( v, 'gridOpacity' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'gridOpacity' ), true, 'returns expected value' ); + t.strictEqual( isNumber( v.gridOpacity ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the constructor throws an error if provided an invalid `gridOpacity` option', function test( t ) { + var values; + var i; + + values = [ + 'beep', + -1, + 2, + NaN, + 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 axis = new Axis({ // eslint-disable-line no-unused-vars + 'scale': 'xScale', + 'orient': 'bottom', + 'gridOpacity': value + }); + }; + } +}); + +tape( 'the constructor returns an instance having a `gridOpacity` property which throws an error if set to an invalid value', function test( t ) { + var values; + var i; + + values = [ + 'beep', + -1, + 2, + NaN, + 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 axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + axis.gridOpacity = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `gridOpacity` property', function test( t ) { + var axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + t.strictEqual( axis.gridOpacity, 1, 'returns expected value' ); + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom', + 'gridOpacity': 0.5 + }); + t.strictEqual( axis.gridOpacity, 0.5, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `gridOpacity` property which can be set to a valid value', function test( t ) { + var axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + + axis.gridOpacity = 0.5; + t.strictEqual( axis.gridOpacity, 0.5, 'returns expected value' ); + + axis.gridOpacity = 0; + t.strictEqual( axis.gridOpacity, 0, 'returns expected value' ); + + axis.gridOpacity = 1; + t.strictEqual( axis.gridOpacity, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `gridOpacity` property is set to a new value', function test( t ) { + var axis; + var count; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + count = 0; + + axis.on( 'change', onChange ); + + axis.gridOpacity = 0.5; + t.strictEqual( count, 1, 'returns expected value' ); + + axis.gridOpacity = 0; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + axis.gridOpacity = 0; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.grid_scale.js b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.grid_scale.js new file mode 100644 index 000000000000..f2cf775e796e --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.grid_scale.js @@ -0,0 +1,183 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isUndefined = require( '@stdlib/assert/is-undefined' ); +var hasProp = require( '@stdlib/assert/has-property' ); +var isString = require( '@stdlib/assert/is-string' ); +var Axis = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Axis, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `gridScale` property', function test( t ) { + var v; + + v = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + t.strictEqual( hasOwnProp( v, 'gridScale' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'gridScale' ), true, 'returns expected value' ); + t.strictEqual( isUndefined( v.gridScale ), true, 'returns expected value' ); + + v = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom', + 'gridScale': 'yScale' + }); + t.strictEqual( isString( v.gridScale ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor throws an error if provided an invalid `gridScale` 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 axis = new Axis({ // eslint-disable-line no-unused-vars + 'scale': 'xScale', + 'orient': 'bottom', + 'gridScale': value + }); + }; + } +}); + +tape( 'the constructor returns an instance having a `gridScale` 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 axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + axis.gridScale = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `gridScale` property', function test( t ) { + var axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + t.strictEqual( isUndefined( axis.gridScale ), true, 'returns expected value' ); + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom', + 'gridScale': 'yScale' + }); + t.strictEqual( axis.gridScale, 'yScale', 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `gridScale` property which can be set to a valid value', function test( t ) { + var axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + + axis.gridScale = 'yScale'; + t.strictEqual( axis.gridScale, 'yScale', 'returns expected value' ); + + axis.gridScale = 'zScale'; + t.strictEqual( axis.gridScale, 'zScale', 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `gridScale` property is set to a new value', function test( t ) { + var axis; + var count; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + count = 0; + + axis.on( 'change', onChange ); + + axis.gridScale = 'yScale'; + t.strictEqual( count, 1, 'returns expected value' ); + + axis.gridScale = 'zScale'; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + axis.gridScale = 'zScale'; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.grid_width.js b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.grid_width.js new file mode 100644 index 000000000000..e9d18bb910dd --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.grid_width.js @@ -0,0 +1,185 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isUndefined = require( '@stdlib/assert/is-undefined' ); +var hasProp = require( '@stdlib/assert/has-property' ); +var isNumber = require( '@stdlib/assert/is-number' ); +var Axis = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Axis, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `gridWidth` property', function test( t ) { + var v; + + v = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + t.strictEqual( hasOwnProp( v, 'gridWidth' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'gridWidth' ), true, 'returns expected value' ); + t.strictEqual( isUndefined( v.gridWidth ), true, 'returns expected value' ); + + v = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom', + 'gridWidth': 2 + }); + t.strictEqual( isNumber( v.gridWidth ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor throws an error if provided an invalid `gridWidth` 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 axis = new Axis({ // eslint-disable-line no-unused-vars + 'scale': 'xScale', + 'orient': 'bottom', + 'gridWidth': value + }); + }; + } +}); + +tape( 'the constructor returns an instance having a `gridWidth` 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 axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + axis.gridWidth = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `gridWidth` property', function test( t ) { + var axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + t.strictEqual( isUndefined( axis.gridWidth ), true, 'returns expected value' ); + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom', + 'gridWidth': 2 + }); + t.strictEqual( axis.gridWidth, 2, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `gridWidth` property which can be set to a valid value', function test( t ) { + var axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + + axis.gridWidth = 2; + t.strictEqual( axis.gridWidth, 2, 'returns expected value' ); + + axis.gridWidth = 0; + t.strictEqual( axis.gridWidth, 0, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `gridWidth` property is set to a new value', function test( t ) { + var axis; + var count; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + count = 0; + + axis.on( 'change', onChange ); + + axis.gridWidth = 2; + t.strictEqual( count, 1, 'returns expected value' ); + + axis.gridWidth = 3; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + axis.gridWidth = 3; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.js b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.js new file mode 100644 index 000000000000..ed29584d2f49 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.js @@ -0,0 +1,415 @@ +/** +* @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 instanceOf = require( '@stdlib/assert/instance-of' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var Axis = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Axis, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function is a constructor', function test( t ) { + var axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + t.strictEqual( instanceOf( axis, Axis ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the constructor does not require the `new` keyword', function test( t ) { + var axis; + var ctor; + + ctor = Axis; + axis = ctor({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + t.strictEqual( instanceOf( axis, Axis ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the constructor does not require the `new` keyword (options)', function test( t ) { + var axis; + var ctor; + + ctor = Axis; + axis = ctor({ + 'scale': 'xScale', + 'orient': 'bottom', + 'grid': true + }); + t.strictEqual( instanceOf( axis, Axis ), true, 'returns expected value' ); + t.strictEqual( axis.grid, true, 'returns expected value' ); + t.end(); +}); + +tape( 'the constructor throws an error if provided an options argument which is not an object', function test( t ) { + var values; + var i; + + values = [ + '5', + 5, + NaN, + null, + void 0, + true, + false, + [], + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + var axis = new Axis( value ); // eslint-disable-line no-unused-vars + }; + } +}); + +tape( 'the constructor throws an error if not provided a `scale` option', function test( t ) { + t.throws( foo, TypeError, 'throws an error' ); + t.end(); + + function foo() { + var axis = new Axis({ // eslint-disable-line no-unused-vars + 'orient': 'bottom' + }); + } +}); + +tape( 'the constructor throws an error if not provided an `orient` option', function test( t ) { + t.throws( foo, TypeError, 'throws an error' ); + t.end(); + + function foo() { + var axis = new Axis({ // eslint-disable-line no-unused-vars + 'scale': 'xScale' + }); + } +}); + +tape( 'the constructor has a read-only `name` property', function test( t ) { + t.strictEqual( Axis.name, 'Axis', '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 axis; + var json; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + json = axis.toJSON(); + + expected = { + 'aria': true, + 'description': '', + 'domain': true, + 'domainCap': 'butt', + 'domainDash': [], + 'domainOpacity': 1, + 'grid': false, + 'gridCap': 'butt', + 'gridDash': [], + 'gridOpacity': 1, + 'labelBound': false, + 'labelFlushOffset': 0, + 'labelOpacity': 1, + 'labelOverlap': false, + 'labels': true, + 'labelSeparation': 0, + 'orient': 'bottom', + 'position': 0, + 'scale': 'xScale', + 'tickCap': 'butt', + 'tickDash': [], + 'tickOpacity': 1, + 'ticks': true, + 'title': [ '' ], + 'titleAnchor': null, + 'titleOpacity': 1, + 'translate': 0.5, + '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 axis; + var json; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom', + 'aria': false, + 'bandPosition': 0.5, + 'description': 'An axis', + 'domain': false, + 'domainCap': 'round', + 'domainColor': 'steelblue', + 'domainDash': [ 2, 4 ], + 'domainDashOffset': 1, + 'domainOpacity': 0.5, + 'domainWidth': 2, + 'format': '.1f', + 'formatType': 'number', + 'grid': true, + 'gridCap': 'round', + 'gridColor': 'gray', + 'gridDash': [ 1, 2 ], + 'gridDashOffset': 1, + 'gridOpacity': 0.5, + 'gridScale': 'yScale', + 'gridWidth': 1, + 'labelAlign': 'center', + 'labelAngle': 45, + 'labelBaseline': 'top', + 'labelBound': true, + 'labelColor': 'red', + 'labelFlush': true, + 'labelFlushOffset': 5, + 'labelFont': 'Arial', + 'labelFontSize': 12, + 'labelFontStyle': 'italic', + 'labelFontWeight': 'bold', + 'labelLimit': 200, + 'labelLineHeight': 16, + 'labelOffset': 4, + 'labelOpacity': 0.8, + 'labelOverlap': 'parity', + 'labelPadding': 4, + 'labels': false, + 'labelSeparation': 2, + 'maxExtent': 100, + 'minExtent': 50, + 'offset': 10, + 'position': 5, + 'tickBand': 'center', + 'tickCap': 'round', + 'tickColor': 'black', + 'tickCount': 10, + 'tickDash': [ 2, 2 ], + 'tickDashOffset': 1, + 'tickExtra': true, + 'tickMinStep': 1, + 'tickOffset': 2, + 'tickOpacity': 0.9, + 'tickRound': true, + 'ticks': false, + 'tickSize': 5, + 'tickWidth': 1, + 'title': 'X Axis', + 'titleAlign': 'center', + 'titleAnchor': 'start', + 'titleAngle': 0, + 'titleBaseline': 'bottom', + 'titleColor': 'black', + 'titleFont': 'Helvetica', + 'titleFontSize': 14, + 'titleFontStyle': 'normal', + 'titleFontWeight': 'bold', + 'titleLimit': 300, + 'titleLineHeight': 18, + 'titleOpacity': 0.9, + 'titlePadding': 8, + 'titleX': 10, + 'titleY': 20, + 'translate': 1, + 'zindex': 2 + }); + json = axis.toJSON(); + + expected = { + 'aria': false, + 'bandPosition': 0.5, + 'description': 'An axis', + 'domain': false, + 'domainCap': 'round', + 'domainColor': 'steelblue', + 'domainDash': [ 2, 4 ], + 'domainDashOffset': 1, + 'domainOpacity': 0.5, + 'domainWidth': 2, + 'format': '.1f', + 'formatType': 'number', + 'grid': true, + 'gridCap': 'round', + 'gridColor': 'gray', + 'gridDash': [ 1, 2 ], + 'gridDashOffset': 1, + 'gridOpacity': 0.5, + 'gridScale': 'yScale', + 'gridWidth': 1, + 'labelAlign': 'center', + 'labelAngle': 45, + 'labelBaseline': 'top', + 'labelBound': true, + 'labelColor': 'red', + 'labelFlush': true, + 'labelFlushOffset': 5, + 'labelFont': 'Arial', + 'labelFontSize': 12, + 'labelFontStyle': 'italic', + 'labelFontWeight': 'bold', + 'labelLimit': 200, + 'labelLineHeight': 16, + 'labelOffset': 4, + 'labelOpacity': 0.8, + 'labelOverlap': 'parity', + 'labelPadding': 4, + 'labels': false, + 'labelSeparation': 2, + 'maxExtent': 100, + 'minExtent': 50, + 'offset': 10, + 'orient': 'bottom', + 'position': 5, + 'scale': 'xScale', + 'tickBand': 'center', + 'tickCap': 'round', + 'tickColor': 'black', + 'tickCount': 10, + 'tickDash': [ 2, 2 ], + 'tickDashOffset': 1, + 'tickExtra': true, + 'tickMinStep': 1, + 'tickOffset': 2, + 'tickOpacity': 0.9, + 'tickRound': true, + 'ticks': false, + 'tickSize': 5, + 'tickWidth': 1, + 'title': [ 'X Axis' ], + 'titleAlign': 'center', + 'titleAnchor': 'start', + 'titleAngle': 0, + 'titleBaseline': 'bottom', + 'titleColor': 'black', + 'titleFont': 'Helvetica', + 'titleFontSize': 14, + 'titleFontStyle': 'normal', + 'titleFontWeight': 'bold', + 'titleLimit': 300, + 'titleLineHeight': 18, + 'titleOpacity': 0.9, + 'titlePadding': 8, + 'titleX': 10, + 'titleY': 20, + 'translate': 1, + '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 axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + + expected = { + 'aria': true, + 'description': '', + 'domain': true, + 'domainCap': 'butt', + 'domainDash': [], + 'domainOpacity': 1, + 'grid': false, + 'gridCap': 'butt', + 'gridDash': [], + 'gridOpacity': 1, + 'labelBound': false, + 'labelFlushOffset': 0, + 'labelOpacity': 1, + 'labelOverlap': false, + 'labels': true, + 'labelSeparation': 0, + 'orient': 'bottom', + 'position': 0, + 'scale': 'xScale', + 'tickCap': 'butt', + 'tickDash': [], + 'tickOpacity': 1, + 'ticks': true, + 'title': [ '' ], + 'titleAnchor': null, + 'titleOpacity': 1, + 'translate': 0.5, + 'zindex': 0 + }; + t.strictEqual( JSON.stringify( axis ), JSON.stringify( expected ), 'returns expected value' ); + t.end(); +}); + +tape( 'the constructor returns an instance which inherits from EventEmitter', function test( t ) { + var axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + + t.strictEqual( typeof axis.on, 'function', 'returns expected value' ); + t.strictEqual( typeof axis.emit, 'function', 'returns expected value' ); + t.strictEqual( typeof axis.removeListener, 'function', 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor ignores unrecognized options', function test( t ) { + var axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom', + 'beep': 'boop', + 'foo': 'bar' + }); + + t.strictEqual( axis.scale, 'xScale', 'returns expected value' ); + t.strictEqual( hasOwnProp( axis, 'beep' ), false, 'returns expected value' ); + t.strictEqual( hasOwnProp( axis, 'foo' ), false, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.label_align.js b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.label_align.js new file mode 100644 index 000000000000..186d1454d82e --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.label_align.js @@ -0,0 +1,183 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isUndefined = require( '@stdlib/assert/is-undefined' ); +var hasProp = require( '@stdlib/assert/has-property' ); +var isString = require( '@stdlib/assert/is-string' ); +var Axis = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Axis, '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 Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + 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 Axis({ + 'scale': 'xScale', + 'orient': 'bottom', + 'labelAlign': 'center' + }); + t.strictEqual( isString( v.labelAlign ), true, 'returns expected value' ); + + t.end(); +}); + +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 axis = new Axis({ // eslint-disable-line no-unused-vars + 'scale': 'xScale', + 'orient': 'bottom', + 'labelAlign': value + }); + }; + } +}); + +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 axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + axis.labelAlign = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `labelAlign` property', function test( t ) { + var axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + t.strictEqual( isUndefined( axis.labelAlign ), true, 'returns expected value' ); + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom', + 'labelAlign': 'center' + }); + t.strictEqual( axis.labelAlign, 'center', '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 axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + + axis.labelAlign = 'center'; + t.strictEqual( axis.labelAlign, 'center', 'returns expected value' ); + + axis.labelAlign = 'left'; + t.strictEqual( axis.labelAlign, 'left', '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 axis; + var count; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + count = 0; + + axis.on( 'change', onChange ); + + axis.labelAlign = 'center'; + t.strictEqual( count, 1, 'returns expected value' ); + + axis.labelAlign = 'left'; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + axis.labelAlign = 'left'; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.label_angle.js b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.label_angle.js new file mode 100644 index 000000000000..bf8d13bae7ac --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.label_angle.js @@ -0,0 +1,181 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isUndefined = require( '@stdlib/assert/is-undefined' ); +var hasProp = require( '@stdlib/assert/has-property' ); +var isNumber = require( '@stdlib/assert/is-number' ); +var Axis = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Axis, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `labelAngle` property', function test( t ) { + var v; + + v = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + t.strictEqual( hasOwnProp( v, 'labelAngle' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'labelAngle' ), true, 'returns expected value' ); + t.strictEqual( isUndefined( v.labelAngle ), true, 'returns expected value' ); + + v = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom', + 'labelAngle': 45 + }); + t.strictEqual( isNumber( v.labelAngle ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor throws an error if provided an invalid `labelAngle` 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 axis = new Axis({ // eslint-disable-line no-unused-vars + 'scale': 'xScale', + 'orient': 'bottom', + 'labelAngle': value + }); + }; + } +}); + +tape( 'the constructor returns an instance having a `labelAngle` 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 axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + axis.labelAngle = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `labelAngle` property', function test( t ) { + var axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + t.strictEqual( isUndefined( axis.labelAngle ), true, 'returns expected value' ); + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom', + 'labelAngle': 45 + }); + t.strictEqual( axis.labelAngle, 45, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `labelAngle` property which can be set to a valid value', function test( t ) { + var axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + + axis.labelAngle = 45; + t.strictEqual( axis.labelAngle, 45, 'returns expected value' ); + + axis.labelAngle = 90; + t.strictEqual( axis.labelAngle, 90, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `labelAngle` property is set to a new value', function test( t ) { + var axis; + var count; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + count = 0; + + axis.on( 'change', onChange ); + + axis.labelAngle = 45; + t.strictEqual( count, 1, 'returns expected value' ); + + axis.labelAngle = 90; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + axis.labelAngle = 90; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.label_baseline.js b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.label_baseline.js new file mode 100644 index 000000000000..5a37a7236a7c --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.label_baseline.js @@ -0,0 +1,181 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isUndefined = require( '@stdlib/assert/is-undefined' ); +var hasProp = require( '@stdlib/assert/has-property' ); +var Axis = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Axis, '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 Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + t.strictEqual( hasOwnProp( v, 'labelBaseline' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'labelBaseline' ), true, 'returns expected value' ); + t.strictEqual( isUndefined( v.labelBaseline ), true, 'returns expected value' ); + t.end(); +}); + +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 axis = new Axis({ // eslint-disable-line no-unused-vars + 'scale': 'xScale', + 'orient': 'bottom', + 'labelBaseline': value + }); + }; + } +}); + +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 axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + axis.labelBaseline = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `labelBaseline` property', function test( t ) { + var axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + t.strictEqual( isUndefined( axis.labelBaseline ), true, 'returns expected value' ); + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom', + 'labelBaseline': 'top' + }); + t.strictEqual( axis.labelBaseline, 'top', 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `labelBaseline` property which can be set to a valid value', function test( t ) { + var axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + + axis.labelBaseline = 'top'; + t.strictEqual( axis.labelBaseline, 'top', 'returns expected value' ); + + axis.labelBaseline = 'middle'; + t.strictEqual( axis.labelBaseline, 'middle', 'returns expected value' ); + + axis.labelBaseline = 'bottom'; + t.strictEqual( axis.labelBaseline, 'bottom', '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 axis; + var count; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + count = 0; + + axis.on( 'change', onChange ); + + axis.labelBaseline = 'top'; + t.strictEqual( count, 1, 'returns expected value' ); + + axis.labelBaseline = 'middle'; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + axis.labelBaseline = 'middle'; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.label_bound.js b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.label_bound.js new file mode 100644 index 000000000000..6025ab2ea044 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.label_bound.js @@ -0,0 +1,178 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var hasProp = require( '@stdlib/assert/has-property' ); +var Axis = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Axis, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `labelBound` property', function test( t ) { + var v; + + v = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + t.strictEqual( hasOwnProp( v, 'labelBound' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'labelBound' ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the constructor throws an error if provided an invalid `labelBound` option', function test( t ) { + var values; + var i; + + values = [ + 'beep', + 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 axis = new Axis({ // eslint-disable-line no-unused-vars + 'scale': 'xScale', + 'orient': 'bottom', + 'labelBound': value + }); + }; + } +}); + +tape( 'the constructor returns an instance having a `labelBound` property which throws an error if set to an invalid value', function test( t ) { + var values; + var i; + + values = [ + 'beep', + 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 axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + axis.labelBound = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `labelBound` property', function test( t ) { + var axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + t.strictEqual( axis.labelBound, false, 'returns expected value' ); + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom', + 'labelBound': true + }); + t.strictEqual( axis.labelBound, true, 'returns expected value' ); + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom', + 'labelBound': 10 + }); + t.strictEqual( axis.labelBound, 10, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `labelBound` property which can be set to a valid value', function test( t ) { + var axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + + axis.labelBound = true; + t.strictEqual( axis.labelBound, true, 'returns expected value' ); + + axis.labelBound = 10; + t.strictEqual( axis.labelBound, 10, 'returns expected value' ); + + axis.labelBound = false; + t.strictEqual( axis.labelBound, false, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `labelBound` property is set to a new value', function test( t ) { + var axis; + var count; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + count = 0; + + axis.on( 'change', onChange ); + + axis.labelBound = true; + t.strictEqual( count, 1, 'returns expected value' ); + + axis.labelBound = 10; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + axis.labelBound = 10; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.label_color.js b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.label_color.js new file mode 100644 index 000000000000..b2e8323bc47a --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.label_color.js @@ -0,0 +1,183 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isUndefined = require( '@stdlib/assert/is-undefined' ); +var hasProp = require( '@stdlib/assert/has-property' ); +var isString = require( '@stdlib/assert/is-string' ); +var Axis = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Axis, '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 Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + 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 Axis({ + 'scale': 'xScale', + 'orient': 'bottom', + 'labelColor': 'steelblue' + }); + t.strictEqual( isString( v.labelColor ), true, 'returns expected value' ); + + t.end(); +}); + +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 axis = new Axis({ // eslint-disable-line no-unused-vars + 'scale': 'xScale', + 'orient': 'bottom', + 'labelColor': value + }); + }; + } +}); + +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 axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + axis.labelColor = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `labelColor` property', function test( t ) { + var axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + t.strictEqual( isUndefined( axis.labelColor ), true, 'returns expected value' ); + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom', + 'labelColor': 'steelblue' + }); + t.strictEqual( axis.labelColor, 'steelblue', 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `labelColor` property which can be set to a valid value', function test( t ) { + var axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + + axis.labelColor = 'steelblue'; + t.strictEqual( axis.labelColor, 'steelblue', 'returns expected value' ); + + axis.labelColor = 'red'; + t.strictEqual( axis.labelColor, 'red', '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 axis; + var count; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + count = 0; + + axis.on( 'change', onChange ); + + axis.labelColor = 'steelblue'; + t.strictEqual( count, 1, 'returns expected value' ); + + axis.labelColor = 'red'; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + axis.labelColor = 'red'; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.label_flush.js b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.label_flush.js new file mode 100644 index 000000000000..cdb8825a57a9 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.label_flush.js @@ -0,0 +1,178 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isUndefined = require( '@stdlib/assert/is-undefined' ); +var hasProp = require( '@stdlib/assert/has-property' ); +var Axis = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Axis, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `labelFlush` property', function test( t ) { + var v; + + v = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + t.strictEqual( hasOwnProp( v, 'labelFlush' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'labelFlush' ), true, 'returns expected value' ); + t.strictEqual( isUndefined( v.labelFlush ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the constructor throws an error if provided an invalid `labelFlush` option', function test( t ) { + var values; + var i; + + values = [ + 'beep', + null, + [], + {}, + 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 axis = new Axis({ // eslint-disable-line no-unused-vars + 'scale': 'xScale', + 'orient': 'bottom', + 'labelFlush': value + }); + }; + } +}); + +tape( 'the constructor returns an instance having a `labelFlush` property which throws an error if set to an invalid value', function test( t ) { + var values; + var i; + + values = [ + 'beep', + null, + [], + {}, + 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 axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + axis.labelFlush = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `labelFlush` property', function test( t ) { + var axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + t.strictEqual( isUndefined( axis.labelFlush ), true, 'returns expected value' ); + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom', + 'labelFlush': true + }); + t.strictEqual( axis.labelFlush, true, 'returns expected value' ); + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom', + 'labelFlush': 10 + }); + t.strictEqual( axis.labelFlush, 10, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `labelFlush` property which can be set to a valid value', function test( t ) { + var axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + + axis.labelFlush = true; + t.strictEqual( axis.labelFlush, true, 'returns expected value' ); + + axis.labelFlush = 10; + t.strictEqual( axis.labelFlush, 10, 'returns expected value' ); + + axis.labelFlush = false; + t.strictEqual( axis.labelFlush, false, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `labelFlush` property is set to a new value', function test( t ) { + var axis; + var count; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + count = 0; + + axis.on( 'change', onChange ); + + axis.labelFlush = true; + t.strictEqual( count, 1, 'returns expected value' ); + + axis.labelFlush = 10; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + axis.labelFlush = 10; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.label_flush_offset.js b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.label_flush_offset.js new file mode 100644 index 000000000000..7744a4173a12 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.label_flush_offset.js @@ -0,0 +1,174 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var hasProp = require( '@stdlib/assert/has-property' ); +var isNumber = require( '@stdlib/assert/is-number' ); +var Axis = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Axis, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `labelFlushOffset` property', function test( t ) { + var v; + + v = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + t.strictEqual( hasOwnProp( v, 'labelFlushOffset' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'labelFlushOffset' ), true, 'returns expected value' ); + t.strictEqual( isNumber( v.labelFlushOffset ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the constructor throws an error if provided an invalid `labelFlushOffset` 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 axis = new Axis({ // eslint-disable-line no-unused-vars + 'scale': 'xScale', + 'orient': 'bottom', + 'labelFlushOffset': value + }); + }; + } +}); + +tape( 'the constructor returns an instance having a `labelFlushOffset` 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 axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + axis.labelFlushOffset = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `labelFlushOffset` property', function test( t ) { + var axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + t.strictEqual( axis.labelFlushOffset, 0, 'returns expected value' ); + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom', + 'labelFlushOffset': 5 + }); + t.strictEqual( axis.labelFlushOffset, 5, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `labelFlushOffset` property which can be set to a valid value', function test( t ) { + var axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + + axis.labelFlushOffset = 5; + t.strictEqual( axis.labelFlushOffset, 5, 'returns expected value' ); + + axis.labelFlushOffset = 10; + t.strictEqual( axis.labelFlushOffset, 10, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `labelFlushOffset` property is set to a new value', function test( t ) { + var axis; + var count; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + count = 0; + + axis.on( 'change', onChange ); + + axis.labelFlushOffset = 5; + t.strictEqual( count, 1, 'returns expected value' ); + + axis.labelFlushOffset = 10; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + axis.labelFlushOffset = 10; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.label_font.js b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.label_font.js new file mode 100644 index 000000000000..00488fda76cc --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.label_font.js @@ -0,0 +1,183 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isUndefined = require( '@stdlib/assert/is-undefined' ); +var hasProp = require( '@stdlib/assert/has-property' ); +var isString = require( '@stdlib/assert/is-string' ); +var Axis = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Axis, '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 Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + 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 Axis({ + 'scale': 'xScale', + 'orient': 'bottom', + 'labelFont': 'Arial' + }); + t.strictEqual( isString( v.labelFont ), true, 'returns expected value' ); + + t.end(); +}); + +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 axis = new Axis({ // eslint-disable-line no-unused-vars + 'scale': 'xScale', + 'orient': 'bottom', + 'labelFont': value + }); + }; + } +}); + +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 axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + axis.labelFont = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `labelFont` property', function test( t ) { + var axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + t.strictEqual( isUndefined( axis.labelFont ), true, 'returns expected value' ); + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom', + 'labelFont': 'Arial' + }); + t.strictEqual( axis.labelFont, 'Arial', 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `labelFont` property which can be set to a valid value', function test( t ) { + var axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + + axis.labelFont = 'Arial'; + t.strictEqual( axis.labelFont, 'Arial', 'returns expected value' ); + + axis.labelFont = 'Helvetica'; + t.strictEqual( axis.labelFont, 'Helvetica', '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 axis; + var count; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + count = 0; + + axis.on( 'change', onChange ); + + axis.labelFont = 'Arial'; + t.strictEqual( count, 1, 'returns expected value' ); + + axis.labelFont = 'Helvetica'; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + axis.labelFont = 'Helvetica'; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.label_font_size.js b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.label_font_size.js new file mode 100644 index 000000000000..a09d3c60e65a --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.label_font_size.js @@ -0,0 +1,181 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isUndefined = require( '@stdlib/assert/is-undefined' ); +var hasProp = require( '@stdlib/assert/has-property' ); +var isNumber = require( '@stdlib/assert/is-number' ); +var Axis = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Axis, '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 Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + 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 Axis({ + 'scale': 'xScale', + 'orient': 'bottom', + 'labelFontSize': 12 + }); + t.strictEqual( isNumber( v.labelFontSize ), true, 'returns expected value' ); + + t.end(); +}); + +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 axis = new Axis({ // eslint-disable-line no-unused-vars + 'scale': 'xScale', + 'orient': 'bottom', + 'labelFontSize': value + }); + }; + } +}); + +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', + 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 axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + axis.labelFontSize = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `labelFontSize` property', function test( t ) { + var axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + t.strictEqual( isUndefined( axis.labelFontSize ), true, 'returns expected value' ); + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom', + 'labelFontSize': 12 + }); + t.strictEqual( axis.labelFontSize, 12, '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 axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + + axis.labelFontSize = 12; + t.strictEqual( axis.labelFontSize, 12, 'returns expected value' ); + + axis.labelFontSize = 16; + t.strictEqual( axis.labelFontSize, 16, '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 axis; + var count; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + count = 0; + + axis.on( 'change', onChange ); + + axis.labelFontSize = 12; + t.strictEqual( count, 1, 'returns expected value' ); + + axis.labelFontSize = 16; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + axis.labelFontSize = 16; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.label_font_style.js b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.label_font_style.js new file mode 100644 index 000000000000..14307bb5abdb --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.label_font_style.js @@ -0,0 +1,183 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isUndefined = require( '@stdlib/assert/is-undefined' ); +var hasProp = require( '@stdlib/assert/has-property' ); +var isString = require( '@stdlib/assert/is-string' ); +var Axis = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Axis, '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 Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + 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 Axis({ + 'scale': 'xScale', + 'orient': 'bottom', + 'labelFontStyle': 'italic' + }); + t.strictEqual( isString( v.labelFontStyle ), true, 'returns expected value' ); + + t.end(); +}); + +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 axis = new Axis({ // eslint-disable-line no-unused-vars + 'scale': 'xScale', + 'orient': 'bottom', + 'labelFontStyle': value + }); + }; + } +}); + +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 axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + axis.labelFontStyle = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `labelFontStyle` property', function test( t ) { + var axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + t.strictEqual( isUndefined( axis.labelFontStyle ), true, 'returns expected value' ); + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom', + 'labelFontStyle': 'italic' + }); + t.strictEqual( axis.labelFontStyle, 'italic', 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `labelFontStyle` property which can be set to a valid value', function test( t ) { + var axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + + axis.labelFontStyle = 'italic'; + t.strictEqual( axis.labelFontStyle, 'italic', 'returns expected value' ); + + axis.labelFontStyle = 'normal'; + t.strictEqual( axis.labelFontStyle, 'normal', '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 axis; + var count; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + count = 0; + + axis.on( 'change', onChange ); + + axis.labelFontStyle = 'italic'; + t.strictEqual( count, 1, 'returns expected value' ); + + axis.labelFontStyle = 'normal'; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + axis.labelFontStyle = 'normal'; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.label_font_weight.js b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.label_font_weight.js new file mode 100644 index 000000000000..bde53ae90d92 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.label_font_weight.js @@ -0,0 +1,180 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isUndefined = require( '@stdlib/assert/is-undefined' ); +var hasProp = require( '@stdlib/assert/has-property' ); +var Axis = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Axis, '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 Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + 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' ); + t.end(); +}); + +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 axis = new Axis({ // eslint-disable-line no-unused-vars + 'scale': 'xScale', + 'orient': 'bottom', + 'labelFontWeight': value + }); + }; + } +}); + +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 axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + axis.labelFontWeight = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `labelFontWeight` property', function test( t ) { + var axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + t.strictEqual( isUndefined( axis.labelFontWeight ), true, 'returns expected value' ); + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom', + 'labelFontWeight': 'bold' + }); + t.strictEqual( axis.labelFontWeight, 'bold', 'returns expected value' ); + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom', + 'labelFontWeight': 700 + }); + t.strictEqual( axis.labelFontWeight, 700, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `labelFontWeight` property which can be set to a valid value', function test( t ) { + var axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + + axis.labelFontWeight = 'bold'; + t.strictEqual( axis.labelFontWeight, 'bold', 'returns expected value' ); + + axis.labelFontWeight = 700; + t.strictEqual( axis.labelFontWeight, 700, 'returns expected value' ); + + axis.labelFontWeight = 'normal'; + t.strictEqual( axis.labelFontWeight, 'normal', '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', function test( t ) { + var axis; + var count; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + count = 0; + + axis.on( 'change', onChange ); + + axis.labelFontWeight = 'bold'; + t.strictEqual( count, 1, 'returns expected value' ); + + axis.labelFontWeight = 700; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + axis.labelFontWeight = 700; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.label_limit.js b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.label_limit.js new file mode 100644 index 000000000000..387922b60064 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.label_limit.js @@ -0,0 +1,176 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isUndefined = require( '@stdlib/assert/is-undefined' ); +var hasProp = require( '@stdlib/assert/has-property' ); +var Axis = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Axis, '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 Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + 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' ); + t.end(); +}); + +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 axis = new Axis({ // eslint-disable-line no-unused-vars + 'scale': 'xScale', + 'orient': 'bottom', + 'labelLimit': value + }); + }; + } +}); + +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 axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + axis.labelLimit = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `labelLimit` property', function test( t ) { + var axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + t.strictEqual( isUndefined( axis.labelLimit ), true, 'returns expected value' ); + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom', + 'labelLimit': 100 + }); + t.strictEqual( axis.labelLimit, 100, '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 axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + + axis.labelLimit = 100; + t.strictEqual( axis.labelLimit, 100, 'returns expected value' ); + + axis.labelLimit = 200; + t.strictEqual( axis.labelLimit, 200, '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 axis; + var count; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + count = 0; + + axis.on( 'change', onChange ); + + axis.labelLimit = 100; + t.strictEqual( count, 1, 'returns expected value' ); + + axis.labelLimit = 200; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + axis.labelLimit = 200; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.label_line_height.js b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.label_line_height.js new file mode 100644 index 000000000000..67d487bc4f32 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.label_line_height.js @@ -0,0 +1,181 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isUndefined = require( '@stdlib/assert/is-undefined' ); +var hasProp = require( '@stdlib/assert/has-property' ); +var isNumber = require( '@stdlib/assert/is-number' ); +var Axis = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Axis, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `labelLineHeight` property', function test( t ) { + var v; + + v = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + t.strictEqual( hasOwnProp( v, 'labelLineHeight' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'labelLineHeight' ), true, 'returns expected value' ); + t.strictEqual( isUndefined( v.labelLineHeight ), true, 'returns expected value' ); + + v = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom', + 'labelLineHeight': 20 + }); + t.strictEqual( isNumber( v.labelLineHeight ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor throws an error if provided an invalid `labelLineHeight` 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 axis = new Axis({ // eslint-disable-line no-unused-vars + 'scale': 'xScale', + 'orient': 'bottom', + 'labelLineHeight': value + }); + }; + } +}); + +tape( 'the constructor returns an instance having a `labelLineHeight` 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 axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + axis.labelLineHeight = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `labelLineHeight` property', function test( t ) { + var axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + t.strictEqual( isUndefined( axis.labelLineHeight ), true, 'returns expected value' ); + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom', + 'labelLineHeight': 20 + }); + t.strictEqual( axis.labelLineHeight, 20, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `labelLineHeight` property which can be set to a valid value', function test( t ) { + var axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + + axis.labelLineHeight = 20; + t.strictEqual( axis.labelLineHeight, 20, 'returns expected value' ); + + axis.labelLineHeight = 24; + t.strictEqual( axis.labelLineHeight, 24, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `labelLineHeight` property is set to a new value', function test( t ) { + var axis; + var count; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + count = 0; + + axis.on( 'change', onChange ); + + axis.labelLineHeight = 20; + t.strictEqual( count, 1, 'returns expected value' ); + + axis.labelLineHeight = 24; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + axis.labelLineHeight = 24; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.label_offset.js b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.label_offset.js new file mode 100644 index 000000000000..48f6081c62f3 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.label_offset.js @@ -0,0 +1,181 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isUndefined = require( '@stdlib/assert/is-undefined' ); +var hasProp = require( '@stdlib/assert/has-property' ); +var isNumber = require( '@stdlib/assert/is-number' ); +var Axis = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Axis, '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 Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + 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 Axis({ + 'scale': 'xScale', + 'orient': 'bottom', + 'labelOffset': 5 + }); + t.strictEqual( isNumber( v.labelOffset ), true, 'returns expected value' ); + + t.end(); +}); + +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 axis = new Axis({ // eslint-disable-line no-unused-vars + 'scale': 'xScale', + 'orient': 'bottom', + 'labelOffset': value + }); + }; + } +}); + +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 axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + axis.labelOffset = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `labelOffset` property', function test( t ) { + var axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + t.strictEqual( isUndefined( axis.labelOffset ), true, 'returns expected value' ); + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom', + 'labelOffset': 5 + }); + t.strictEqual( axis.labelOffset, 5, '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 axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + + axis.labelOffset = 5; + t.strictEqual( axis.labelOffset, 5, 'returns expected value' ); + + axis.labelOffset = 10; + t.strictEqual( axis.labelOffset, 10, '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 axis; + var count; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + count = 0; + + axis.on( 'change', onChange ); + + axis.labelOffset = 5; + t.strictEqual( count, 1, 'returns expected value' ); + + axis.labelOffset = 10; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + axis.labelOffset = 10; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.label_opacity.js b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.label_opacity.js new file mode 100644 index 000000000000..524db85d26a8 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.label_opacity.js @@ -0,0 +1,175 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var hasProp = require( '@stdlib/assert/has-property' ); +var isNumber = require( '@stdlib/assert/is-number' ); +var Axis = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Axis, '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 Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + t.strictEqual( hasOwnProp( v, 'labelOpacity' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'labelOpacity' ), true, 'returns expected value' ); + t.strictEqual( isNumber( v.labelOpacity ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the constructor throws an error if provided an invalid `labelOpacity` option', function test( t ) { + var values; + var i; + + values = [ + 'beep', + -0.1, + 1.1, + NaN, + 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 axis = new Axis({ // eslint-disable-line no-unused-vars + 'scale': 'xScale', + 'orient': 'bottom', + 'labelOpacity': value + }); + }; + } +}); + +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', + -0.1, + 1.1, + NaN, + 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 axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + axis.labelOpacity = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `labelOpacity` property', function test( t ) { + var axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + t.strictEqual( axis.labelOpacity, 1, 'returns expected value' ); + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom', + 'labelOpacity': 0.5 + }); + t.strictEqual( axis.labelOpacity, 0.5, '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 axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + + axis.labelOpacity = 0.5; + t.strictEqual( axis.labelOpacity, 0.5, 'returns expected value' ); + + axis.labelOpacity = 0; + t.strictEqual( axis.labelOpacity, 0, 'returns expected value' ); + + axis.labelOpacity = 1; + t.strictEqual( axis.labelOpacity, 1, '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 axis; + var count; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + count = 0; + + axis.on( 'change', onChange ); + + axis.labelOpacity = 0.5; + t.strictEqual( count, 1, 'returns expected value' ); + + axis.labelOpacity = 0.3; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + axis.labelOpacity = 0.3; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.label_overlap.js b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.label_overlap.js new file mode 100644 index 000000000000..4a2320d27bd0 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.label_overlap.js @@ -0,0 +1,185 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var hasProp = require( '@stdlib/assert/has-property' ); +var Axis = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Axis, '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 Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + t.strictEqual( hasOwnProp( v, 'labelOverlap' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'labelOverlap' ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the constructor throws an error if provided an invalid `labelOverlap` option', function test( t ) { + var values; + var i; + + values = [ + 'beep', + 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 axis = new Axis({ // eslint-disable-line no-unused-vars + 'scale': 'xScale', + 'orient': 'bottom', + 'labelOverlap': value + }); + }; + } +}); + +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 = [ + 'beep', + 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 axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + axis.labelOverlap = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `labelOverlap` property', function test( t ) { + var axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + t.strictEqual( axis.labelOverlap, false, 'returns expected value' ); + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom', + 'labelOverlap': true + }); + t.strictEqual( axis.labelOverlap, true, 'returns expected value' ); + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom', + 'labelOverlap': 'parity' + }); + t.strictEqual( axis.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 axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + + axis.labelOverlap = true; + t.strictEqual( axis.labelOverlap, true, 'returns expected value' ); + + axis.labelOverlap = 'parity'; + t.strictEqual( axis.labelOverlap, 'parity', 'returns expected value' ); + + axis.labelOverlap = 'greedy'; + t.strictEqual( axis.labelOverlap, 'greedy', 'returns expected value' ); + + axis.labelOverlap = false; + t.strictEqual( axis.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 axis; + var count; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + count = 0; + + axis.on( 'change', onChange ); + + axis.labelOverlap = true; + t.strictEqual( count, 1, 'returns expected value' ); + + axis.labelOverlap = 'parity'; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + axis.labelOverlap = 'parity'; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.label_padding.js b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.label_padding.js new file mode 100644 index 000000000000..f59b8777ea14 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.label_padding.js @@ -0,0 +1,181 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isUndefined = require( '@stdlib/assert/is-undefined' ); +var hasProp = require( '@stdlib/assert/has-property' ); +var isNumber = require( '@stdlib/assert/is-number' ); +var Axis = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Axis, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `labelPadding` property', function test( t ) { + var v; + + v = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + t.strictEqual( hasOwnProp( v, 'labelPadding' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'labelPadding' ), true, 'returns expected value' ); + t.strictEqual( isUndefined( v.labelPadding ), true, 'returns expected value' ); + + v = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom', + 'labelPadding': 5 + }); + t.strictEqual( isNumber( v.labelPadding ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor throws an error if provided an invalid `labelPadding` 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 axis = new Axis({ // eslint-disable-line no-unused-vars + 'scale': 'xScale', + 'orient': 'bottom', + 'labelPadding': value + }); + }; + } +}); + +tape( 'the constructor returns an instance having a `labelPadding` 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 axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + axis.labelPadding = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `labelPadding` property', function test( t ) { + var axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + t.strictEqual( isUndefined( axis.labelPadding ), true, 'returns expected value' ); + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom', + 'labelPadding': 5 + }); + t.strictEqual( axis.labelPadding, 5, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `labelPadding` property which can be set to a valid value', function test( t ) { + var axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + + axis.labelPadding = 5; + t.strictEqual( axis.labelPadding, 5, 'returns expected value' ); + + axis.labelPadding = 10; + t.strictEqual( axis.labelPadding, 10, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `labelPadding` property is set to a new value', function test( t ) { + var axis; + var count; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + count = 0; + + axis.on( 'change', onChange ); + + axis.labelPadding = 5; + t.strictEqual( count, 1, 'returns expected value' ); + + axis.labelPadding = 10; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + axis.labelPadding = 10; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.label_separation.js b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.label_separation.js new file mode 100644 index 000000000000..17a9cc402e01 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.label_separation.js @@ -0,0 +1,178 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var hasProp = require( '@stdlib/assert/has-property' ); +var isNumber = require( '@stdlib/assert/is-number' ); +var Axis = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Axis, '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 Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + t.strictEqual( hasOwnProp( v, 'labelSeparation' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'labelSeparation' ), true, 'returns expected value' ); + t.strictEqual( isNumber( v.labelSeparation ), true, 'returns expected value' ); + t.end(); +}); + +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 axis = new Axis({ // eslint-disable-line no-unused-vars + 'scale': 'xScale', + 'orient': 'bottom', + 'labelSeparation': value + }); + }; + } +}); + +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 axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + axis.labelSeparation = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `labelSeparation` property', function test( t ) { + var axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + t.strictEqual( axis.labelSeparation, 0, 'returns expected value' ); + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom', + 'labelSeparation': 10 + }); + t.strictEqual( axis.labelSeparation, 10, '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 axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + + axis.labelSeparation = 10; + t.strictEqual( axis.labelSeparation, 10, 'returns expected value' ); + + axis.labelSeparation = 20; + t.strictEqual( axis.labelSeparation, 20, '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 axis; + var count; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + count = 0; + + axis.on( 'change', onChange ); + + axis.labelSeparation = 10; + t.strictEqual( count, 1, 'returns expected value' ); + + axis.labelSeparation = 20; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + axis.labelSeparation = 20; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.labels.js b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.labels.js new file mode 100644 index 000000000000..ccf05550d1b2 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.labels.js @@ -0,0 +1,174 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var hasProp = require( '@stdlib/assert/has-property' ); +var isBoolean = require( '@stdlib/assert/is-boolean' ); +var Axis = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Axis, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `labels` property', function test( t ) { + var v; + + v = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + t.strictEqual( hasOwnProp( v, 'labels' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'labels' ), true, 'returns expected value' ); + t.strictEqual( isBoolean( v.labels ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the constructor throws an error if provided an invalid `labels` 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 axis = new Axis({ // eslint-disable-line no-unused-vars + 'scale': 'xScale', + 'orient': 'bottom', + 'labels': value + }); + }; + } +}); + +tape( 'the constructor returns an instance having a `labels` property which throws an error if set to a non-boolean value', function test( t ) { + var values; + var i; + + values = [ + '5', + 5, + NaN, + null, + void 0, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + var axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + axis.labels = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `labels` property', function test( t ) { + var axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + t.strictEqual( axis.labels, true, 'returns expected value' ); + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom', + 'labels': false + }); + t.strictEqual( axis.labels, false, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `labels` property which can be set to a boolean', function test( t ) { + var axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + + axis.labels = false; + t.strictEqual( axis.labels, false, 'returns expected value' ); + + axis.labels = true; + t.strictEqual( axis.labels, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `labels` property is set to a new value', function test( t ) { + var axis; + var count; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + count = 0; + + axis.on( 'change', onChange ); + + axis.labels = false; + t.strictEqual( count, 1, 'returns expected value' ); + + axis.labels = true; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + axis.labels = true; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.max_extent.js b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.max_extent.js new file mode 100644 index 000000000000..b27489af8260 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.max_extent.js @@ -0,0 +1,185 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isUndefined = require( '@stdlib/assert/is-undefined' ); +var hasProp = require( '@stdlib/assert/has-property' ); +var isNumber = require( '@stdlib/assert/is-number' ); +var Axis = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Axis, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `maxExtent` property', function test( t ) { + var v; + + v = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + t.strictEqual( hasOwnProp( v, 'maxExtent' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'maxExtent' ), true, 'returns expected value' ); + t.strictEqual( isUndefined( v.maxExtent ), true, 'returns expected value' ); + + v = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom', + 'maxExtent': 200 + }); + t.strictEqual( isNumber( v.maxExtent ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor throws an error if provided an invalid `maxExtent` 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 axis = new Axis({ // eslint-disable-line no-unused-vars + 'scale': 'xScale', + 'orient': 'bottom', + 'maxExtent': value + }); + }; + } +}); + +tape( 'the constructor returns an instance having a `maxExtent` 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 axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + axis.maxExtent = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `maxExtent` property', function test( t ) { + var axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + t.strictEqual( isUndefined( axis.maxExtent ), true, 'returns expected value' ); + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom', + 'maxExtent': 200 + }); + t.strictEqual( axis.maxExtent, 200, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `maxExtent` property which can be set to a valid value', function test( t ) { + var axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + + axis.maxExtent = 200; + t.strictEqual( axis.maxExtent, 200, 'returns expected value' ); + + axis.maxExtent = 300; + t.strictEqual( axis.maxExtent, 300, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `maxExtent` property is set to a new value', function test( t ) { + var axis; + var count; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + count = 0; + + axis.on( 'change', onChange ); + + axis.maxExtent = 200; + t.strictEqual( count, 1, 'returns expected value' ); + + axis.maxExtent = 300; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + axis.maxExtent = 300; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.min_extent.js b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.min_extent.js new file mode 100644 index 000000000000..b9c33f9ece24 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.min_extent.js @@ -0,0 +1,185 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isUndefined = require( '@stdlib/assert/is-undefined' ); +var hasProp = require( '@stdlib/assert/has-property' ); +var isNumber = require( '@stdlib/assert/is-number' ); +var Axis = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Axis, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `minExtent` property', function test( t ) { + var v; + + v = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + t.strictEqual( hasOwnProp( v, 'minExtent' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'minExtent' ), true, 'returns expected value' ); + t.strictEqual( isUndefined( v.minExtent ), true, 'returns expected value' ); + + v = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom', + 'minExtent': 50 + }); + t.strictEqual( isNumber( v.minExtent ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor throws an error if provided an invalid `minExtent` 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 axis = new Axis({ // eslint-disable-line no-unused-vars + 'scale': 'xScale', + 'orient': 'bottom', + 'minExtent': value + }); + }; + } +}); + +tape( 'the constructor returns an instance having a `minExtent` 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 axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + axis.minExtent = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `minExtent` property', function test( t ) { + var axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + t.strictEqual( isUndefined( axis.minExtent ), true, 'returns expected value' ); + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom', + 'minExtent': 50 + }); + t.strictEqual( axis.minExtent, 50, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `minExtent` property which can be set to a valid value', function test( t ) { + var axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + + axis.minExtent = 50; + t.strictEqual( axis.minExtent, 50, 'returns expected value' ); + + axis.minExtent = 100; + t.strictEqual( axis.minExtent, 100, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `minExtent` property is set to a new value', function test( t ) { + var axis; + var count; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + count = 0; + + axis.on( 'change', onChange ); + + axis.minExtent = 50; + t.strictEqual( count, 1, 'returns expected value' ); + + axis.minExtent = 100; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + axis.minExtent = 100; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.offset.js b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.offset.js new file mode 100644 index 000000000000..1fc1189ca118 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.offset.js @@ -0,0 +1,181 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isUndefined = require( '@stdlib/assert/is-undefined' ); +var hasProp = require( '@stdlib/assert/has-property' ); +var isNumber = require( '@stdlib/assert/is-number' ); +var Axis = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Axis, '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 Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + 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 Axis({ + 'scale': 'xScale', + 'orient': 'bottom', + 'offset': 10 + }); + t.strictEqual( isNumber( v.offset ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor throws an error if provided an invalid `offset` option', function test( t ) { + var values; + var i; + + values = [ + 'beep', + 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 axis = new Axis({ // eslint-disable-line no-unused-vars + 'scale': 'xScale', + 'orient': 'bottom', + 'offset': value + }); + }; + } +}); + +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 axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + axis.offset = value; + }; + } +}); + +tape( 'the constructor returns an instance having an `offset` property', function test( t ) { + var axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + t.strictEqual( isUndefined( axis.offset ), true, 'returns expected value' ); + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom', + 'offset': 10 + }); + t.strictEqual( axis.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 axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + + axis.offset = 10; + t.strictEqual( axis.offset, 10, 'returns expected value' ); + + axis.offset = 20; + t.strictEqual( axis.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 axis; + var count; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + count = 0; + + axis.on( 'change', onChange ); + + axis.offset = 10; + t.strictEqual( count, 1, 'returns expected value' ); + + axis.offset = 20; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + axis.offset = 20; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.orient.js b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.orient.js new file mode 100644 index 000000000000..d9fd3826f05c --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.orient.js @@ -0,0 +1,198 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var hasProp = require( '@stdlib/assert/has-property' ); +var isString = require( '@stdlib/assert/is-string' ); +var Axis = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Axis, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `orient` property', function test( t ) { + var v; + + v = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + t.strictEqual( hasOwnProp( v, 'orient' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'orient' ), true, 'returns expected value' ); + t.strictEqual( isString( v.orient ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the constructor throws an error if provided an invalid `orient` option', function test( t ) { + var values; + var i; + + values = [ + 'beep', + 'boop', + 'BOTTOM', + 5, + NaN, + null, + 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 axis = new Axis({ // eslint-disable-line no-unused-vars + 'scale': 'xScale', + 'orient': value + }); + }; + } +}); + +tape( 'the constructor returns an instance having a `orient` property which throws an error if set to an invalid value', function test( t ) { + var values; + var i; + + values = [ + 'beep', + 'boop', + 'BOTTOM', + 5, + NaN, + null, + 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 axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + axis.orient = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `orient` property', function test( t ) { + var axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + t.strictEqual( axis.orient, 'bottom', 'returns expected value' ); + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'top' + }); + t.strictEqual( axis.orient, 'top', 'returns expected value' ); + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'left' + }); + t.strictEqual( axis.orient, 'left', 'returns expected value' ); + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'right' + }); + t.strictEqual( axis.orient, 'right', 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `orient` property which can be set to a valid orientation', function test( t ) { + var axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + + axis.orient = 'top'; + t.strictEqual( axis.orient, 'top', 'returns expected value' ); + + axis.orient = 'left'; + t.strictEqual( axis.orient, 'left', 'returns expected value' ); + + axis.orient = 'right'; + t.strictEqual( axis.orient, 'right', 'returns expected value' ); + + axis.orient = 'bottom'; + t.strictEqual( axis.orient, 'bottom', '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 axis; + var count; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + count = 0; + + axis.on( 'change', onChange ); + + axis.orient = 'top'; + t.strictEqual( count, 1, 'returns expected value' ); + + axis.orient = 'left'; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + axis.orient = 'left'; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.position.js b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.position.js new file mode 100644 index 000000000000..4ad9efbb9b1f --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.position.js @@ -0,0 +1,174 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var hasProp = require( '@stdlib/assert/has-property' ); +var isNumber = require( '@stdlib/assert/is-number' ); +var Axis = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Axis, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `position` property', function test( t ) { + var v; + + v = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + t.strictEqual( hasOwnProp( v, 'position' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'position' ), true, 'returns expected value' ); + t.strictEqual( isNumber( v.position ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the constructor throws an error if provided an invalid `position` 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 axis = new Axis({ // eslint-disable-line no-unused-vars + 'scale': 'xScale', + 'orient': 'bottom', + 'position': value + }); + }; + } +}); + +tape( 'the constructor returns an instance having a `position` 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 axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + axis.position = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `position` property', function test( t ) { + var axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + t.strictEqual( axis.position, 0, 'returns expected value' ); + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom', + 'position': 100 + }); + t.strictEqual( axis.position, 100, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `position` property which can be set to a valid value', function test( t ) { + var axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + + axis.position = 100; + t.strictEqual( axis.position, 100, 'returns expected value' ); + + axis.position = 200; + t.strictEqual( axis.position, 200, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `position` property is set to a new value', function test( t ) { + var axis; + var count; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + count = 0; + + axis.on( 'change', onChange ); + + axis.position = 100; + t.strictEqual( count, 1, 'returns expected value' ); + + axis.position = 200; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + axis.position = 200; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.properties.js b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.properties.js new file mode 100644 index 000000000000..dfbfaa810a89 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.properties.js @@ -0,0 +1,86 @@ +/** +* @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 Axis = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Axis, '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 Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + 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 axis; + var props; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + props = axis.properties; + + t.strictEqual( isArray( props ), true, 'returns expected value' ); + + expected = [ 'aria', 'bandPosition', 'description', 'domain', 'domainCap', 'domainColor', 'domainDash', 'domainDashOffset', 'domainOpacity', 'domainWidth', 'encode', 'format', 'formatType', 'grid', 'gridCap', 'gridColor', 'gridDash', 'gridDashOffset', 'gridOpacity', 'gridScale', 'gridWidth', 'labelAlign', 'labelAngle', 'labelBaseline', 'labelBound', 'labelColor', 'labelFlush', 'labelFlushOffset', 'labelFont', 'labelFontSize', 'labelFontStyle', 'labelFontWeight', 'labelLimit', 'labelLineHeight', 'labelOffset', 'labelOpacity', 'labelOverlap', 'labelPadding', 'labels', 'labelSeparation', 'maxExtent', 'minExtent', 'offset', 'orient', 'position', 'scale', 'tickBand', 'tickCap', 'tickColor', 'tickCount', 'tickDash', 'tickDashOffset', 'tickExtra', 'tickMinStep', 'tickOffset', 'tickOpacity', 'tickRound', 'ticks', 'tickSize', 'tickWidth', 'title', 'titleAlign', 'titleAnchor', 'titleAngle', 'titleBaseline', 'titleColor', 'titleFont', 'titleFontSize', 'titleFontStyle', 'titleFontWeight', 'titleLimit', 'titleLineHeight', 'titleOpacity', 'titlePadding', 'titleX', 'titleY', 'translate', '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 axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + props1 = axis.properties; + props2 = axis.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/axis/ctor/test/test.scale.js b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.scale.js new file mode 100644 index 000000000000..fdb876e29f5a --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.scale.js @@ -0,0 +1,174 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var hasProp = require( '@stdlib/assert/has-property' ); +var isString = require( '@stdlib/assert/is-string' ); +var Axis = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Axis, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `scale` property', function test( t ) { + var v; + + v = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + t.strictEqual( hasOwnProp( v, 'scale' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'scale' ), true, 'returns expected value' ); + t.strictEqual( isString( v.scale ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the constructor throws an error if provided an invalid `scale` 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 axis = new Axis({ // eslint-disable-line no-unused-vars + 'scale': value, + 'orient': 'bottom' + }); + }; + } +}); + +tape( 'the constructor returns an instance having a `scale` 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 axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + axis.scale = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `scale` property', function test( t ) { + var axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + t.strictEqual( axis.scale, 'xScale', 'returns expected value' ); + + axis = new Axis({ + 'scale': 'yScale', + 'orient': 'left' + }); + t.strictEqual( axis.scale, 'yScale', 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `scale` property which can be set to a string', function test( t ) { + var axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + + axis.scale = 'yScale'; + t.strictEqual( axis.scale, 'yScale', 'returns expected value' ); + + axis.scale = 'xScale'; + t.strictEqual( axis.scale, 'xScale', 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `scale` property is set to a new value', function test( t ) { + var axis; + var count; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + count = 0; + + axis.on( 'change', onChange ); + + axis.scale = 'yScale'; + t.strictEqual( count, 1, 'returns expected value' ); + + axis.scale = 'xScale'; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + axis.scale = 'xScale'; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.tick_band.js b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.tick_band.js new file mode 100644 index 000000000000..ff1841d2221b --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.tick_band.js @@ -0,0 +1,185 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isUndefined = require( '@stdlib/assert/is-undefined' ); +var hasProp = require( '@stdlib/assert/has-property' ); +var Axis = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Axis, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `tickBand` property', function test( t ) { + var v; + + v = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + t.strictEqual( hasOwnProp( v, 'tickBand' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'tickBand' ), true, 'returns expected value' ); + t.strictEqual( isUndefined( v.tickBand ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the constructor throws an error if provided an invalid `tickBand` 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 axis = new Axis({ // eslint-disable-line no-unused-vars + 'scale': 'xScale', + 'orient': 'bottom', + 'tickBand': value + }); + }; + } +}); + +tape( 'the constructor returns an instance having a `tickBand` 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 axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + axis.tickBand = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `tickBand` property', function test( t ) { + var axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + t.strictEqual( isUndefined( axis.tickBand ), true, 'returns expected value' ); + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom', + 'tickBand': 'center' + }); + t.strictEqual( axis.tickBand, 'center', 'returns expected value' ); + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom', + 'tickBand': 'extent' + }); + t.strictEqual( axis.tickBand, 'extent', 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `tickBand` property which can be set to a valid value', function test( t ) { + var axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + + axis.tickBand = 'center'; + t.strictEqual( axis.tickBand, 'center', 'returns expected value' ); + + axis.tickBand = 'extent'; + t.strictEqual( axis.tickBand, 'extent', 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `tickBand` property is set to a new value', function test( t ) { + var axis; + var count; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + count = 0; + + axis.on( 'change', onChange ); + + axis.tickBand = 'center'; + t.strictEqual( count, 1, 'returns expected value' ); + + axis.tickBand = 'extent'; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + axis.tickBand = 'extent'; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.tick_cap.js b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.tick_cap.js new file mode 100644 index 000000000000..338cdad68576 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.tick_cap.js @@ -0,0 +1,190 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var hasProp = require( '@stdlib/assert/has-property' ); +var isString = require( '@stdlib/assert/is-string' ); +var Axis = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Axis, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `tickCap` property', function test( t ) { + var v; + + v = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + t.strictEqual( hasOwnProp( v, 'tickCap' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'tickCap' ), true, 'returns expected value' ); + t.strictEqual( isString( v.tickCap ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the constructor throws an error if provided an invalid `tickCap` 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 axis = new Axis({ // eslint-disable-line no-unused-vars + 'scale': 'xScale', + 'orient': 'bottom', + 'tickCap': value + }); + }; + } +}); + +tape( 'the constructor returns an instance having a `tickCap` 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 axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + axis.tickCap = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `tickCap` property', function test( t ) { + var axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + t.strictEqual( axis.tickCap, 'butt', 'returns expected value' ); + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom', + 'tickCap': 'round' + }); + t.strictEqual( axis.tickCap, 'round', 'returns expected value' ); + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom', + 'tickCap': 'square' + }); + t.strictEqual( axis.tickCap, 'square', 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `tickCap` property which can be set to a valid value', function test( t ) { + var axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + + axis.tickCap = 'round'; + t.strictEqual( axis.tickCap, 'round', 'returns expected value' ); + + axis.tickCap = 'square'; + t.strictEqual( axis.tickCap, 'square', 'returns expected value' ); + + axis.tickCap = 'butt'; + t.strictEqual( axis.tickCap, 'butt', 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `tickCap` property is set to a new value', function test( t ) { + var axis; + var count; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + count = 0; + + axis.on( 'change', onChange ); + + axis.tickCap = 'round'; + t.strictEqual( count, 1, 'returns expected value' ); + + axis.tickCap = 'square'; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + axis.tickCap = 'square'; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.tick_color.js b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.tick_color.js new file mode 100644 index 000000000000..205429b0ddad --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.tick_color.js @@ -0,0 +1,183 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isUndefined = require( '@stdlib/assert/is-undefined' ); +var hasProp = require( '@stdlib/assert/has-property' ); +var isString = require( '@stdlib/assert/is-string' ); +var Axis = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Axis, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `tickColor` property', function test( t ) { + var v; + + v = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + t.strictEqual( hasOwnProp( v, 'tickColor' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'tickColor' ), true, 'returns expected value' ); + t.strictEqual( isUndefined( v.tickColor ), true, 'returns expected value' ); + + v = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom', + 'tickColor': 'steelblue' + }); + t.strictEqual( isString( v.tickColor ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor throws an error if provided an invalid `tickColor` 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 axis = new Axis({ // eslint-disable-line no-unused-vars + 'scale': 'xScale', + 'orient': 'bottom', + 'tickColor': value + }); + }; + } +}); + +tape( 'the constructor returns an instance having a `tickColor` 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 axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + axis.tickColor = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `tickColor` property', function test( t ) { + var axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + t.strictEqual( isUndefined( axis.tickColor ), true, 'returns expected value' ); + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom', + 'tickColor': 'steelblue' + }); + t.strictEqual( axis.tickColor, 'steelblue', 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `tickColor` property which can be set to a valid value', function test( t ) { + var axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + + axis.tickColor = 'steelblue'; + t.strictEqual( axis.tickColor, 'steelblue', 'returns expected value' ); + + axis.tickColor = 'red'; + t.strictEqual( axis.tickColor, 'red', 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `tickColor` property is set to a new value', function test( t ) { + var axis; + var count; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + count = 0; + + axis.on( 'change', onChange ); + + axis.tickColor = 'steelblue'; + t.strictEqual( count, 1, 'returns expected value' ); + + axis.tickColor = 'red'; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + axis.tickColor = 'red'; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.tick_count.js b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.tick_count.js new file mode 100644 index 000000000000..2cb51259732b --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.tick_count.js @@ -0,0 +1,175 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isUndefined = require( '@stdlib/assert/is-undefined' ); +var hasProp = require( '@stdlib/assert/has-property' ); +var Axis = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Axis, '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 Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + 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' ); + t.end(); +}); + +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 axis = new Axis({ // eslint-disable-line no-unused-vars + 'scale': 'xScale', + 'orient': 'bottom', + 'tickCount': value + }); + }; + } +}); + +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 axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + axis.tickCount = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `tickCount` property', function test( t ) { + var axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + t.strictEqual( isUndefined( axis.tickCount ), true, 'returns expected value' ); + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom', + 'tickCount': 10 + }); + t.strictEqual( axis.tickCount, 10, 'returns expected value' ); + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom', + 'tickCount': 'day' + }); + t.strictEqual( axis.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 axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + + axis.tickCount = 10; + t.strictEqual( axis.tickCount, 10, 'returns expected value' ); + + axis.tickCount = 'day'; + t.strictEqual( axis.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 axis; + var count; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + count = 0; + + axis.on( 'change', onChange ); + + axis.tickCount = 10; + t.strictEqual( count, 1, 'returns expected value' ); + + axis.tickCount = 20; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + axis.tickCount = 20; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.tick_dash.js b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.tick_dash.js new file mode 100644 index 000000000000..e1abc862e11c --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.tick_dash.js @@ -0,0 +1,176 @@ +/** +* @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 Axis = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Axis, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `tickDash` property', function test( t ) { + var v; + + v = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + t.strictEqual( hasOwnProp( v, 'tickDash' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'tickDash' ), true, 'returns expected value' ); + t.strictEqual( isArray( v.tickDash ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the constructor throws an error if provided an invalid `tickDash` 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 axis = new Axis({ // eslint-disable-line no-unused-vars + 'scale': 'xScale', + 'orient': 'bottom', + 'tickDash': value + }); + }; + } +}); + +tape( 'the constructor returns an instance having a `tickDash` 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 axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + axis.tickDash = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `tickDash` property', function test( t ) { + var axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + t.deepEqual( axis.tickDash, [], 'returns expected value' ); + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom', + 'tickDash': [ 2, 4 ] + }); + t.deepEqual( axis.tickDash, [ 2, 4 ], 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `tickDash` property which can be set to a valid value', function test( t ) { + var axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + + axis.tickDash = [ 2, 4 ]; + t.deepEqual( axis.tickDash, [ 2, 4 ], 'returns expected value' ); + + axis.tickDash = []; + t.deepEqual( axis.tickDash, [], 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `tickDash` property is set to a new value', function test( t ) { + var axis; + var count; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + count = 0; + + axis.on( 'change', onChange ); + + axis.tickDash = [ 2, 4 ]; + t.strictEqual( count, 1, 'returns expected value' ); + + axis.tickDash = [ 1, 2 ]; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + axis.tickDash = [ 1, 2 ]; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.tick_dash_offset.js b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.tick_dash_offset.js new file mode 100644 index 000000000000..e649bfe79af7 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.tick_dash_offset.js @@ -0,0 +1,181 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isUndefined = require( '@stdlib/assert/is-undefined' ); +var hasProp = require( '@stdlib/assert/has-property' ); +var isNumber = require( '@stdlib/assert/is-number' ); +var Axis = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Axis, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `tickDashOffset` property', function test( t ) { + var v; + + v = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + t.strictEqual( hasOwnProp( v, 'tickDashOffset' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'tickDashOffset' ), true, 'returns expected value' ); + t.strictEqual( isUndefined( v.tickDashOffset ), true, 'returns expected value' ); + + v = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom', + 'tickDashOffset': 1 + }); + t.strictEqual( isNumber( v.tickDashOffset ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor throws an error if provided an invalid `tickDashOffset` 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 axis = new Axis({ // eslint-disable-line no-unused-vars + 'scale': 'xScale', + 'orient': 'bottom', + 'tickDashOffset': value + }); + }; + } +}); + +tape( 'the constructor returns an instance having a `tickDashOffset` 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 axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + axis.tickDashOffset = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `tickDashOffset` property', function test( t ) { + var axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + t.strictEqual( isUndefined( axis.tickDashOffset ), true, 'returns expected value' ); + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom', + 'tickDashOffset': 1 + }); + t.strictEqual( axis.tickDashOffset, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `tickDashOffset` property which can be set to a valid value', function test( t ) { + var axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + + axis.tickDashOffset = 1; + t.strictEqual( axis.tickDashOffset, 1, 'returns expected value' ); + + axis.tickDashOffset = 2; + t.strictEqual( axis.tickDashOffset, 2, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `tickDashOffset` property is set to a new value', function test( t ) { + var axis; + var count; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + count = 0; + + axis.on( 'change', onChange ); + + axis.tickDashOffset = 1; + t.strictEqual( count, 1, 'returns expected value' ); + + axis.tickDashOffset = 2; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + axis.tickDashOffset = 2; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.tick_extra.js b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.tick_extra.js new file mode 100644 index 000000000000..dce007e7efb6 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.tick_extra.js @@ -0,0 +1,179 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isUndefined = require( '@stdlib/assert/is-undefined' ); +var hasProp = require( '@stdlib/assert/has-property' ); +var Axis = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Axis, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `tickExtra` property', function test( t ) { + var v; + + v = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + t.strictEqual( hasOwnProp( v, 'tickExtra' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'tickExtra' ), true, 'returns expected value' ); + t.strictEqual( isUndefined( v.tickExtra ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the constructor throws an error if provided an invalid `tickExtra` option', function test( t ) { + var values; + var i; + + values = [ + '5', + 5, + NaN, + null, + [], + {}, + 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 axis = new Axis({ // eslint-disable-line no-unused-vars + 'scale': 'xScale', + 'orient': 'bottom', + 'tickExtra': value + }); + }; + } +}); + +tape( 'the constructor returns an instance having a `tickExtra` property which throws an error if set to an invalid value', function test( t ) { + var values; + var i; + + values = [ + '5', + 5, + NaN, + null, + [], + {}, + 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 axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + axis.tickExtra = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `tickExtra` property', function test( t ) { + var axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + t.strictEqual( isUndefined( axis.tickExtra ), true, 'returns expected value' ); + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom', + 'tickExtra': true + }); + t.strictEqual( axis.tickExtra, true, 'returns expected value' ); + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom', + 'tickExtra': false + }); + t.strictEqual( axis.tickExtra, false, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `tickExtra` property which can be set to a valid value', function test( t ) { + var axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + + axis.tickExtra = true; + t.strictEqual( axis.tickExtra, true, 'returns expected value' ); + + axis.tickExtra = false; + t.strictEqual( axis.tickExtra, false, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `tickExtra` property is set to a new value', function test( t ) { + var axis; + var count; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + count = 0; + + axis.on( 'change', onChange ); + + axis.tickExtra = true; + t.strictEqual( count, 1, 'returns expected value' ); + + axis.tickExtra = false; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + axis.tickExtra = false; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.tick_min_step.js b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.tick_min_step.js new file mode 100644 index 000000000000..f3fa1dfea0d5 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.tick_min_step.js @@ -0,0 +1,181 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isUndefined = require( '@stdlib/assert/is-undefined' ); +var hasProp = require( '@stdlib/assert/has-property' ); +var isNumber = require( '@stdlib/assert/is-number' ); +var Axis = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Axis, '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 Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + 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 Axis({ + 'scale': 'xScale', + 'orient': 'bottom', + 'tickMinStep': 1 + }); + t.strictEqual( isNumber( v.tickMinStep ), true, 'returns expected value' ); + + t.end(); +}); + +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 axis = new Axis({ // eslint-disable-line no-unused-vars + 'scale': 'xScale', + 'orient': 'bottom', + 'tickMinStep': value + }); + }; + } +}); + +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 axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + axis.tickMinStep = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `tickMinStep` property', function test( t ) { + var axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + t.strictEqual( isUndefined( axis.tickMinStep ), true, 'returns expected value' ); + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom', + 'tickMinStep': 1 + }); + t.strictEqual( axis.tickMinStep, 1, '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 axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + + axis.tickMinStep = 1; + t.strictEqual( axis.tickMinStep, 1, 'returns expected value' ); + + axis.tickMinStep = 0.5; + t.strictEqual( axis.tickMinStep, 0.5, '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 axis; + var count; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + count = 0; + + axis.on( 'change', onChange ); + + axis.tickMinStep = 1; + t.strictEqual( count, 1, 'returns expected value' ); + + axis.tickMinStep = 2; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + axis.tickMinStep = 2; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.tick_offset.js b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.tick_offset.js new file mode 100644 index 000000000000..fe5a69ed96a8 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.tick_offset.js @@ -0,0 +1,181 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isUndefined = require( '@stdlib/assert/is-undefined' ); +var hasProp = require( '@stdlib/assert/has-property' ); +var isNumber = require( '@stdlib/assert/is-number' ); +var Axis = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Axis, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `tickOffset` property', function test( t ) { + var v; + + v = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + t.strictEqual( hasOwnProp( v, 'tickOffset' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'tickOffset' ), true, 'returns expected value' ); + t.strictEqual( isUndefined( v.tickOffset ), true, 'returns expected value' ); + + v = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom', + 'tickOffset': 1 + }); + t.strictEqual( isNumber( v.tickOffset ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor throws an error if provided an invalid `tickOffset` 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 axis = new Axis({ // eslint-disable-line no-unused-vars + 'scale': 'xScale', + 'orient': 'bottom', + 'tickOffset': value + }); + }; + } +}); + +tape( 'the constructor returns an instance having a `tickOffset` 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 axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + axis.tickOffset = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `tickOffset` property', function test( t ) { + var axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + t.strictEqual( isUndefined( axis.tickOffset ), true, 'returns expected value' ); + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom', + 'tickOffset': 5 + }); + t.strictEqual( axis.tickOffset, 5, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `tickOffset` property which can be set to a valid value', function test( t ) { + var axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + + axis.tickOffset = 5; + t.strictEqual( axis.tickOffset, 5, 'returns expected value' ); + + axis.tickOffset = 10; + t.strictEqual( axis.tickOffset, 10, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `tickOffset` property is set to a new value', function test( t ) { + var axis; + var count; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + count = 0; + + axis.on( 'change', onChange ); + + axis.tickOffset = 5; + t.strictEqual( count, 1, 'returns expected value' ); + + axis.tickOffset = 10; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + axis.tickOffset = 10; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.tick_opacity.js b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.tick_opacity.js new file mode 100644 index 000000000000..d5a6a528512b --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.tick_opacity.js @@ -0,0 +1,175 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var hasProp = require( '@stdlib/assert/has-property' ); +var isNumber = require( '@stdlib/assert/is-number' ); +var Axis = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Axis, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `tickOpacity` property', function test( t ) { + var v; + + v = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + t.strictEqual( hasOwnProp( v, 'tickOpacity' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'tickOpacity' ), true, 'returns expected value' ); + t.strictEqual( isNumber( v.tickOpacity ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the constructor throws an error if provided an invalid `tickOpacity` option', function test( t ) { + var values; + var i; + + values = [ + 'beep', + -1, + 2, + NaN, + 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 axis = new Axis({ // eslint-disable-line no-unused-vars + 'scale': 'xScale', + 'orient': 'bottom', + 'tickOpacity': value + }); + }; + } +}); + +tape( 'the constructor returns an instance having a `tickOpacity` property which throws an error if set to an invalid value', function test( t ) { + var values; + var i; + + values = [ + 'beep', + -1, + 2, + NaN, + 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 axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + axis.tickOpacity = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `tickOpacity` property', function test( t ) { + var axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + t.strictEqual( axis.tickOpacity, 1, 'returns expected value' ); + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom', + 'tickOpacity': 0.5 + }); + t.strictEqual( axis.tickOpacity, 0.5, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `tickOpacity` property which can be set to a valid value', function test( t ) { + var axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + + axis.tickOpacity = 0.5; + t.strictEqual( axis.tickOpacity, 0.5, 'returns expected value' ); + + axis.tickOpacity = 0; + t.strictEqual( axis.tickOpacity, 0, 'returns expected value' ); + + axis.tickOpacity = 1; + t.strictEqual( axis.tickOpacity, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `tickOpacity` property is set to a new value', function test( t ) { + var axis; + var count; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + count = 0; + + axis.on( 'change', onChange ); + + axis.tickOpacity = 0.5; + t.strictEqual( count, 1, 'returns expected value' ); + + axis.tickOpacity = 0; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + axis.tickOpacity = 0; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.tick_round.js b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.tick_round.js new file mode 100644 index 000000000000..4c5081613f1a --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.tick_round.js @@ -0,0 +1,179 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isUndefined = require( '@stdlib/assert/is-undefined' ); +var hasProp = require( '@stdlib/assert/has-property' ); +var Axis = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Axis, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `tickRound` property', function test( t ) { + var v; + + v = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + t.strictEqual( hasOwnProp( v, 'tickRound' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'tickRound' ), true, 'returns expected value' ); + t.strictEqual( isUndefined( v.tickRound ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the constructor throws an error if provided an invalid `tickRound` option', function test( t ) { + var values; + var i; + + values = [ + '5', + 5, + NaN, + null, + [], + {}, + 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 axis = new Axis({ // eslint-disable-line no-unused-vars + 'scale': 'xScale', + 'orient': 'bottom', + 'tickRound': value + }); + }; + } +}); + +tape( 'the constructor returns an instance having a `tickRound` property which throws an error if set to an invalid value', function test( t ) { + var values; + var i; + + values = [ + '5', + 5, + NaN, + null, + [], + {}, + 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 axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + axis.tickRound = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `tickRound` property', function test( t ) { + var axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + t.strictEqual( isUndefined( axis.tickRound ), true, 'returns expected value' ); + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom', + 'tickRound': true + }); + t.strictEqual( axis.tickRound, true, 'returns expected value' ); + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom', + 'tickRound': false + }); + t.strictEqual( axis.tickRound, false, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `tickRound` property which can be set to a valid value', function test( t ) { + var axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + + axis.tickRound = true; + t.strictEqual( axis.tickRound, true, 'returns expected value' ); + + axis.tickRound = false; + t.strictEqual( axis.tickRound, false, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `tickRound` property is set to a new value', function test( t ) { + var axis; + var count; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + count = 0; + + axis.on( 'change', onChange ); + + axis.tickRound = true; + t.strictEqual( count, 1, 'returns expected value' ); + + axis.tickRound = false; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + axis.tickRound = false; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.tick_size.js b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.tick_size.js new file mode 100644 index 000000000000..e9b70065bc32 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.tick_size.js @@ -0,0 +1,185 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isUndefined = require( '@stdlib/assert/is-undefined' ); +var hasProp = require( '@stdlib/assert/has-property' ); +var isNumber = require( '@stdlib/assert/is-number' ); +var Axis = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Axis, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `tickSize` property', function test( t ) { + var v; + + v = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + t.strictEqual( hasOwnProp( v, 'tickSize' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'tickSize' ), true, 'returns expected value' ); + t.strictEqual( isUndefined( v.tickSize ), true, 'returns expected value' ); + + v = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom', + 'tickSize': 5 + }); + t.strictEqual( isNumber( v.tickSize ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor throws an error if provided an invalid `tickSize` 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 axis = new Axis({ // eslint-disable-line no-unused-vars + 'scale': 'xScale', + 'orient': 'bottom', + 'tickSize': value + }); + }; + } +}); + +tape( 'the constructor returns an instance having a `tickSize` 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 axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + axis.tickSize = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `tickSize` property', function test( t ) { + var axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + t.strictEqual( isUndefined( axis.tickSize ), true, 'returns expected value' ); + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom', + 'tickSize': 5 + }); + t.strictEqual( axis.tickSize, 5, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `tickSize` property which can be set to a valid value', function test( t ) { + var axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + + axis.tickSize = 5; + t.strictEqual( axis.tickSize, 5, 'returns expected value' ); + + axis.tickSize = 0; + t.strictEqual( axis.tickSize, 0, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `tickSize` property is set to a new value', function test( t ) { + var axis; + var count; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + count = 0; + + axis.on( 'change', onChange ); + + axis.tickSize = 5; + t.strictEqual( count, 1, 'returns expected value' ); + + axis.tickSize = 10; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + axis.tickSize = 10; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.tick_width.js b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.tick_width.js new file mode 100644 index 000000000000..63b204e0487d --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.tick_width.js @@ -0,0 +1,185 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isUndefined = require( '@stdlib/assert/is-undefined' ); +var hasProp = require( '@stdlib/assert/has-property' ); +var isNumber = require( '@stdlib/assert/is-number' ); +var Axis = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Axis, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `tickWidth` property', function test( t ) { + var v; + + v = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + t.strictEqual( hasOwnProp( v, 'tickWidth' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'tickWidth' ), true, 'returns expected value' ); + t.strictEqual( isUndefined( v.tickWidth ), true, 'returns expected value' ); + + v = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom', + 'tickWidth': 2 + }); + t.strictEqual( isNumber( v.tickWidth ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor throws an error if provided an invalid `tickWidth` 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 axis = new Axis({ // eslint-disable-line no-unused-vars + 'scale': 'xScale', + 'orient': 'bottom', + 'tickWidth': value + }); + }; + } +}); + +tape( 'the constructor returns an instance having a `tickWidth` 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 axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + axis.tickWidth = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `tickWidth` property', function test( t ) { + var axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + t.strictEqual( isUndefined( axis.tickWidth ), true, 'returns expected value' ); + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom', + 'tickWidth': 2 + }); + t.strictEqual( axis.tickWidth, 2, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `tickWidth` property which can be set to a valid value', function test( t ) { + var axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + + axis.tickWidth = 2; + t.strictEqual( axis.tickWidth, 2, 'returns expected value' ); + + axis.tickWidth = 0; + t.strictEqual( axis.tickWidth, 0, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `tickWidth` property is set to a new value', function test( t ) { + var axis; + var count; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + count = 0; + + axis.on( 'change', onChange ); + + axis.tickWidth = 2; + t.strictEqual( count, 1, 'returns expected value' ); + + axis.tickWidth = 3; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + axis.tickWidth = 3; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.ticks.js b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.ticks.js new file mode 100644 index 000000000000..88ac9b4a224f --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.ticks.js @@ -0,0 +1,174 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var hasProp = require( '@stdlib/assert/has-property' ); +var isBoolean = require( '@stdlib/assert/is-boolean' ); +var Axis = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Axis, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `ticks` property', function test( t ) { + var v; + + v = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + t.strictEqual( hasOwnProp( v, 'ticks' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'ticks' ), true, 'returns expected value' ); + t.strictEqual( isBoolean( v.ticks ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the constructor throws an error if provided an invalid `ticks` 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 axis = new Axis({ // eslint-disable-line no-unused-vars + 'scale': 'xScale', + 'orient': 'bottom', + 'ticks': value + }); + }; + } +}); + +tape( 'the constructor returns an instance having a `ticks` property which throws an error if set to a non-boolean value', function test( t ) { + var values; + var i; + + values = [ + '5', + 5, + NaN, + null, + void 0, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + var axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + axis.ticks = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `ticks` property', function test( t ) { + var axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + t.strictEqual( axis.ticks, true, 'returns expected value' ); + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom', + 'ticks': false + }); + t.strictEqual( axis.ticks, false, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `ticks` property which can be set to a boolean', function test( t ) { + var axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + + axis.ticks = false; + t.strictEqual( axis.ticks, false, 'returns expected value' ); + + axis.ticks = true; + t.strictEqual( axis.ticks, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `ticks` property is set to a new value', function test( t ) { + var axis; + var count; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + count = 0; + + axis.on( 'change', onChange ); + + axis.ticks = false; + t.strictEqual( count, 1, 'returns expected value' ); + + axis.ticks = true; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + axis.ticks = true; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.title.js b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.title.js new file mode 100644 index 000000000000..367763bdc256 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.title.js @@ -0,0 +1,183 @@ +/** +* @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 Axis = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Axis, '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 Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + 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 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 axis = new Axis({ // eslint-disable-line no-unused-vars + 'scale': 'xScale', + 'orient': 'bottom', + 'title': value + }); + }; + } +}); + +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 axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + axis.title = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `title` property', function test( t ) { + var axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + t.deepEqual( axis.title, [ '' ], 'returns expected value' ); + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom', + 'title': 'Axis Title' + }); + t.deepEqual( axis.title, [ 'Axis Title' ], 'returns expected value' ); + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom', + 'title': [ 'Line 1', 'Line 2' ] + }); + t.deepEqual( axis.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 axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + + axis.title = 'Axis Title'; + t.deepEqual( axis.title, [ 'Axis Title' ], 'returns expected value' ); + + axis.title = [ 'Line 1', 'Line 2' ]; + t.deepEqual( axis.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 axis; + var count; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + count = 0; + + axis.on( 'change', onChange ); + + axis.title = 'Axis Title'; + t.strictEqual( count, 1, 'returns expected value' ); + + axis.title = [ 'Line 1', 'Line 2' ]; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + axis.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/axis/ctor/test/test.title_align.js b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.title_align.js new file mode 100644 index 000000000000..957209885899 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.title_align.js @@ -0,0 +1,179 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isUndefined = require( '@stdlib/assert/is-undefined' ); +var hasProp = require( '@stdlib/assert/has-property' ); +var Axis = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Axis, '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 Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + 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' ); + t.end(); +}); + +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 axis = new Axis({ // eslint-disable-line no-unused-vars + 'scale': 'xScale', + 'orient': 'bottom', + 'titleAlign': value + }); + }; + } +}); + +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 axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + axis.titleAlign = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `titleAlign` property', function test( t ) { + var axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + t.strictEqual( isUndefined( axis.titleAlign ), true, 'returns expected value' ); + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom', + 'titleAlign': 'center' + }); + t.strictEqual( axis.titleAlign, 'center', '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 axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + + axis.titleAlign = 'left'; + t.strictEqual( axis.titleAlign, 'left', 'returns expected value' ); + + axis.titleAlign = 'center'; + t.strictEqual( axis.titleAlign, 'center', 'returns expected value' ); + + axis.titleAlign = 'right'; + t.strictEqual( axis.titleAlign, 'right', '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 axis; + var count; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + count = 0; + + axis.on( 'change', onChange ); + + axis.titleAlign = 'left'; + t.strictEqual( count, 1, 'returns expected value' ); + + axis.titleAlign = 'center'; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + axis.titleAlign = 'center'; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.title_anchor.js b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.title_anchor.js new file mode 100644 index 000000000000..8dc57495ba84 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.title_anchor.js @@ -0,0 +1,178 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var hasProp = require( '@stdlib/assert/has-property' ); +var Axis = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Axis, '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 Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + t.strictEqual( hasOwnProp( v, 'titleAnchor' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'titleAnchor' ), true, 'returns expected value' ); + t.strictEqual( v.titleAnchor, null, 'returns expected value' ); + t.end(); +}); + +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 axis = new Axis({ // eslint-disable-line no-unused-vars + 'scale': 'xScale', + 'orient': 'bottom', + 'titleAnchor': value + }); + }; + } +}); + +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 axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + axis.titleAnchor = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `titleAnchor` property', function test( t ) { + var axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + t.strictEqual( axis.titleAnchor, null, 'returns expected value' ); + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom', + 'titleAnchor': 'start' + }); + t.strictEqual( axis.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 axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + + axis.titleAnchor = 'start'; + t.strictEqual( axis.titleAnchor, 'start', 'returns expected value' ); + + axis.titleAnchor = 'end'; + t.strictEqual( axis.titleAnchor, 'end', 'returns expected value' ); + + axis.titleAnchor = null; + t.strictEqual( axis.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 axis; + var count; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + count = 0; + + axis.on( 'change', onChange ); + + axis.titleAnchor = 'start'; + t.strictEqual( count, 1, 'returns expected value' ); + + axis.titleAnchor = 'end'; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + axis.titleAnchor = 'end'; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.title_angle.js b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.title_angle.js new file mode 100644 index 000000000000..be43114bf07d --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.title_angle.js @@ -0,0 +1,181 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isUndefined = require( '@stdlib/assert/is-undefined' ); +var hasProp = require( '@stdlib/assert/has-property' ); +var isNumber = require( '@stdlib/assert/is-number' ); +var Axis = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Axis, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `titleAngle` property', function test( t ) { + var v; + + v = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + t.strictEqual( hasOwnProp( v, 'titleAngle' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'titleAngle' ), true, 'returns expected value' ); + t.strictEqual( isUndefined( v.titleAngle ), true, 'returns expected value' ); + + v = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom', + 'titleAngle': 45 + }); + t.strictEqual( isNumber( v.titleAngle ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor throws an error if provided an invalid `titleAngle` 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 axis = new Axis({ // eslint-disable-line no-unused-vars + 'scale': 'xScale', + 'orient': 'bottom', + 'titleAngle': value + }); + }; + } +}); + +tape( 'the constructor returns an instance having a `titleAngle` 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 axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + axis.titleAngle = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `titleAngle` property', function test( t ) { + var axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + t.strictEqual( isUndefined( axis.titleAngle ), true, 'returns expected value' ); + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom', + 'titleAngle': 45 + }); + t.strictEqual( axis.titleAngle, 45, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `titleAngle` property which can be set to a valid value', function test( t ) { + var axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + + axis.titleAngle = 45; + t.strictEqual( axis.titleAngle, 45, 'returns expected value' ); + + axis.titleAngle = 90; + t.strictEqual( axis.titleAngle, 90, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `titleAngle` property is set to a new value', function test( t ) { + var axis; + var count; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + count = 0; + + axis.on( 'change', onChange ); + + axis.titleAngle = 45; + t.strictEqual( count, 1, 'returns expected value' ); + + axis.titleAngle = 90; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + axis.titleAngle = 90; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.title_baseline.js b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.title_baseline.js new file mode 100644 index 000000000000..8b3f090c2fd5 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.title_baseline.js @@ -0,0 +1,181 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isUndefined = require( '@stdlib/assert/is-undefined' ); +var hasProp = require( '@stdlib/assert/has-property' ); +var Axis = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Axis, '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 Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + t.strictEqual( hasOwnProp( v, 'titleBaseline' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'titleBaseline' ), true, 'returns expected value' ); + t.strictEqual( isUndefined( v.titleBaseline ), true, 'returns expected value' ); + t.end(); +}); + +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 axis = new Axis({ // eslint-disable-line no-unused-vars + 'scale': 'xScale', + 'orient': 'bottom', + 'titleBaseline': value + }); + }; + } +}); + +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 axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + axis.titleBaseline = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `titleBaseline` property', function test( t ) { + var axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + t.strictEqual( isUndefined( axis.titleBaseline ), true, 'returns expected value' ); + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom', + 'titleBaseline': 'top' + }); + t.strictEqual( axis.titleBaseline, 'top', 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `titleBaseline` property which can be set to a valid value', function test( t ) { + var axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + + axis.titleBaseline = 'top'; + t.strictEqual( axis.titleBaseline, 'top', 'returns expected value' ); + + axis.titleBaseline = 'middle'; + t.strictEqual( axis.titleBaseline, 'middle', 'returns expected value' ); + + axis.titleBaseline = 'bottom'; + t.strictEqual( axis.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 axis; + var count; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + count = 0; + + axis.on( 'change', onChange ); + + axis.titleBaseline = 'top'; + t.strictEqual( count, 1, 'returns expected value' ); + + axis.titleBaseline = 'middle'; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + axis.titleBaseline = 'middle'; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.title_color.js b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.title_color.js new file mode 100644 index 000000000000..02e7afe3e661 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.title_color.js @@ -0,0 +1,183 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isUndefined = require( '@stdlib/assert/is-undefined' ); +var hasProp = require( '@stdlib/assert/has-property' ); +var isString = require( '@stdlib/assert/is-string' ); +var Axis = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Axis, '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 Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + 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 Axis({ + 'scale': 'xScale', + 'orient': 'bottom', + 'titleColor': 'steelblue' + }); + t.strictEqual( isString( v.titleColor ), true, 'returns expected value' ); + + t.end(); +}); + +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 axis = new Axis({ // eslint-disable-line no-unused-vars + 'scale': 'xScale', + 'orient': 'bottom', + 'titleColor': value + }); + }; + } +}); + +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 axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + axis.titleColor = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `titleColor` property', function test( t ) { + var axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + t.strictEqual( isUndefined( axis.titleColor ), true, 'returns expected value' ); + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom', + 'titleColor': 'steelblue' + }); + t.strictEqual( axis.titleColor, 'steelblue', 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `titleColor` property which can be set to a valid value', function test( t ) { + var axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + + axis.titleColor = 'steelblue'; + t.strictEqual( axis.titleColor, 'steelblue', 'returns expected value' ); + + axis.titleColor = 'red'; + t.strictEqual( axis.titleColor, 'red', '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 axis; + var count; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + count = 0; + + axis.on( 'change', onChange ); + + axis.titleColor = 'steelblue'; + t.strictEqual( count, 1, 'returns expected value' ); + + axis.titleColor = 'red'; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + axis.titleColor = 'red'; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.title_font.js b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.title_font.js new file mode 100644 index 000000000000..6456cbb42c80 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.title_font.js @@ -0,0 +1,183 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isUndefined = require( '@stdlib/assert/is-undefined' ); +var hasProp = require( '@stdlib/assert/has-property' ); +var isString = require( '@stdlib/assert/is-string' ); +var Axis = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Axis, '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 Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + 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 Axis({ + 'scale': 'xScale', + 'orient': 'bottom', + 'titleFont': 'Arial' + }); + t.strictEqual( isString( v.titleFont ), true, 'returns expected value' ); + + t.end(); +}); + +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 axis = new Axis({ // eslint-disable-line no-unused-vars + 'scale': 'xScale', + 'orient': 'bottom', + 'titleFont': value + }); + }; + } +}); + +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 axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + axis.titleFont = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `titleFont` property', function test( t ) { + var axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + t.strictEqual( isUndefined( axis.titleFont ), true, 'returns expected value' ); + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom', + 'titleFont': 'Arial' + }); + t.strictEqual( axis.titleFont, 'Arial', 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `titleFont` property which can be set to a valid value', function test( t ) { + var axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + + axis.titleFont = 'Arial'; + t.strictEqual( axis.titleFont, 'Arial', 'returns expected value' ); + + axis.titleFont = 'Helvetica'; + t.strictEqual( axis.titleFont, 'Helvetica', '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 axis; + var count; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + count = 0; + + axis.on( 'change', onChange ); + + axis.titleFont = 'Arial'; + t.strictEqual( count, 1, 'returns expected value' ); + + axis.titleFont = 'Helvetica'; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + axis.titleFont = 'Helvetica'; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.title_font_size.js b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.title_font_size.js new file mode 100644 index 000000000000..2f677878fd2f --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.title_font_size.js @@ -0,0 +1,181 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isUndefined = require( '@stdlib/assert/is-undefined' ); +var hasProp = require( '@stdlib/assert/has-property' ); +var isNumber = require( '@stdlib/assert/is-number' ); +var Axis = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Axis, '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 Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + 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 Axis({ + 'scale': 'xScale', + 'orient': 'bottom', + 'titleFontSize': 14 + }); + t.strictEqual( isNumber( v.titleFontSize ), true, 'returns expected value' ); + + t.end(); +}); + +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 axis = new Axis({ // eslint-disable-line no-unused-vars + 'scale': 'xScale', + 'orient': 'bottom', + 'titleFontSize': value + }); + }; + } +}); + +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', + 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 axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + axis.titleFontSize = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `titleFontSize` property', function test( t ) { + var axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + t.strictEqual( isUndefined( axis.titleFontSize ), true, 'returns expected value' ); + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom', + 'titleFontSize': 14 + }); + t.strictEqual( axis.titleFontSize, 14, '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 axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + + axis.titleFontSize = 14; + t.strictEqual( axis.titleFontSize, 14, 'returns expected value' ); + + axis.titleFontSize = 18; + t.strictEqual( axis.titleFontSize, 18, '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 axis; + var count; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + count = 0; + + axis.on( 'change', onChange ); + + axis.titleFontSize = 14; + t.strictEqual( count, 1, 'returns expected value' ); + + axis.titleFontSize = 18; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + axis.titleFontSize = 18; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.title_font_style.js b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.title_font_style.js new file mode 100644 index 000000000000..3116174048f5 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.title_font_style.js @@ -0,0 +1,183 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isUndefined = require( '@stdlib/assert/is-undefined' ); +var hasProp = require( '@stdlib/assert/has-property' ); +var isString = require( '@stdlib/assert/is-string' ); +var Axis = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Axis, '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 Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + 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 Axis({ + 'scale': 'xScale', + 'orient': 'bottom', + 'titleFontStyle': 'italic' + }); + t.strictEqual( isString( v.titleFontStyle ), true, 'returns expected value' ); + + t.end(); +}); + +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 axis = new Axis({ // eslint-disable-line no-unused-vars + 'scale': 'xScale', + 'orient': 'bottom', + 'titleFontStyle': value + }); + }; + } +}); + +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 axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + axis.titleFontStyle = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `titleFontStyle` property', function test( t ) { + var axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + t.strictEqual( isUndefined( axis.titleFontStyle ), true, 'returns expected value' ); + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom', + 'titleFontStyle': 'italic' + }); + t.strictEqual( axis.titleFontStyle, 'italic', 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `titleFontStyle` property which can be set to a valid value', function test( t ) { + var axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + + axis.titleFontStyle = 'italic'; + t.strictEqual( axis.titleFontStyle, 'italic', 'returns expected value' ); + + axis.titleFontStyle = 'normal'; + t.strictEqual( axis.titleFontStyle, 'normal', '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 axis; + var count; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + count = 0; + + axis.on( 'change', onChange ); + + axis.titleFontStyle = 'italic'; + t.strictEqual( count, 1, 'returns expected value' ); + + axis.titleFontStyle = 'normal'; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + axis.titleFontStyle = 'normal'; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.title_font_weight.js b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.title_font_weight.js new file mode 100644 index 000000000000..3cbe8448b6e7 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.title_font_weight.js @@ -0,0 +1,180 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isUndefined = require( '@stdlib/assert/is-undefined' ); +var hasProp = require( '@stdlib/assert/has-property' ); +var Axis = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Axis, '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 Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + 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' ); + t.end(); +}); + +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 axis = new Axis({ // eslint-disable-line no-unused-vars + 'scale': 'xScale', + 'orient': 'bottom', + 'titleFontWeight': value + }); + }; + } +}); + +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 axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + axis.titleFontWeight = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `titleFontWeight` property', function test( t ) { + var axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + t.strictEqual( isUndefined( axis.titleFontWeight ), true, 'returns expected value' ); + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom', + 'titleFontWeight': 'bold' + }); + t.strictEqual( axis.titleFontWeight, 'bold', 'returns expected value' ); + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom', + 'titleFontWeight': 700 + }); + t.strictEqual( axis.titleFontWeight, 700, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `titleFontWeight` property which can be set to a valid value', function test( t ) { + var axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + + axis.titleFontWeight = 'bold'; + t.strictEqual( axis.titleFontWeight, 'bold', 'returns expected value' ); + + axis.titleFontWeight = 700; + t.strictEqual( axis.titleFontWeight, 700, 'returns expected value' ); + + axis.titleFontWeight = 'normal'; + t.strictEqual( axis.titleFontWeight, 'normal', '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', function test( t ) { + var axis; + var count; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + count = 0; + + axis.on( 'change', onChange ); + + axis.titleFontWeight = 'bold'; + t.strictEqual( count, 1, 'returns expected value' ); + + axis.titleFontWeight = 700; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + axis.titleFontWeight = 700; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.title_limit.js b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.title_limit.js new file mode 100644 index 000000000000..2022135c1e4e --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.title_limit.js @@ -0,0 +1,176 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isUndefined = require( '@stdlib/assert/is-undefined' ); +var hasProp = require( '@stdlib/assert/has-property' ); +var Axis = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Axis, '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 Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + 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' ); + t.end(); +}); + +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 axis = new Axis({ // eslint-disable-line no-unused-vars + 'scale': 'xScale', + 'orient': 'bottom', + 'titleLimit': value + }); + }; + } +}); + +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 axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + axis.titleLimit = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `titleLimit` property', function test( t ) { + var axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + t.strictEqual( isUndefined( axis.titleLimit ), true, 'returns expected value' ); + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom', + 'titleLimit': 200 + }); + t.strictEqual( axis.titleLimit, 200, '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 axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + + axis.titleLimit = 200; + t.strictEqual( axis.titleLimit, 200, 'returns expected value' ); + + axis.titleLimit = 300; + t.strictEqual( axis.titleLimit, 300, '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 axis; + var count; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + count = 0; + + axis.on( 'change', onChange ); + + axis.titleLimit = 200; + t.strictEqual( count, 1, 'returns expected value' ); + + axis.titleLimit = 300; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + axis.titleLimit = 300; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.title_line_height.js b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.title_line_height.js new file mode 100644 index 000000000000..fda0ece34f2e --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.title_line_height.js @@ -0,0 +1,181 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isUndefined = require( '@stdlib/assert/is-undefined' ); +var hasProp = require( '@stdlib/assert/has-property' ); +var isNumber = require( '@stdlib/assert/is-number' ); +var Axis = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Axis, '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 Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + 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 Axis({ + 'scale': 'xScale', + 'orient': 'bottom', + 'titleLineHeight': 20 + }); + t.strictEqual( isNumber( v.titleLineHeight ), true, 'returns expected value' ); + + t.end(); +}); + +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 axis = new Axis({ // eslint-disable-line no-unused-vars + 'scale': 'xScale', + 'orient': 'bottom', + 'titleLineHeight': value + }); + }; + } +}); + +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', + 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 axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + axis.titleLineHeight = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `titleLineHeight` property', function test( t ) { + var axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + t.strictEqual( isUndefined( axis.titleLineHeight ), true, 'returns expected value' ); + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom', + 'titleLineHeight': 20 + }); + t.strictEqual( axis.titleLineHeight, 20, '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 axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + + axis.titleLineHeight = 20; + t.strictEqual( axis.titleLineHeight, 20, 'returns expected value' ); + + axis.titleLineHeight = 24; + t.strictEqual( axis.titleLineHeight, 24, '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 axis; + var count; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + count = 0; + + axis.on( 'change', onChange ); + + axis.titleLineHeight = 20; + t.strictEqual( count, 1, 'returns expected value' ); + + axis.titleLineHeight = 24; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + axis.titleLineHeight = 24; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.title_opacity.js b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.title_opacity.js new file mode 100644 index 000000000000..93bb96b7c869 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.title_opacity.js @@ -0,0 +1,175 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var hasProp = require( '@stdlib/assert/has-property' ); +var isNumber = require( '@stdlib/assert/is-number' ); +var Axis = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Axis, '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 Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + t.strictEqual( hasOwnProp( v, 'titleOpacity' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'titleOpacity' ), true, 'returns expected value' ); + t.strictEqual( isNumber( v.titleOpacity ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the constructor throws an error if provided an invalid `titleOpacity` option', function test( t ) { + var values; + var i; + + values = [ + 'beep', + -0.1, + 1.1, + NaN, + 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 axis = new Axis({ // eslint-disable-line no-unused-vars + 'scale': 'xScale', + 'orient': 'bottom', + 'titleOpacity': value + }); + }; + } +}); + +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', + -0.1, + 1.1, + NaN, + 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 axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + axis.titleOpacity = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `titleOpacity` property', function test( t ) { + var axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + t.strictEqual( axis.titleOpacity, 1, 'returns expected value' ); + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom', + 'titleOpacity': 0.5 + }); + t.strictEqual( axis.titleOpacity, 0.5, '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 axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + + axis.titleOpacity = 0.5; + t.strictEqual( axis.titleOpacity, 0.5, 'returns expected value' ); + + axis.titleOpacity = 0; + t.strictEqual( axis.titleOpacity, 0, 'returns expected value' ); + + axis.titleOpacity = 1; + t.strictEqual( axis.titleOpacity, 1, '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 axis; + var count; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + count = 0; + + axis.on( 'change', onChange ); + + axis.titleOpacity = 0.5; + t.strictEqual( count, 1, 'returns expected value' ); + + axis.titleOpacity = 0.3; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + axis.titleOpacity = 0.3; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.title_padding.js b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.title_padding.js new file mode 100644 index 000000000000..6b8dcede67e7 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.title_padding.js @@ -0,0 +1,181 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isUndefined = require( '@stdlib/assert/is-undefined' ); +var hasProp = require( '@stdlib/assert/has-property' ); +var isNumber = require( '@stdlib/assert/is-number' ); +var Axis = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Axis, '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 Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + 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 Axis({ + 'scale': 'xScale', + 'orient': 'bottom', + 'titlePadding': 10 + }); + t.strictEqual( isNumber( v.titlePadding ), true, 'returns expected value' ); + + t.end(); +}); + +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 axis = new Axis({ // eslint-disable-line no-unused-vars + 'scale': 'xScale', + 'orient': 'bottom', + 'titlePadding': value + }); + }; + } +}); + +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 axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + axis.titlePadding = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `titlePadding` property', function test( t ) { + var axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + t.strictEqual( isUndefined( axis.titlePadding ), true, 'returns expected value' ); + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom', + 'titlePadding': 10 + }); + t.strictEqual( axis.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 axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + + axis.titlePadding = 10; + t.strictEqual( axis.titlePadding, 10, 'returns expected value' ); + + axis.titlePadding = 20; + t.strictEqual( axis.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 axis; + var count; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + count = 0; + + axis.on( 'change', onChange ); + + axis.titlePadding = 10; + t.strictEqual( count, 1, 'returns expected value' ); + + axis.titlePadding = 20; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + axis.titlePadding = 20; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.title_x.js b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.title_x.js new file mode 100644 index 000000000000..eff472e89e12 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.title_x.js @@ -0,0 +1,181 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isUndefined = require( '@stdlib/assert/is-undefined' ); +var hasProp = require( '@stdlib/assert/has-property' ); +var isNumber = require( '@stdlib/assert/is-number' ); +var Axis = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Axis, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `titleX` property', function test( t ) { + var v; + + v = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + t.strictEqual( hasOwnProp( v, 'titleX' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'titleX' ), true, 'returns expected value' ); + t.strictEqual( isUndefined( v.titleX ), true, 'returns expected value' ); + + v = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom', + 'titleX': 100 + }); + t.strictEqual( isNumber( v.titleX ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor throws an error if provided an invalid `titleX` 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 axis = new Axis({ // eslint-disable-line no-unused-vars + 'scale': 'xScale', + 'orient': 'bottom', + 'titleX': value + }); + }; + } +}); + +tape( 'the constructor returns an instance having a `titleX` 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 axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + axis.titleX = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `titleX` property', function test( t ) { + var axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + t.strictEqual( isUndefined( axis.titleX ), true, 'returns expected value' ); + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom', + 'titleX': 100 + }); + t.strictEqual( axis.titleX, 100, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `titleX` property which can be set to a valid value', function test( t ) { + var axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + + axis.titleX = 100; + t.strictEqual( axis.titleX, 100, 'returns expected value' ); + + axis.titleX = 200; + t.strictEqual( axis.titleX, 200, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `titleX` property is set to a new value', function test( t ) { + var axis; + var count; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + count = 0; + + axis.on( 'change', onChange ); + + axis.titleX = 100; + t.strictEqual( count, 1, 'returns expected value' ); + + axis.titleX = 200; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + axis.titleX = 200; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.title_y.js b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.title_y.js new file mode 100644 index 000000000000..4617d685dfcd --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.title_y.js @@ -0,0 +1,181 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isUndefined = require( '@stdlib/assert/is-undefined' ); +var hasProp = require( '@stdlib/assert/has-property' ); +var isNumber = require( '@stdlib/assert/is-number' ); +var Axis = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Axis, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `titleY` property', function test( t ) { + var v; + + v = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + t.strictEqual( hasOwnProp( v, 'titleY' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'titleY' ), true, 'returns expected value' ); + t.strictEqual( isUndefined( v.titleY ), true, 'returns expected value' ); + + v = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom', + 'titleY': 50 + }); + t.strictEqual( isNumber( v.titleY ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor throws an error if provided an invalid `titleY` 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 axis = new Axis({ // eslint-disable-line no-unused-vars + 'scale': 'xScale', + 'orient': 'bottom', + 'titleY': value + }); + }; + } +}); + +tape( 'the constructor returns an instance having a `titleY` 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 axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + axis.titleY = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `titleY` property', function test( t ) { + var axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + t.strictEqual( isUndefined( axis.titleY ), true, 'returns expected value' ); + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom', + 'titleY': 50 + }); + t.strictEqual( axis.titleY, 50, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `titleY` property which can be set to a valid value', function test( t ) { + var axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + + axis.titleY = 50; + t.strictEqual( axis.titleY, 50, 'returns expected value' ); + + axis.titleY = 100; + t.strictEqual( axis.titleY, 100, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `titleY` property is set to a new value', function test( t ) { + var axis; + var count; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + count = 0; + + axis.on( 'change', onChange ); + + axis.titleY = 50; + t.strictEqual( count, 1, 'returns expected value' ); + + axis.titleY = 100; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + axis.titleY = 100; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.translate.js b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.translate.js new file mode 100644 index 000000000000..5542c7573f28 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.translate.js @@ -0,0 +1,174 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var hasProp = require( '@stdlib/assert/has-property' ); +var isNumber = require( '@stdlib/assert/is-number' ); +var Axis = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Axis, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the constructor returns an instance which has a `translate` property', function test( t ) { + var v; + + v = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + t.strictEqual( hasOwnProp( v, 'translate' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'translate' ), true, 'returns expected value' ); + t.strictEqual( isNumber( v.translate ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the constructor throws an error if provided an invalid `translate` 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 axis = new Axis({ // eslint-disable-line no-unused-vars + 'scale': 'xScale', + 'orient': 'bottom', + 'translate': value + }); + }; + } +}); + +tape( 'the constructor returns an instance having a `translate` 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 axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + axis.translate = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `translate` property', function test( t ) { + var axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + t.strictEqual( axis.translate, 0.5, 'returns expected value' ); + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom', + 'translate': 1 + }); + t.strictEqual( axis.translate, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `translate` property which can be set to a valid value', function test( t ) { + var axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + + axis.translate = 1; + t.strictEqual( axis.translate, 1, 'returns expected value' ); + + axis.translate = 0; + t.strictEqual( axis.translate, 0, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `translate` property is set to a new value', function test( t ) { + var axis; + var count; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + count = 0; + + axis.on( 'change', onChange ); + + axis.translate = 1; + t.strictEqual( count, 1, 'returns expected value' ); + + axis.translate = 0; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + axis.translate = 0; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.zindex.js b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.zindex.js new file mode 100644 index 000000000000..6e608ae39c52 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/axis/ctor/test/test.zindex.js @@ -0,0 +1,174 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var hasProp = require( '@stdlib/assert/has-property' ); +var isNumber = require( '@stdlib/assert/is-number' ); +var Axis = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Axis, '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 Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + t.strictEqual( hasOwnProp( v, 'zindex' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'zindex' ), true, 'returns expected value' ); + t.strictEqual( isNumber( v.zindex ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the constructor throws an error if provided an invalid `zindex` option', function test( t ) { + var values; + var i; + + values = [ + 'beep', + 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 axis = new Axis({ // eslint-disable-line no-unused-vars + 'scale': 'xScale', + 'orient': 'bottom', + 'zindex': value + }); + }; + } +}); + +tape( 'the constructor returns an instance having a `zindex` property which throws an error if set to an invalid value', function test( t ) { + var values; + var i; + + values = [ + 'beep', + 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 axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + axis.zindex = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `zindex` property', function test( t ) { + var axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + t.strictEqual( axis.zindex, 0, 'returns expected value' ); + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom', + 'zindex': 5 + }); + t.strictEqual( axis.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 axis; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + + axis.zindex = 5; + t.strictEqual( axis.zindex, 5, 'returns expected value' ); + + axis.zindex = 10; + t.strictEqual( axis.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 axis; + var count; + + axis = new Axis({ + 'scale': 'xScale', + 'orient': 'bottom' + }); + count = 0; + + axis.on( 'change', onChange ); + + axis.zindex = 5; + t.strictEqual( count, 1, 'returns expected value' ); + + axis.zindex = 10; + t.strictEqual( count, 2, 'returns expected value' ); + + // Setting to the same value should not emit an event: + axis.zindex = 10; + t.strictEqual( count, 2, 'returns expected value' ); + + t.end(); + + function onChange() { + count += 1; + } +});