You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

14 lines
514 B

const utf8Array2Str = require('./index');
describe('Uint8Array convert to string', () => {
test('should equal "hello"', () => {
expect(Buffer.from(new Uint8Array(Buffer.from('hello'))).toString()).toBe('hello');
expect(utf8Array2Str(new Uint8Array(Buffer.from('hello')))).toBe('hello');
});
test('should equal "你好"', () => {
expect(Buffer.from(new Uint8Array(Buffer.from('你好'))).toString()).toBe('你好');
expect(utf8Array2Str(new Uint8Array(Buffer.from('你好')))).toBe('你好');
});
});