Skip to content

Commit

Permalink
Auto-generated commit
Browse files Browse the repository at this point in the history
  • Loading branch information
stdlib-bot committed Oct 5, 2023
1 parent d1203ae commit b105811
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 104 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,8 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors].
[npm-image]: http://img.shields.io/npm/v/@stdlib/assert-has-weakset-support.svg
[npm-url]: https://npmjs.org/package/@stdlib/assert-has-weakset-support

[test-image]: https://github.com/stdlib-js/assert-has-weakset-support/actions/workflows/test.yml/badge.svg?branch=v0.1.1
[test-url]: https://github.com/stdlib-js/assert-has-weakset-support/actions/workflows/test.yml?query=branch:v0.1.1
[test-image]: https://github.com/stdlib-js/assert-has-weakset-support/actions/workflows/test.yml/badge.svg?branch=main
[test-url]: https://github.com/stdlib-js/assert-has-weakset-support/actions/workflows/test.yml?query=branch:main

[coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/assert-has-weakset-support/main.svg
[coverage-url]: https://codecov.io/github/stdlib-js/assert-has-weakset-support?branch=main
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@
"@stdlib/fs-read-file": "^0.1.1"
},
"devDependencies": {
"@stdlib/assert-is-boolean": "^0.1.0",
"@stdlib/assert-is-browser": "^0.1.0",
"@stdlib/assert-is-windows": "^0.1.0",
"@stdlib/assert-is-boolean": "^0.1.1",
"@stdlib/assert-is-browser": "^0.1.1",
"@stdlib/assert-is-windows": "^0.1.1",
"@stdlib/bench": "^0.1.0",
"@stdlib/process-exec-path": "^0.1.0",
"@stdlib/process-exec-path": "^0.1.1",
"proxyquire": "^2.0.0",
"tape": "git+https://github.com/kgryte/tape.git#fix/globby",
"istanbul": "^0.4.1",
Expand Down
102 changes: 4 additions & 98 deletions test/dist/test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @license Apache-2.0
*
* Copyright (c) 2018 The Stdlib Authors.
* Copyright (c) 2023 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.
Expand All @@ -21,107 +21,13 @@
// MODULES //

var tape = require( 'tape' );
var proxyquire = require( 'proxyquire' );
var detect = require( './../../dist' );


// VARIABLES //

var hasWeakSet = ( typeof WeakSet === 'function' );
var main = require( './../../dist' );


// TESTS //

tape( 'main export is a function', function test( t ) {
tape( 'main export is defined', function test( t ) {
t.ok( true, __filename );
t.strictEqual( typeof detect, 'function', 'main export is a function' );
t.strictEqual( main !== void 0, true, 'main export is defined' );
t.end();
});

tape( 'feature detection result is a boolean', function test( t ) {
t.strictEqual( typeof detect(), 'boolean', 'detection result is a boolean' );
t.end();
});

tape( 'if `WeakSet` is supported, detection result is `true`', function test( t ) {
var mocked;
if ( hasWeakSet ) {
t.strictEqual( detect(), true, 'detection result is `true`' );
} else {
t.strictEqual( detect(), false, 'detection result is `false`' );
}
mocked = proxyquire( './../dist/main.js', {
'./weakset.js': Mock
});
t.strictEqual( mocked(), true, 'detection result is `true` (mocked)' );

t.end();

function Mock() {
var arr = [];

function has( value ) {
return arr.indexOf( value ) !== -1;
}
function add( value ) {
if ( has( value ) ) {
return;
}
arr.push( value );
}

return {
'has': has,
'add': add
};
}
});

tape( 'if `WeakSet` is not supported, detection result is `false`', function test( t ) {
var mocked;
if ( hasWeakSet ) {
t.strictEqual( detect(), true, 'detection result is `true`' );
} else {
t.strictEqual( detect(), false, 'detection result is `false`' );
}
mocked = proxyquire( './../dist/main.js', {
'./weakset.js': {}
});
t.strictEqual( mocked(), false, 'detection result is `false` (mocked)' );

mocked = proxyquire( './../dist/main.js', {
'./weakset.js': Mock1
});
t.strictEqual( mocked(), false, 'detection result is `false` (no `has` method)' );

mocked = proxyquire( './../dist/main.js', {
'./weakset.js': Mock2
});
t.strictEqual( mocked(), false, 'detection result is `false` (no `add` method)' );

t.end();

function Mock1() {
var arr = [];

function add( value ) {
arr.push( value );
}

return {
'add': add
};
}

function Mock2() {
var arr = [];

function has( value ) {
return arr.indexOf( value ) !== -1;
}

return {
'has': has
};
}
});

0 comments on commit b105811

Please sign in to comment.