quality.test.js 554 B

123456789101112131415
  1. const { quality } = require('../dist/coretypes')
  2. describe('Quality encode/decode', function () {
  3. const bookDirectory =
  4. '4627DFFCFF8B5A265EDBD8AE8C14A52325DBFEDAF4F5C32E5D06F4C3362FE1D0'
  5. const expectedQuality = '195796912.5171664'
  6. test('can decode', function () {
  7. const decimal = quality.decode(bookDirectory)
  8. expect(decimal.toString()).toBe(expectedQuality)
  9. })
  10. test('can encode', function () {
  11. const bytes = quality.encode(expectedQuality)
  12. expect(bytes.toString('hex').toUpperCase()).toBe(bookDirectory.slice(-16))
  13. })
  14. })