import framesToDuration from './framesToDuration';

describe('framesToDuration', () => {
  it('returns the expected result for 0 frames at 44100hz', () => {
    expect(framesToDuration(0, 44100)).toEqual({ seconds: 0, nanos: 0 });
  });

  it('returns the expected result for 44100 frames at 44100hz', () => {
    expect(framesToDuration(44100, 44100)).toEqual({ seconds: 1, nanos: 0 });
  });

  it('returns the expected result for 88200 frames at 44100hz', () => {
    expect(framesToDuration(88200, 44100)).toEqual({ seconds: 2, nanos: 0 });
  });

  it('returns the expected result for 88201 frames at 44100hz', () => {
    expect(framesToDuration(88201, 44100)).toEqual({
      seconds: 2,
      nanos: 22675,
    });
  });

  it('returns the expected result for 110250 frames at 44100hz', () => {
    expect(framesToDuration(110250, 44100)).toEqual({
      seconds: 2,
      nanos: 500_000_000,
    });
  });
});
