util.test.js 572 B

1234567891011121314151617181920212223
  1. 'use strict'
  2. const test = require('tape')
  3. const {
  4. stringArrayToHexStripped
  5. } = require('../lib/utils')
  6. test('stringArrayToHexStripped', (t) => {
  7. const testCases = [
  8. [[['0', '0', '0', '0']], ''],
  9. [[['0', '0', '0', '0'], false], ''],
  10. [[['0', '0', '0', '0'], true], '0'],
  11. [[['0', '1', '0', '0'], false], '100'],
  12. [[['1', '0', '0', '0'], false], '1000'],
  13. [[['1', '0', '0', '0'], true], '1000']
  14. ]
  15. t.plan(testCases.length)
  16. testCases.forEach(([input, expected]) => {
  17. t.same(stringArrayToHexStripped(input[0], input[1]), expected)
  18. })
  19. })