Skip to content

Commit

Permalink
[Tests] add passing test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
ljharb committed Mar 8, 2023
1 parent 017a8c0 commit 2ab172c
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions test/tests.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
'use strict';

var forEach = require('for-each');

module.exports = function (trim, t) {
t.test('normal cases', function (st) {
st.equal(trim(' \t\na \t\n'), 'a', 'strips whitespace off left and right sides');
Expand Down Expand Up @@ -42,4 +44,19 @@ module.exports = function (trim, t) {
st.equal(trim(zeroWidth), zeroWidth, 'zero width space does not trim');
st.end();
});

t.test('non-whitespace characters', function (st) {
// Zero-width space (zws), next line character (nel), and non-character (bom) are not whitespace.
var nonWhitespaces = {
'\\u0085': '\u0085',
'\\u200b': '\u200b',
'\\ufffe': '\ufffe'
};

forEach(nonWhitespaces, function (nonWhitespace, name) {
st.equal(trim(nonWhitespace), nonWhitespace, name + ' does not trim');
});

st.end();
});
};

0 comments on commit 2ab172c

Please sign in to comment.