From 44aa4c6ac245a77102b55788996f9f1798baa12b Mon Sep 17 00:00:00 2001 From: gururaj1512 Date: Thu, 1 Jan 2026 23:44:14 +0530 Subject: [PATCH 1/4] feat: add tests for Autosize constructor and properties --- .../vega/autosize/ctor/test/test.contains.js | 165 ++++++++++++++++ .../plot/vega/autosize/ctor/test/test.js | 181 +++++++++++++++++ .../autosize/ctor/test/test.properties.js | 71 +++++++ .../vega/autosize/ctor/test/test.resize.js | 153 +++++++++++++++ .../plot/vega/autosize/ctor/test/test.type.js | 184 ++++++++++++++++++ 5 files changed, 754 insertions(+) create mode 100644 lib/node_modules/@stdlib/plot/vega/autosize/ctor/test/test.contains.js create mode 100644 lib/node_modules/@stdlib/plot/vega/autosize/ctor/test/test.js create mode 100644 lib/node_modules/@stdlib/plot/vega/autosize/ctor/test/test.properties.js create mode 100644 lib/node_modules/@stdlib/plot/vega/autosize/ctor/test/test.resize.js create mode 100644 lib/node_modules/@stdlib/plot/vega/autosize/ctor/test/test.type.js diff --git a/lib/node_modules/@stdlib/plot/vega/autosize/ctor/test/test.contains.js b/lib/node_modules/@stdlib/plot/vega/autosize/ctor/test/test.contains.js new file mode 100644 index 000000000000..fb3d5086f8f1 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/autosize/ctor/test/test.contains.js @@ -0,0 +1,165 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 Autosize = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Autosize, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'attached to the prototype of the main export is a `contains` property for determining how a size calculation should be performed', function test( t ) { + t.strictEqual( hasOwnProp( Autosize.prototype, 'contains' ), true, 'has property' ); + t.end(); +}); + +tape( 'the constructor throws an error if provided an invalid `contains` option', function test( t ) { + var values; + var i; + + values = [ + 'beep', + 'boop', + 'invalid', + 'CONTENT', + 'PADDING', + 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 autosize = new Autosize({ // eslint-disable-line no-unused-vars + 'contains': value + }); + }; + } +}); + +tape( 'the constructor returns an instance having a `contains` property which throws an error if set to an invalid value', function test( t ) { + var values; + var i; + + values = [ + 'beep', + 'boop', + 'invalid', + 'CONTENT', + 'PADDING', + 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 autosize = new Autosize(); + autosize.contains = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `contains` property which returns the method for determining how a size calculation should be performed', function test( t ) { + var autosize; + + autosize = new Autosize(); + t.strictEqual( autosize.contains, 'content', 'returns expected value' ); + + autosize = new Autosize({ + 'contains': 'padding' + }); + t.strictEqual( autosize.contains, 'padding', 'returns expected value' ); + + autosize = new Autosize({ + 'contains': 'content' + }); + t.strictEqual( autosize.contains, 'content', 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `contains` property which can be set to a valid method', function test( t ) { + var autosize; + + autosize = new Autosize(); + + autosize.contains = 'padding'; + t.strictEqual( autosize.contains, 'padding', 'returns expected value' ); + + autosize.contains = 'content'; + t.strictEqual( autosize.contains, 'content', 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `contains` property is set to a new value', function test( t ) { + var autosize; + var count; + + autosize = new Autosize(); + count = 0; + + autosize.on( 'change', onChange ); + + autosize.contains = 'padding'; + t.strictEqual( count, 1, 'emits event' ); + + autosize.contains = 'content'; + t.strictEqual( count, 2, 'emits event' ); + + // Setting to the same value should not emit an event: + autosize.contains = 'content'; + t.strictEqual( count, 2, 'does not emit event when value is unchanged' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/autosize/ctor/test/test.js b/lib/node_modules/@stdlib/plot/vega/autosize/ctor/test/test.js new file mode 100644 index 000000000000..de180f6e3298 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/autosize/ctor/test/test.js @@ -0,0 +1,181 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 Autosize = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Autosize, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function is a constructor', function test( t ) { + var autosize = new Autosize(); + t.strictEqual( instanceOf( autosize, Autosize ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the constructor does not require the `new` keyword', function test( t ) { + var autosize; + var ctor; + + ctor = Autosize; + autosize = ctor(); + t.strictEqual( instanceOf( autosize, Autosize ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the constructor does not require the `new` keyword (options)', function test( t ) { + var autosize; + var ctor; + + ctor = Autosize; + autosize = ctor({ + 'type': 'fit' + }); + t.strictEqual( instanceOf( autosize, Autosize ), true, 'returns expected value' ); + t.strictEqual( autosize.type, 'fit', '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 autosize = new Autosize( value ); // eslint-disable-line no-unused-vars + }; + } +}); + +tape( 'the constructor has a read-only `name` property', function test( t ) { + t.strictEqual( Autosize.name, 'Autosize', '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 autosize; + var json; + + autosize = new Autosize(); + json = autosize.toJSON(); + + expected = { + 'contains': 'content', + 'resize': false, + 'type': 'pad' + }; + 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 (custom options)', function test( t ) { + var expected; + var autosize; + var json; + + autosize = new Autosize({ + 'type': 'fit', + 'contains': 'padding', + 'resize': true + }); + json = autosize.toJSON(); + + expected = { + 'contains': 'padding', + 'resize': true, + 'type': 'fit' + }; + 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 autosize; + + autosize = new Autosize({ + 'type': 'none', + 'contains': 'content', + 'resize': false + }); + + expected = { + 'contains': 'content', + 'resize': false, + 'type': 'none' + }; + t.strictEqual( JSON.stringify( autosize ), JSON.stringify( expected ), 'serializes as JSON when called by JSON.stringify()' ); + t.end(); +}); + +tape( 'the constructor returns an instance which inherits from EventEmitter', function test( t ) { + var autosize; + + autosize = new Autosize(); + + t.strictEqual( typeof autosize.on, 'function', 'has `on` method' ); + t.strictEqual( typeof autosize.emit, 'function', 'has `emit` method' ); + t.strictEqual( typeof autosize.removeListener, 'function', 'has `removeListener` method' ); + + t.end(); +}); + +tape( 'the constructor ignores unrecognized options', function test( t ) { + var autosize; + + autosize = new Autosize({ + 'type': 'fit', + 'beep': 'boop', + 'foo': 'bar' + }); + + t.strictEqual( autosize.type, 'fit', 'returns expected value' ); + t.strictEqual( hasOwnProp( autosize, 'beep' ), false, 'does not have property' ); + t.strictEqual( hasOwnProp( autosize, 'foo' ), false, 'does not have property' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/plot/vega/autosize/ctor/test/test.properties.js b/lib/node_modules/@stdlib/plot/vega/autosize/ctor/test/test.properties.js new file mode 100644 index 000000000000..da12aad98c82 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/autosize/ctor/test/test.properties.js @@ -0,0 +1,71 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 isArray = require( '@stdlib/assert/is-array' ); +var Autosize = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Autosize, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'attached to the prototype of the main export is a `properties` property which returns autosize properties', function test( t ) { + t.strictEqual( hasOwnProp( Autosize.prototype, 'properties' ), true, 'has property' ); + 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 autosize; + var props; + + autosize = new Autosize(); + props = autosize.properties; + + t.strictEqual( isArray( props ), true, 'returns an array' ); + + expected = [ 'contains', 'resize', 'type' ]; + 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 autosize; + var props1; + var props2; + + autosize = new Autosize(); + props1 = autosize.properties; + props2 = autosize.properties; + + t.strictEqual( props1 !== props2, true, 'returns a new array' ); + t.deepEqual( props1, props2, 'arrays have same content' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/plot/vega/autosize/ctor/test/test.resize.js b/lib/node_modules/@stdlib/plot/vega/autosize/ctor/test/test.resize.js new file mode 100644 index 000000000000..f6bb2d271a8b --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/autosize/ctor/test/test.resize.js @@ -0,0 +1,153 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 Autosize = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Autosize, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'attached to the prototype of the main export is a `resize` property which indicates whether to re-calculate an autosize layout on every view update', function test( t ) { + t.strictEqual( hasOwnProp( Autosize.prototype, 'resize' ), true, 'has property' ); + t.end(); +}); + +tape( 'the constructor throws an error if provided an invalid `resize` 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 autosize = new Autosize({ // eslint-disable-line no-unused-vars + 'resize': value + }); + }; + } +}); + +tape( 'the constructor returns an instance having a `resize` 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 autosize = new Autosize(); + autosize.resize = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `resize` property which returns a boolean indicating whether to re-calculate an autosize layout on every view update', function test( t ) { + var autosize; + + autosize = new Autosize(); + t.strictEqual( autosize.resize, false, 'returns expected value' ); + + autosize = new Autosize({ + 'resize': true + }); + t.strictEqual( autosize.resize, true, 'returns expected value' ); + + autosize = new Autosize({ + 'resize': false + }); + t.strictEqual( autosize.resize, false, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `resize` property which can be set to a boolean', function test( t ) { + var autosize; + + autosize = new Autosize(); + + autosize.resize = true; + t.strictEqual( autosize.resize, true, 'returns expected value' ); + + autosize.resize = false; + t.strictEqual( autosize.resize, false, 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `resize` property is set to a new value', function test( t ) { + var autosize; + var count; + + autosize = new Autosize(); + count = 0; + + autosize.on( 'change', onChange ); + + autosize.resize = true; + t.strictEqual( count, 1, 'emits event' ); + + autosize.resize = false; + t.strictEqual( count, 2, 'emits event' ); + + // Setting to the same value should not emit an event: + autosize.resize = false; + t.strictEqual( count, 2, 'does not emit event when value is unchanged' ); + + t.end(); + + function onChange() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/plot/vega/autosize/ctor/test/test.type.js b/lib/node_modules/@stdlib/plot/vega/autosize/ctor/test/test.type.js new file mode 100644 index 000000000000..4778d9286903 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/autosize/ctor/test/test.type.js @@ -0,0 +1,184 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 Autosize = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Autosize, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'attached to the prototype of the main export is a `type` property for autosize type', function test( t ) { + t.strictEqual( hasOwnProp( Autosize.prototype, 'type' ), true, 'has property' ); + t.end(); +}); + +tape( 'the constructor throws an error if provided an invalid `type` option', function test( t ) { + var values; + var i; + + values = [ + 'beep', + 'boop', + 'invalid', + 'PAD', + 'FIT', + 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 autosize = new Autosize({ // eslint-disable-line no-unused-vars + 'type': value + }); + }; + } +}); + +tape( 'the constructor returns an instance having a `type` property which throws an error if set to an invalid value', function test( t ) { + var values; + var i; + + values = [ + 'beep', + 'boop', + 'invalid', + 'PAD', + 'FIT', + 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 autosize = new Autosize(); + autosize.type = value; + }; + } +}); + +tape( 'the constructor returns an instance having a `type` property which returns the autosize type', function test( t ) { + var autosize; + + autosize = new Autosize(); + t.strictEqual( autosize.type, 'pad', 'returns expected value' ); + + autosize = new Autosize({ + 'type': 'fit' + }); + t.strictEqual( autosize.type, 'fit', 'returns expected value' ); + + autosize = new Autosize({ + 'type': 'fit-x' + }); + t.strictEqual( autosize.type, 'fit-x', 'returns expected value' ); + + autosize = new Autosize({ + 'type': 'fit-y' + }); + t.strictEqual( autosize.type, 'fit-y', 'returns expected value' ); + + autosize = new Autosize({ + 'type': 'none' + }); + t.strictEqual( autosize.type, 'none', 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance having a `type` property which can be set to a valid autosize method', function test( t ) { + var autosize; + + autosize = new Autosize(); + + autosize.type = 'fit'; + t.strictEqual( autosize.type, 'fit', 'returns expected value' ); + + autosize.type = 'fit-x'; + t.strictEqual( autosize.type, 'fit-x', 'returns expected value' ); + + autosize.type = 'fit-y'; + t.strictEqual( autosize.type, 'fit-y', 'returns expected value' ); + + autosize.type = 'none'; + t.strictEqual( autosize.type, 'none', 'returns expected value' ); + + autosize.type = 'pad'; + t.strictEqual( autosize.type, 'pad', 'returns expected value' ); + + t.end(); +}); + +tape( 'the constructor returns an instance which emits an event when the `type` property is set to a new value', function test( t ) { + var autosize; + var count; + + autosize = new Autosize(); + count = 0; + + autosize.on( 'change', onChange ); + + autosize.type = 'fit'; + t.strictEqual( count, 1, 'emits event' ); + + autosize.type = 'none'; + t.strictEqual( count, 2, 'emits event' ); + + // Setting to the same value should not emit an event: + autosize.type = 'none'; + t.strictEqual( count, 2, 'does not emit event when value is unchanged' ); + + t.end(); + + function onChange() { + count += 1; + } +}); From e711a7226344e064fc34ad2e2c157eb92d43540c Mon Sep 17 00:00:00 2001 From: Gururaj Gurram <143020143+gururaj1512@users.noreply.github.com> Date: Thu, 1 Jan 2026 23:48:08 +0530 Subject: [PATCH 2/4] Update test description Signed-off-by: Gururaj Gurram <143020143+gururaj1512@users.noreply.github.com> --- lib/node_modules/@stdlib/plot/vega/autosize/ctor/test/test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/plot/vega/autosize/ctor/test/test.js b/lib/node_modules/@stdlib/plot/vega/autosize/ctor/test/test.js index de180f6e3298..9a86dea85d90 100644 --- a/lib/node_modules/@stdlib/plot/vega/autosize/ctor/test/test.js +++ b/lib/node_modules/@stdlib/plot/vega/autosize/ctor/test/test.js @@ -112,7 +112,7 @@ tape( 'the constructor returns an instance having a `toJSON` method for serializ t.end(); }); -tape( 'the constructor returns an instance having a `toJSON` method for serializing an instance to JSON (custom options)', function test( t ) { +tape( 'the constructor returns an instance having a `toJSON` method for serializing an instance to JSON (options)', function test( t ) { var expected; var autosize; var json; From 086b2dab2b46d4027709757d9a08ef656c19c82b Mon Sep 17 00:00:00 2001 From: stdlib-bot <82920195+stdlib-bot@users.noreply.github.com> Date: Thu, 1 Jan 2026 18:22:24 +0000 Subject: [PATCH 3/4] chore: update copyright years --- .../@stdlib/plot/vega/autosize/ctor/test/test.contains.js | 2 +- lib/node_modules/@stdlib/plot/vega/autosize/ctor/test/test.js | 2 +- .../@stdlib/plot/vega/autosize/ctor/test/test.properties.js | 2 +- .../@stdlib/plot/vega/autosize/ctor/test/test.resize.js | 2 +- .../@stdlib/plot/vega/autosize/ctor/test/test.type.js | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/node_modules/@stdlib/plot/vega/autosize/ctor/test/test.contains.js b/lib/node_modules/@stdlib/plot/vega/autosize/ctor/test/test.contains.js index fb3d5086f8f1..8a11ed6d32ee 100644 --- a/lib/node_modules/@stdlib/plot/vega/autosize/ctor/test/test.contains.js +++ b/lib/node_modules/@stdlib/plot/vega/autosize/ctor/test/test.contains.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2025 The Stdlib Authors. +* 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. diff --git a/lib/node_modules/@stdlib/plot/vega/autosize/ctor/test/test.js b/lib/node_modules/@stdlib/plot/vega/autosize/ctor/test/test.js index 9a86dea85d90..7b0407fba2e2 100644 --- a/lib/node_modules/@stdlib/plot/vega/autosize/ctor/test/test.js +++ b/lib/node_modules/@stdlib/plot/vega/autosize/ctor/test/test.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2025 The Stdlib Authors. +* 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. diff --git a/lib/node_modules/@stdlib/plot/vega/autosize/ctor/test/test.properties.js b/lib/node_modules/@stdlib/plot/vega/autosize/ctor/test/test.properties.js index da12aad98c82..d7b0894ef078 100644 --- a/lib/node_modules/@stdlib/plot/vega/autosize/ctor/test/test.properties.js +++ b/lib/node_modules/@stdlib/plot/vega/autosize/ctor/test/test.properties.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2025 The Stdlib Authors. +* 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. diff --git a/lib/node_modules/@stdlib/plot/vega/autosize/ctor/test/test.resize.js b/lib/node_modules/@stdlib/plot/vega/autosize/ctor/test/test.resize.js index f6bb2d271a8b..36b52890a812 100644 --- a/lib/node_modules/@stdlib/plot/vega/autosize/ctor/test/test.resize.js +++ b/lib/node_modules/@stdlib/plot/vega/autosize/ctor/test/test.resize.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2025 The Stdlib Authors. +* 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. diff --git a/lib/node_modules/@stdlib/plot/vega/autosize/ctor/test/test.type.js b/lib/node_modules/@stdlib/plot/vega/autosize/ctor/test/test.type.js index 4778d9286903..c5704275fede 100644 --- a/lib/node_modules/@stdlib/plot/vega/autosize/ctor/test/test.type.js +++ b/lib/node_modules/@stdlib/plot/vega/autosize/ctor/test/test.type.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2025 The Stdlib Authors. +* 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. From 4a60b278d5d5d369be6a217cd201231d10c14523 Mon Sep 17 00:00:00 2001 From: gururaj1512 Date: Wed, 14 Jan 2026 13:09:21 +0530 Subject: [PATCH 4/4] chore: apply suggested changes --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../vega/autosize/ctor/test/test.contains.js | 17 ++++++++++++----- .../plot/vega/autosize/ctor/test/test.js | 12 ++++++------ .../vega/autosize/ctor/test/test.properties.js | 16 +++++++++++----- .../plot/vega/autosize/ctor/test/test.resize.js | 17 ++++++++++++----- .../plot/vega/autosize/ctor/test/test.type.js | 17 ++++++++++++----- 5 files changed, 53 insertions(+), 26 deletions(-) diff --git a/lib/node_modules/@stdlib/plot/vega/autosize/ctor/test/test.contains.js b/lib/node_modules/@stdlib/plot/vega/autosize/ctor/test/test.contains.js index 8a11ed6d32ee..a3d6f28c1510 100644 --- a/lib/node_modules/@stdlib/plot/vega/autosize/ctor/test/test.contains.js +++ b/lib/node_modules/@stdlib/plot/vega/autosize/ctor/test/test.contains.js @@ -22,6 +22,8 @@ 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 Autosize = require( './../lib' ); @@ -33,8 +35,13 @@ tape( 'main export is a function', function test( t ) { t.end(); }); -tape( 'attached to the prototype of the main export is a `contains` property for determining how a size calculation should be performed', function test( t ) { - t.strictEqual( hasOwnProp( Autosize.prototype, 'contains' ), true, 'has property' ); +tape( 'the constructor returns an instance which has a `contains` property', function test( t ) { + var v; + + v = new Autosize(); + t.strictEqual( hasOwnProp( v, 'contains' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'contains' ), true, 'returns expected value' ); + t.strictEqual( isString( v.contains ), true, 'returns expected value' ); t.end(); }); @@ -148,14 +155,14 @@ tape( 'the constructor returns an instance which emits an event when the `contai autosize.on( 'change', onChange ); autosize.contains = 'padding'; - t.strictEqual( count, 1, 'emits event' ); + t.strictEqual( count, 1, 'returns expected value' ); autosize.contains = 'content'; - t.strictEqual( count, 2, 'emits event' ); + t.strictEqual( count, 2, 'returns expected value' ); // Setting to the same value should not emit an event: autosize.contains = 'content'; - t.strictEqual( count, 2, 'does not emit event when value is unchanged' ); + t.strictEqual( count, 2, 'returns expected value' ); t.end(); diff --git a/lib/node_modules/@stdlib/plot/vega/autosize/ctor/test/test.js b/lib/node_modules/@stdlib/plot/vega/autosize/ctor/test/test.js index 7b0407fba2e2..f8bb9caf6152 100644 --- a/lib/node_modules/@stdlib/plot/vega/autosize/ctor/test/test.js +++ b/lib/node_modules/@stdlib/plot/vega/autosize/ctor/test/test.js @@ -148,7 +148,7 @@ tape( 'the `toJSON` method is implicitly invoked by `JSON.stringify`', function 'resize': false, 'type': 'none' }; - t.strictEqual( JSON.stringify( autosize ), JSON.stringify( expected ), 'serializes as JSON when called by JSON.stringify()' ); + t.strictEqual( JSON.stringify( autosize ), JSON.stringify( expected ), 'returns expected value' ); t.end(); }); @@ -157,9 +157,9 @@ tape( 'the constructor returns an instance which inherits from EventEmitter', fu autosize = new Autosize(); - t.strictEqual( typeof autosize.on, 'function', 'has `on` method' ); - t.strictEqual( typeof autosize.emit, 'function', 'has `emit` method' ); - t.strictEqual( typeof autosize.removeListener, 'function', 'has `removeListener` method' ); + t.strictEqual( typeof autosize.on, 'function', 'returns expected value' ); + t.strictEqual( typeof autosize.emit, 'function', 'returns expected value' ); + t.strictEqual( typeof autosize.removeListener, 'function', 'returns expected value' ); t.end(); }); @@ -174,8 +174,8 @@ tape( 'the constructor ignores unrecognized options', function test( t ) { }); t.strictEqual( autosize.type, 'fit', 'returns expected value' ); - t.strictEqual( hasOwnProp( autosize, 'beep' ), false, 'does not have property' ); - t.strictEqual( hasOwnProp( autosize, 'foo' ), false, 'does not have property' ); + t.strictEqual( hasOwnProp( autosize, 'beep' ), false, 'returns expected value' ); + t.strictEqual( hasOwnProp( autosize, 'foo' ), false, 'returns expected value' ); t.end(); }); diff --git a/lib/node_modules/@stdlib/plot/vega/autosize/ctor/test/test.properties.js b/lib/node_modules/@stdlib/plot/vega/autosize/ctor/test/test.properties.js index d7b0894ef078..8224f9c55b1e 100644 --- a/lib/node_modules/@stdlib/plot/vega/autosize/ctor/test/test.properties.js +++ b/lib/node_modules/@stdlib/plot/vega/autosize/ctor/test/test.properties.js @@ -22,6 +22,7 @@ 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 Autosize = require( './../lib' ); @@ -34,8 +35,13 @@ tape( 'main export is a function', function test( t ) { t.end(); }); -tape( 'attached to the prototype of the main export is a `properties` property which returns autosize properties', function test( t ) { - t.strictEqual( hasOwnProp( Autosize.prototype, 'properties' ), true, 'has property' ); +tape( 'the constructor returns an instance which has a `properties` property', function test( t ) { + var v; + + v = new Autosize(); + 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(); }); @@ -47,7 +53,7 @@ tape( 'the constructor returns an instance having a `properties` property which autosize = new Autosize(); props = autosize.properties; - t.strictEqual( isArray( props ), true, 'returns an array' ); + t.strictEqual( isArray( props ), true, 'returns expected value' ); expected = [ 'contains', 'resize', 'type' ]; t.deepEqual( props, expected, 'returns expected value' ); @@ -64,8 +70,8 @@ tape( 'the constructor returns an instance having a `properties` property which props1 = autosize.properties; props2 = autosize.properties; - t.strictEqual( props1 !== props2, true, 'returns a new array' ); - t.deepEqual( props1, props2, 'arrays have same content' ); + 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/autosize/ctor/test/test.resize.js b/lib/node_modules/@stdlib/plot/vega/autosize/ctor/test/test.resize.js index 36b52890a812..567d244c9336 100644 --- a/lib/node_modules/@stdlib/plot/vega/autosize/ctor/test/test.resize.js +++ b/lib/node_modules/@stdlib/plot/vega/autosize/ctor/test/test.resize.js @@ -22,6 +22,8 @@ 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 Autosize = require( './../lib' ); @@ -33,8 +35,13 @@ tape( 'main export is a function', function test( t ) { t.end(); }); -tape( 'attached to the prototype of the main export is a `resize` property which indicates whether to re-calculate an autosize layout on every view update', function test( t ) { - t.strictEqual( hasOwnProp( Autosize.prototype, 'resize' ), true, 'has property' ); +tape( 'the constructor returns an instance which has a `resize` property', function test( t ) { + var v; + + v = new Autosize(); + t.strictEqual( hasOwnProp( v, 'resize' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'resize' ), true, 'returns expected value' ); + t.strictEqual( isBoolean( v.resize ), true, 'returns expected value' ); t.end(); }); @@ -136,14 +143,14 @@ tape( 'the constructor returns an instance which emits an event when the `resize autosize.on( 'change', onChange ); autosize.resize = true; - t.strictEqual( count, 1, 'emits event' ); + t.strictEqual( count, 1, 'returns expected value' ); autosize.resize = false; - t.strictEqual( count, 2, 'emits event' ); + t.strictEqual( count, 2, 'returns expected value' ); // Setting to the same value should not emit an event: autosize.resize = false; - t.strictEqual( count, 2, 'does not emit event when value is unchanged' ); + t.strictEqual( count, 2, 'returns expected value' ); t.end(); diff --git a/lib/node_modules/@stdlib/plot/vega/autosize/ctor/test/test.type.js b/lib/node_modules/@stdlib/plot/vega/autosize/ctor/test/test.type.js index c5704275fede..3ec46745a9d6 100644 --- a/lib/node_modules/@stdlib/plot/vega/autosize/ctor/test/test.type.js +++ b/lib/node_modules/@stdlib/plot/vega/autosize/ctor/test/test.type.js @@ -22,6 +22,8 @@ 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 Autosize = require( './../lib' ); @@ -33,8 +35,13 @@ tape( 'main export is a function', function test( t ) { t.end(); }); -tape( 'attached to the prototype of the main export is a `type` property for autosize type', function test( t ) { - t.strictEqual( hasOwnProp( Autosize.prototype, 'type' ), true, 'has property' ); +tape( 'the constructor returns an instance which has a `type` property', function test( t ) { + var v; + + v = new Autosize(); + t.strictEqual( hasOwnProp( v, 'type' ), false, 'returns expected value' ); + t.strictEqual( hasProp( v, 'type' ), true, 'returns expected value' ); + t.strictEqual( isString( v.type ), true, 'returns expected value' ); t.end(); }); @@ -167,14 +174,14 @@ tape( 'the constructor returns an instance which emits an event when the `type` autosize.on( 'change', onChange ); autosize.type = 'fit'; - t.strictEqual( count, 1, 'emits event' ); + t.strictEqual( count, 1, 'returns expected value' ); autosize.type = 'none'; - t.strictEqual( count, 2, 'emits event' ); + t.strictEqual( count, 2, 'returns expected value' ); // Setting to the same value should not emit an event: autosize.type = 'none'; - t.strictEqual( count, 2, 'does not emit event when value is unchanged' ); + t.strictEqual( count, 2, 'returns expected value' ); t.end();