mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2025-08-10 21:39:57 -04:00
Add tests! =]
This commit is contained in:
parent
d91c19434f
commit
cd8de5f156
6 changed files with 378 additions and 0 deletions
test/unit
|
@ -84,3 +84,28 @@ test('stringify', t => {
|
|||
t.equal(parsed.f.nested, 0);
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('replaceUnsafeChars', t => {
|
||||
const empty = '';
|
||||
t.equal(StringUtil.replaceUnsafeChars(empty), empty);
|
||||
|
||||
const safe = 'hello';
|
||||
t.equal(StringUtil.replaceUnsafeChars(safe), safe);
|
||||
|
||||
const unsafe = '< > & \' "';
|
||||
t.equal(StringUtil.replaceUnsafeChars(unsafe), 'lt gt amp apos quot');
|
||||
|
||||
const single = '&';
|
||||
t.equal(StringUtil.replaceUnsafeChars(single), 'amp');
|
||||
|
||||
const mix = '<a>b& c\'def_-"';
|
||||
t.equal(StringUtil.replaceUnsafeChars(mix), 'ltagtbamp caposdef_-quot');
|
||||
|
||||
const dupes = '<<&_"_"_&>>';
|
||||
t.equal(StringUtil.replaceUnsafeChars(dupes), 'ltltamp_quot_quot_ampgtgt');
|
||||
|
||||
const emoji = '(>^_^)>';
|
||||
t.equal(StringUtil.replaceUnsafeChars(emoji), '(gt^_^)gt');
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue