helpers.ts 1.2 KB

12345678910111213141516171819202122232425262728293031
  1. /**
  2. * Copyright © 2016-2020 Threema GmbH (https://threema.ch/).
  3. *
  4. * This file is part of Threema Web.
  5. *
  6. * Threema Web is free software: you can redistribute it and/or modify it
  7. * under the terms of the GNU Affero General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or (at
  9. * your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful, but
  12. * WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero
  14. * General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Affero General Public License
  17. * along with Threema Web. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. import {replaceWhitespace, u8aToHex} from '../../src/helpers';
  20. describe('Helpers', () => {
  21. it('u8aToHex', function() {
  22. const arr = Uint8Array.of(1, 2, 4, 8, 254, 255);
  23. expect(u8aToHex(arr)).toEqual('01020408feff');
  24. });
  25. it('replaceWhitespace', function() {
  26. expect(replaceWhitespace(' Hello wor ld')).toEqual('&nbsp;&nbsp;Hello&nbsp;wor&nbsp;&nbsp;ld');
  27. });
  28. });