import {assert} from 'chai';

import path from 'node:path';

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

describe('Parse Philips DSDIFF', () => {

  const dsdiffamplePath = path.join(samplePath, 'dsdiff');

  it('parse: DSD64.dff', async () => {

    const filePath = path.join(dsdiffamplePath, 'DSD64.dff');

    const {format, common} = await mm.parseFile(filePath, {duration: false});

    // format chunk information
    assert.strictEqual(format.container, 'DSDIFF/DSD');
    assert.deepEqual(format.lossless, true);
    assert.deepEqual(format.tagTypes, ['ID3v2.3']);
    assert.deepEqual(format.numberOfChannels, 2, 'format.numberOfChannels');
    assert.deepEqual(format.bitsPerSample, 1, 'format.bitsPerSample');
    assert.deepEqual(format.sampleRate, 2822400, 'format.sampleRate [Hz]');
    assert.deepEqual(format.numberOfSamples, 300800, 'format.numberOfSamples');
    assert.deepEqual(format.duration, 300800 / 2822400, 'format.duration');
    assert.deepEqual(format.bitrate, 5644800, 'format.bitrate');
    assert.deepEqual(format.tagTypes, ['ID3v2.3'], 'TAG headers');

    // ID3v2 chunk information
    assert.strictEqual(common.artist, 'CANTUS (Tove Ramlo-Ystad) & Frode Fjellheim', 'common.artist');
    assert.strictEqual(common.title, 'Kyrie', 'common.title');
    assert.strictEqual(common.album, 'SPES', 'common.album');
    assert.deepEqual(common.genre, ['Choral'], 'common.genre');
    assert.deepEqual(common.track, {no: 4, of: 12}, 'common.track');
  });

});
