import {assert} from 'chai';
import path from 'node:path';

import * as mm from '../lib/index.js';
import { samplePath } from './util.js';

const t = assert;

it("should be able to read id3v2 files with extended headers", () => {

  const filename = 'id3v2-xheader.mp3';
  const filePath = path.join(samplePath, filename);

  return mm.parseFile(filePath, {duration: true}).then(metadata => {
    t.strictEqual(metadata.format.numberOfSamples, 10944, 'format.numberOfSamples');
    t.strictEqual(metadata.format.sampleRate, 22050, 'format.sampleRate');
    t.strictEqual(metadata.format.duration, 10944 / metadata.format.sampleRate, 'format.duration');

    t.strictEqual(metadata.common.title, 'title', 'common.title');
    t.deepEqual(metadata.common.track, {no: null, of: null}, 'common.track');
    t.deepEqual(metadata.common.disk, {no: null, of: null}, 'common.disk');
  });

});
