// Copyright 2017-2025 @pezkuwi/types authors & contributors
// SPDX-License-Identifier: Apache-2.0

/// <reference types="@pezkuwi/dev-test/globals.d.ts" />

import { TypeRegistry } from '../create/index.js';
import { MAGIC_NUMBER, MagicNumber } from './MagicNumber.js';

describe('MagicNumber', (): void => {
  const registry = new TypeRegistry();

  it('succeeds when the magic number matches', (): void => {
    expect(
      () => new MagicNumber(registry, MAGIC_NUMBER)
    ).not.toThrow();
  });

  it('succeeds when the magic number is empty', (): void => {
    expect(
      () => new MagicNumber(registry)
    ).not.toThrow();
  });

  it('fails when the magic number mismatches', (): void => {
    expect(
      () => new MagicNumber(registry, 0x12345678)
    ).toThrow(/MagicNumber mismatch/);
  });
});
