Skip to content

Commit e19b784

Browse files
authored
test: add baseline tests for _tools/licenses/licenses and add README example
PR-URL: #12273 Reviewed-by: Athan Reines <kgryte@gmail.com>
1 parent 3c1e93d commit e19b784

3 files changed

Lines changed: 77 additions & 4 deletions

File tree

lib/node_modules/@stdlib/_tools/licenses/licenses/README.md

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,22 @@ function onResults( error, results ) {
9797

9898
<section class="examples">
9999

100-
<!-- ## Examples
100+
## Examples
101101

102-
``` javascript
102+
<!-- eslint no-undef: "error" -->
103103

104-
``` -->
104+
```javascript
105+
var licenses = require( '@stdlib/_tools/licenses/licenses' );
106+
107+
licenses( onResults );
108+
109+
function onResults( error, results ) {
110+
if ( error ) {
111+
throw error;
112+
}
113+
console.log( JSON.stringify( results ) );
114+
}
115+
```
105116

106117
</section>
107118

lib/node_modules/@stdlib/_tools/licenses/licenses/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
"directories": {
2121
"doc": "./docs",
2222
"example": "./examples",
23-
"lib": "./lib"
23+
"lib": "./lib",
24+
"test": "./test"
2425
},
2526
"scripts": {},
2627
"homepage": "https://github.com/stdlib-js/stdlib",
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2026 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
'use strict';
20+
21+
// MODULES //
22+
23+
var tape = require( 'tape' );
24+
var licenses = require( './../lib' );
25+
26+
27+
// TESTS //
28+
29+
tape( 'main export is a function', function test( t ) {
30+
t.ok( true, __filename );
31+
t.strictEqual( typeof licenses, 'function', 'main export is a function' );
32+
t.end();
33+
});
34+
35+
tape( 'the function throws an error if not provided a callback argument which is a function', function test( t ) {
36+
var values;
37+
var i;
38+
39+
values = [
40+
'5',
41+
5,
42+
NaN,
43+
true,
44+
false,
45+
null,
46+
undefined,
47+
[],
48+
{}
49+
];
50+
51+
for ( i = 0; i < values.length; i++ ) {
52+
t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided '+values[ i ] );
53+
}
54+
t.end();
55+
56+
function badValue( value ) {
57+
return function badValue() {
58+
licenses( value );
59+
};
60+
}
61+
});

0 commit comments

Comments
 (0)