Skip to content

Commit 534a2fe

Browse files
committed
Auto-generated commit
1 parent ff553e2 commit 534a2fe

File tree

3 files changed

+11
-146
lines changed

3 files changed

+11
-146
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,8 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors].
197197
[npm-image]: http://img.shields.io/npm/v/@stdlib/assert-has-node-buffer-support.svg
198198
[npm-url]: https://npmjs.org/package/@stdlib/assert-has-node-buffer-support
199199

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

203203
[coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/assert-has-node-buffer-support/main.svg
204204
[coverage-url]: https://codecov.io/github/stdlib-js/assert-has-node-buffer-support?branch=main

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,12 @@
4545
"@stdlib/fs-read-file": "^0.1.1"
4646
},
4747
"devDependencies": {
48-
"@stdlib/assert-is-boolean": "^0.1.0",
49-
"@stdlib/assert-is-browser": "^0.1.0",
50-
"@stdlib/assert-is-windows": "^0.1.0",
48+
"@stdlib/assert-is-boolean": "^0.1.1",
49+
"@stdlib/assert-is-browser": "^0.1.1",
50+
"@stdlib/assert-is-windows": "^0.1.1",
5151
"@stdlib/bench": "^0.1.0",
52-
"@stdlib/buffer-ctor": "^0.1.0",
53-
"@stdlib/process-exec-path": "^0.1.0",
52+
"@stdlib/buffer-ctor": "^0.1.1",
53+
"@stdlib/process-exec-path": "^0.1.1",
5454
"proxyquire": "^2.0.0",
5555
"tape": "git+https://github.com/kgryte/tape.git#fix/globby",
5656
"istanbul": "^0.4.1",

test/dist/test.js

Lines changed: 4 additions & 139 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* @license Apache-2.0
33
*
4-
* Copyright (c) 2018 The Stdlib Authors.
4+
* Copyright (c) 2023 The Stdlib Authors.
55
*
66
* Licensed under the Apache License, Version 2.0 (the "License");
77
* you may not use this file except in compliance with the License.
@@ -21,148 +21,13 @@
2121
// MODULES //
2222

2323
var tape = require( 'tape' );
24-
var proxyquire = require( 'proxyquire' );
25-
var Buffer = require( '@stdlib/buffer-ctor' );
26-
var detect = require( './../../dist' );
27-
28-
29-
// VARIABLES //
30-
31-
var hasNodeBuffer = ( typeof Buffer === 'function' );
24+
var main = require( './../../dist' );
3225

3326

3427
// TESTS //
3528

36-
tape( 'main export is a function', function test( t ) {
29+
tape( 'main export is defined', function test( t ) {
3730
t.ok( true, __filename );
38-
t.strictEqual( typeof detect, 'function', 'main export is a function' );
39-
t.end();
40-
});
41-
42-
tape( 'feature detection result is a boolean', function test( t ) {
43-
t.strictEqual( typeof detect(), 'boolean', 'detection result is a boolean' );
44-
t.end();
45-
});
46-
47-
tape( 'if `Buffer` is supported, detection result is `true` (no `from` method; Node <v5.10)', function test( t ) {
48-
var mocked;
49-
if ( hasNodeBuffer ) {
50-
t.strictEqual( detect(), true, 'detection result is `true`' );
51-
} else {
52-
t.strictEqual( detect(), false, 'detection result is `false`' );
53-
}
54-
mocked = proxyquire( './../dist/main.js', {
55-
'./buffer.js': Mock,
56-
'@stdlib/assert-is-buffer': isBuffer
57-
});
58-
t.strictEqual( mocked(), true, 'detection result is `true` (mocked)' );
59-
60-
t.end();
61-
62-
function isBuffer() {
63-
return true;
64-
}
65-
66-
function Mock() {
67-
return [
68-
1,
69-
2,
70-
3,
71-
4
72-
];
73-
}
74-
});
75-
76-
tape( 'if `Buffer` is supported, detection result is `true` (has `from` method; Node v5.10+)', function test( t ) {
77-
var mocked;
78-
if ( hasNodeBuffer ) {
79-
t.strictEqual( detect(), true, 'detection result is `true`' );
80-
} else {
81-
t.strictEqual( detect(), false, 'detection result is `false`' );
82-
}
83-
function Mock() {
84-
return this;
85-
}
86-
87-
Mock.from = from;
88-
89-
mocked = proxyquire( './../dist/main.js', {
90-
'./buffer.js': Mock,
91-
'@stdlib/assert-is-buffer': isBuffer
92-
});
93-
t.strictEqual( mocked(), true, 'detection result is `true` (mocked)' );
94-
31+
t.strictEqual( main !== void 0, true, 'main export is defined' );
9532
t.end();
96-
97-
function isBuffer() {
98-
return true;
99-
}
100-
101-
function from() {
102-
return [
103-
1,
104-
2,
105-
3,
106-
4
107-
];
108-
}
109-
});
110-
111-
tape( 'if `Buffer` is not supported, detection result is `false`', function test( t ) {
112-
var mocked;
113-
if ( hasNodeBuffer ) {
114-
t.strictEqual( detect(), true, 'detection result is `true`' );
115-
} else {
116-
t.strictEqual( detect(), false, 'detection result is `false`' );
117-
}
118-
function Mock1() {
119-
// Not a buffer:
120-
return {};
121-
}
122-
123-
Mock1.from = null;
124-
125-
function Mock2() {
126-
throw new Error( 'beep' );
127-
}
128-
129-
Mock2.from = null;
130-
131-
function Mock3() {
132-
return this;
133-
}
134-
135-
Mock3.from = from;
136-
137-
mocked = proxyquire( './../dist/main.js', {
138-
'./buffer.js': {}
139-
});
140-
t.strictEqual( mocked(), false, 'detection result is `false`' );
141-
142-
mocked = proxyquire( './../dist/main.js', {
143-
'./buffer.js': Mock1
144-
});
145-
t.strictEqual( mocked(), false, 'detection result is `false`' );
146-
147-
mocked = proxyquire( './../dist/main.js', {
148-
'./buffer.js': Mock2,
149-
'@stdlib/assert-is-buffer': isBuffer
150-
});
151-
t.strictEqual( mocked(), false, 'detection result is `false`' );
152-
153-
mocked = proxyquire( './../dist/main.js', {
154-
'./buffer.js': Mock3,
155-
'@stdlib/assert-is-buffer': isBuffer
156-
});
157-
t.strictEqual( mocked(), false, 'detection result is `false`' );
158-
159-
t.end();
160-
161-
function isBuffer() {
162-
return true;
163-
}
164-
165-
function from() {
166-
throw new Error( 'boop' );
167-
}
16833
});

0 commit comments

Comments
 (0)