Skip to content

Commit 0fc57a1

Browse files
committed
Auto-generated commit
1 parent 71abd0d commit 0fc57a1

File tree

2 files changed

+6
-132
lines changed

2 files changed

+6
-132
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,8 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors].
207207
[npm-image]: http://img.shields.io/npm/v/@stdlib/buffer-from-string.svg
208208
[npm-url]: https://npmjs.org/package/@stdlib/buffer-from-string
209209

210-
[test-image]: https://github.com/stdlib-js/buffer-from-string/actions/workflows/test.yml/badge.svg?branch=v0.1.1
211-
[test-url]: https://github.com/stdlib-js/buffer-from-string/actions/workflows/test.yml?query=branch:v0.1.1
210+
[test-image]: https://github.com/stdlib-js/buffer-from-string/actions/workflows/test.yml/badge.svg?branch=main
211+
[test-url]: https://github.com/stdlib-js/buffer-from-string/actions/workflows/test.yml?query=branch:main
212212

213213
[coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/buffer-from-string/main.svg
214214
[coverage-url]: https://codecov.io/github/stdlib-js/buffer-from-string?branch=main

test/dist/test.js

Lines changed: 4 additions & 130 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,139 +21,13 @@
2121
// MODULES //
2222

2323
var tape = require( 'tape' );
24-
var proxyquire = require( 'proxyquire' );
25-
var isBuffer = require( '@stdlib/assert-is-buffer' );
26-
var polyfill = require( './../../dist/polyfill.js' );
27-
var nonPolyfill = require( './../../dist/main.js' );
28-
var string2buffer = require( './../../dist' );
24+
var main = require( './../../dist' );
2925

3026

3127
// TESTS //
3228

33-
tape( 'main export is a function', function test( t ) {
29+
tape( 'main export is defined', function test( t ) {
3430
t.ok( true, __filename );
35-
t.strictEqual( typeof string2buffer, 'function', 'main export is a function' );
36-
t.end();
37-
});
38-
39-
tape( 'in older environments, the main export is a polyfill', function test( t ) {
40-
var string2buffer = proxyquire( './../dist', {
41-
'./has_from.js': false
42-
});
43-
t.strictEqual( string2buffer, polyfill, 'returns polyfill' );
44-
t.end();
45-
});
46-
47-
tape( 'in newer environments, the main export is not a polyfill', function test( t ) {
48-
var string2buffer = proxyquire( './../dist', {
49-
'./has_from.js': true
50-
});
51-
t.strictEqual( string2buffer, nonPolyfill, 'does not return polyfill' );
52-
t.end();
53-
});
54-
55-
tape( 'the function throws an error if not provided a string', function test( t ) {
56-
var values;
57-
var i;
58-
59-
values = [
60-
5,
61-
NaN,
62-
true,
63-
false,
64-
null,
65-
void 0,
66-
[],
67-
[ 1, 2, 3, 4 ],
68-
{},
69-
function noop() {}
70-
];
71-
72-
for ( i = 0; i < values.length; i++ ) {
73-
t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] );
74-
}
75-
t.end();
76-
77-
function badValue( value ) {
78-
return function badValue() {
79-
string2buffer( value );
80-
};
81-
}
82-
});
83-
84-
tape( 'the function throws an error if not provided a string (encoding)', function test( t ) {
85-
var values;
86-
var i;
87-
88-
values = [
89-
5,
90-
NaN,
91-
true,
92-
false,
93-
null,
94-
void 0,
95-
[],
96-
[ 1, 2, 3, 4 ],
97-
{},
98-
function noop() {}
99-
];
100-
101-
for ( i = 0; i < values.length; i++ ) {
102-
t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] );
103-
}
104-
t.end();
105-
106-
function badValue( value ) {
107-
return function badValue() {
108-
string2buffer( value, 'utf8' );
109-
};
110-
}
111-
});
112-
113-
tape( 'the function throws an error if not provided a valid encoding argument', function test( t ) {
114-
var values;
115-
var i;
116-
117-
values = [
118-
'beep',
119-
'boop',
120-
'bop',
121-
5,
122-
NaN,
123-
true,
124-
false,
125-
null,
126-
void 0,
127-
[],
128-
[ 1, 2, 3, 4 ],
129-
{},
130-
function noop() {}
131-
];
132-
133-
for ( i = 0; i < values.length; i++ ) {
134-
t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] );
135-
}
136-
t.end();
137-
138-
function badValue( value ) {
139-
return function badValue() {
140-
string2buffer( 'beep', value );
141-
};
142-
}
143-
});
144-
145-
tape( 'the function allocates a buffer containing a provided string', function test( t ) {
146-
var buf = string2buffer( 'beep boop' );
147-
t.strictEqual( isBuffer( buf ), true, 'returns a buffer' );
148-
t.strictEqual( buf.length, 9, 'has expected length' );
149-
t.strictEqual( buf.toString(), 'beep boop', 'returns expected value' );
150-
t.end();
151-
});
152-
153-
tape( 'the function allocates a buffer containing a provided string (encoding)', function test( t ) {
154-
var buf = string2buffer( '7468697320697320612074c3a97374', 'hex' );
155-
t.strictEqual( isBuffer( buf ), true, 'returns a buffer' );
156-
t.strictEqual( buf.length, 15, 'has expected length' );
157-
t.strictEqual( buf.toString(), 'this is a tést', 'returns expected value' );
31+
t.strictEqual( main !== void 0, true, 'main export is defined' );
15832
t.end();
15933
});

0 commit comments

Comments
 (0)