Files
30-seconds-of-code/test/byteSize/byteSize.test.js
Angelos Chalaris 4f7da1be9b Test migration to jest by hand
Apparently using regular expressions is way easier.
2018-06-18 15:15:56 +03:00

19 lines
463 B
JavaScript

const expect = require('expect');
const Blob = class{
constructor(s) {
return {
size: Buffer.byteLength(s.toString())
};
}
};
const byteSize = str => new Blob([str]).size;
test('byteSize is a Function', () => {
expect(byteSize).toBeInstanceOf(Function);
});
t.equal(byteSize('a'), 1, 'Works for a single letter');
t.equal(byteSize('Hello World'), 11, 'Works for a common string');
t.equal(byteSize('😀'), 4, 'Works for emoji');