"use strict";

var _ = require(".");

// Copyright 2017-2020 @polkadot/util authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
describe('hexFixLength', () => {
  it('returns bitLength === -1 as-is', () => {
    expect((0, _.hexFixLength)('0x12345678')).toEqual('0x12345678');
  });
  it('returns bitLength === -1 as-is (adding missing 0)', () => {
    expect((0, _.hexFixLength)('0x1234567')).toEqual('0x01234567');
  });
  it('does not change when bitlength === length', () => {
    expect((0, _.hexFixLength)('0x12345678', 32)).toEqual('0x12345678');
  });
  it('trims values when bitLength > length', () => {
    expect((0, _.hexFixLength)('0x12345678', 16)).toEqual('0x5678');
  });
  it('returns as-is when bitLength < length', () => {
    expect((0, _.hexFixLength)('0x1234', 32)).toEqual('0x1234');
  });
  it('adds zeros when bitLength < length (withPadded)', () => {
    expect((0, _.hexFixLength)('0x1234', 32, true)).toEqual('0x00001234');
  });
});