{"size": 488, "ext": "js", "max_stars_repo_path": "test/units.js", "max_stars_repo_name": "PolymathWhiz/bitcoin-units", "max_stars_repo_stars_event_min_datetime": "2018-06-10T05:44:34.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-28T00:29:20.000Z", "max_issues_repo_path": "test/units.js", "max_issues_repo_name": "PolymathWhiz/bitcoin-units", "max_issues_repo_issues_event_min_datetime": "2020-04-02T18:54:40.000Z", "max_issues_repo_issues_event_max_datetime": "2020-04-02T18:54:40.000Z", "max_forks_repo_path": "test/units.js", "max_forks_repo_name": "PolymathWhiz/bitcoin-units", "max_forks_repo_forks_event_min_datetime": "2018-06-10T05:45:03.000Z", "max_forks_repo_forks_event_max_datetime": "2021-08-13T15:36:38.000Z"}
{"max_stars_count": 35, "max_issues_count": 1, "max_forks_count": 7, "avg_line_length": 23.2380952381, "max_line_length": 52, "alphanum_fraction": 0.5758196721}
const { assert } = require('chai');
const bitcoin = require('../lib/bitcoin.cjs.js');

describe('Getting bitcoin units', () => {
  it('gets units by name', () => {
    const bit = 1 / 1E6;

    assert.equal(bitcoin.getUnit('bit'), bit);
  });

  it('gets units by their alias', () => {
    const satoshi = 1 / 1E8;

    assert.equal(bitcoin.getUnit('sats'), satoshi);
  });

  it('throws an error for unknown units', () => {
    assert.throws(() => bitcoin.getUnit('unknown'));
  });
});
