Skip to content

Commit d0bfd4e

Browse files
committed
Add Unicode test cases
1 parent f69fc27 commit d0bfd4e

File tree

2 files changed

+42
-0
lines changed
  • lib/node_modules/@stdlib/string

2 files changed

+42
-0
lines changed

lib/node_modules/@stdlib/string/substring-before-last/test/test.js

+21
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,27 @@ tape( 'the function returns the substring before the last occurrence of the prov
111111
t.end();
112112
});
113113

114+
tape( 'the function returns the substring before a provided search string (Unicode characters)', function test( t ) {
115+
var expected;
116+
var actual;
117+
var str;
118+
119+
str = 'beep 😀 boop 😀 baz';
120+
actual = substringBeforeLast( str, '😀' );
121+
expected = 'beep 😀 boop ';
122+
t.strictEqual( actual, expected, 'returns expected value' );
123+
124+
str = '🤖 Robot army 🤖!';
125+
actual = substringBeforeLast( str, '🤖' );
126+
expected = '🤖 Robot army ';
127+
128+
str = '🐺 Wolf brothers 🐺';
129+
actual = substringBeforeLast( str, 'o' );
130+
expected = '🐺 Wolf brothers ';
131+
132+
t.end();
133+
});
134+
114135
tape( 'the function returns the entire string if the search string is not found', function test( t ) {
115136
var expected;
116137
var actual;

lib/node_modules/@stdlib/string/substring-before/test/test.js

+21
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,27 @@ tape( 'the function returns the substring before a provided search string', func
109109
t.end();
110110
});
111111

112+
tape( 'the function returns the substring before a provided search string (Unicode characters)', function test( t ) {
113+
var expected;
114+
var actual;
115+
var str;
116+
117+
str = 'beep 😀 boop 😀 baz';
118+
actual = substringBefore( str, '😀' );
119+
expected = 'beep ';
120+
t.strictEqual( actual, expected, 'returns expected value' );
121+
122+
str = '🤖 Robot army 🤖!';
123+
actual = substringBefore( str, '🤖' );
124+
expected = '';
125+
126+
str = '🐺 Wolf brothers 🐺';
127+
actual = substringBefore( str, 'o' );
128+
expected = '🐺 W';
129+
130+
t.end();
131+
});
132+
112133
tape( 'the function returns the entire string if the search string is not found', function test( t ) {
113134
var expected;
114135
var actual;

0 commit comments

Comments
 (0)