|
1 | 1 | /** |
2 | 2 | * @license Apache-2.0 |
3 | 3 | * |
4 | | -* Copyright (c) 2018 The Stdlib Authors. |
| 4 | +* Copyright (c) 2023 The Stdlib Authors. |
5 | 5 | * |
6 | 6 | * Licensed under the Apache License, Version 2.0 (the "License"); |
7 | 7 | * you may not use this file except in compliance with the License. |
|
21 | 21 | // MODULES // |
22 | 22 |
|
23 | 23 | var tape = require( 'tape' ); |
24 | | -var string2buffer = require( '@stdlib/buffer-from-string' ); |
25 | | -var removeUTF8BOM = require( './../../dist' ); |
| 24 | +var main = require( './../../dist' ); |
26 | 25 |
|
27 | 26 |
|
28 | 27 | // TESTS // |
29 | 28 |
|
30 | | -tape( 'main export is a function', function test( t ) { |
| 29 | +tape( 'main export is defined', function test( t ) { |
31 | 30 | t.ok( true, __filename ); |
32 | | - t.strictEqual( typeof removeUTF8BOM, 'function', 'main export is a function' ); |
33 | | - t.end(); |
34 | | -}); |
35 | | - |
36 | | -tape( 'the function throws an error if not provided a string primitive', function test( t ) { |
37 | | - var values; |
38 | | - var i; |
39 | | - |
40 | | - values = [ |
41 | | - 5, |
42 | | - NaN, |
43 | | - true, |
44 | | - null, |
45 | | - void 0, |
46 | | - [], |
47 | | - {}, |
48 | | - function noop() {} |
49 | | - ]; |
50 | | - |
51 | | - for ( i = 0; i < values.length; i++ ) { |
52 | | - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); |
53 | | - } |
54 | | - t.end(); |
55 | | - |
56 | | - function badValue( value ) { |
57 | | - return function badValue() { |
58 | | - removeUTF8BOM( value ); |
59 | | - }; |
60 | | - } |
61 | | -}); |
62 | | - |
63 | | -tape( 'the function removes a UTF-8 byte order mark (BOM) from the beginning of a string', function test( t ) { |
64 | | - var str; |
65 | | - |
66 | | - str = removeUTF8BOM( '\ufeffbeep' ); |
67 | | - t.equal( str, 'beep', 'returns beep' ); |
68 | | - |
69 | | - str = string2buffer( '\ufeffboop' ).toString(); |
70 | | - str = removeUTF8BOM( str ); |
71 | | - t.equal( str, 'boop', 'returns boop' ); |
72 | | - |
73 | | - t.end(); |
74 | | -}); |
75 | | - |
76 | | -tape( 'the function ignores zero-width non-breaking spaces (Unicode) occurring elsewhere in a string', function test( t ) { |
77 | | - var str; |
78 | | - |
79 | | - str = removeUTF8BOM( 'boop\ufeff' ); |
80 | | - t.equal( str, 'boop\ufeff', 'returns boop\ufeff' ); |
81 | | - |
82 | | - str = removeUTF8BOM( 'be\ufeffbop' ); |
83 | | - t.equal( str, 'be\ufeffbop', 'returns be\ufeffbop' ); |
84 | | - |
85 | | - t.end(); |
86 | | -}); |
87 | | - |
88 | | -tape( 'if a string does not begin with a BOM, the function returns the input string unchanged', function test( t ) { |
89 | | - var str = removeUTF8BOM( 'foobar' ); |
90 | | - t.equal( str, 'foobar', 'returns foobar' ); |
| 31 | + t.strictEqual( main !== void 0, true, 'main export is defined' ); |
91 | 32 | t.end(); |
92 | 33 | }); |
0 commit comments