util.test.js 598 B

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