import toHHMMSS from './toHHMMSS';
import { Duration } from '../generated/google/protobuf/duration';

describe('toHHMMSS', () => {
  it('renders correctly for 0ms', () => {
    const duration: Duration = { seconds: 0, nanos: 0 };
    expect(toHHMMSS(duration)).toEqual('00:00');
  });

  it('renders correctly for 500ms', () => {
    const duration: Duration = { seconds: 0, nanos: 500_000_000 };
    expect(toHHMMSS(duration)).toEqual('00:00');
  });

  it('renders correctly for 2700ms', () => {
    const duration: Duration = { seconds: 27, nanos: 0 };
    expect(toHHMMSS(duration)).toEqual('00:27');
  });

  it('renders correctly for 61s', () => {
    const duration: Duration = { seconds: 61, nanos: 0 };
    expect(toHHMMSS(duration)).toEqual('01:01');
  });

  it('renders correctly for 1200s', () => {
    const duration: Duration = { seconds: 1200, nanos: 0 };
    expect(toHHMMSS(duration)).toEqual('20:00');
  });

  it('renders correctly for 1201s', () => {
    const duration: Duration = { seconds: 1201, nanos: 0 };
    expect(toHHMMSS(duration)).toEqual('20:01');
  });

  it('renders correctly for 1h', () => {
    const duration: Duration = { seconds: 3600, nanos: 0 };
    expect(toHHMMSS(duration)).toEqual('01:00:00');
  });

  it('renders correctly for 1h1m1s', () => {
    const duration: Duration = { seconds: 3661, nanos: 0 };
    expect(toHHMMSS(duration)).toEqual('01:01:01');
  });

  it('renders correctly for 24h1s', () => {
    const duration: Duration = { seconds: 86401, nanos: 0 };
    expect(toHHMMSS(duration)).toEqual('24:00:01');
  });
});
