ts-sdk

12345678910111213141516171819202122232425
  1. import { Utils } from '../src/utils';
  2. test('utils crc32', () => {
  3. const v = Utils.crc32('/v1/session/init');
  4. expect(v).toBe(1897767088);
  5. });
  6. test('utils str2ab and ab2str', () => {
  7. expect(Utils.ab2str(Utils.str2ab('test'))).toBe('test');
  8. });
  9. test('utils encrypt and decrypt', () => {
  10. const key = 'b8ca9aa66def05ff3f24919274bb4a66';
  11. const iv = key;
  12. expect(Utils.decrypt(Utils.encrypt('test', key, iv), key, iv)).toBe('test');
  13. });
  14. test('utils binToBase64 and base64ToBin', () => {
  15. expect(Utils.binToBase64(Utils.base64ToBin('test'))).toBe('test');
  16. });
  17. test('utils stringToBin and binToString', () => {
  18. expect(Utils.binToString(Utils.stringToBin('test'))).toBe('test');
  19. });