// test string utils var assert = require('assert'); var approx = require('../../tools/approx'); var BigNumber = require('decimal.js'); var math = require('../../index'); var string = require('../../lib/utils/string'); describe ('string', function () { it('isString', function() { assert.equal(string.isString('hi'), true); assert.equal(string.isString(String('hi')), true); assert.equal(string.isString(23), false); assert.equal(string.isString(true), false); assert.equal(string.isString(new Date()), false); // we don't support non primitive Strings anymore assert.equal(string.isString(new String('hi')), false); }); it('endsWith', function() { assert.equal(string.endsWith('hello', 'hello'), true); assert.equal(string.endsWith('hello', 'lo'), true); assert.equal(string.endsWith('hello', ''), true); assert.equal(string.endsWith('hello!', 'lo'), false); assert.equal(string.endsWith('hello', 'LO'), false); assert.equal(string.endsWith('hello', 'hellohello'), false); }); it('should escape special HTML characters', function() { assert.equal(string.escape('&<>"\''), '&<>"''); assert.equal(string.escape('