import { iswcError, titleError, alternateError } from '../errors';

describe('NewSong errors', () => {
    it('iswc error format', () => {
        expect(iswcError('cow')).toEqual(
            'This is not the correct format for an ISWC'
        );
        expect(iswcError('T123a1231233')).toEqual(
            'This is not the correct format for an ISWC'
        );
    });

    it('has good iswc', () => {
        expect(iswcError('')).toEqual(undefined);
        expect(iswcError('T123.123.123.3')).toEqual(undefined);
        expect(iswcError('T-123-123.123-3')).toEqual(undefined);
        expect(iswcError('T-034.524.680-1')).toEqual(undefined);
        expect(iswcError('T-000.000.001-0')).toEqual(undefined);
    });

    it('has bad iswc check code', () => {
        expect(iswcError('T-034.524.680-2')).toEqual(
            'The check digit is wrong'
        );
        expect(iswcError('T-000.000.001-1')).toEqual(
            'The check digit is wrong'
        );
    });

    it('has too long title', () => {
        expect(titleError('#'.repeat(10001))).toEqual('This value is too long');
    });

    it('has too long alternate title', () => {
        expect(alternateError('#'.repeat(10001))).toEqual(
            'This value is too long'
        );
    });
});
