import {
    findTagsInObjectURL,
    findTagsInBuffer,
    base64ToArrayBuffer,
} from '../../exif_helper';


const fixtures = {
    orientation: {
        'none': 'data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEASABIAAD/4QQuRXhpZgAASUkqAAgAAAALAAMBAwABAAAABgAAAA8BAgAIAAAAkgAAABABAgAJAAAAmgAAABoBBQABAAAApAAAABsBBQABAAAArAAAACgBAwABAAAAAgAAADEBAgAMAAAAtAAAADIBAgAUAAAAwAAAABMCAwABAAAAAQAAAGmHBAABAAAA1AAAACWIBAABAAAA7gIAALwDAABzYW1zdW5nAFNNLUc5MjBGAABIAAAAAQAAAEgAAAABAAAAR0lNUCAyLjguMTAAMjAxNjowODoxNSAwMDoyMjoxNQAZAJqCBQABAAAABgIAAJ2CBQABAAAADgIAACKIAwABAAAAAgAAACeIAwABAAAAZAAAAACQBwAEAAAAMDIyMAOQAgAUAAAAFgIAAASQAgAUAAAAKgIAAAGSCgABAAAAPgIAAAKSBQABAAAARgIAAAOSCgABAAAATgIAAASSCgABAAAAVgIAAAWSBQABAAAAXgIAAAeSAwABAAAAAgAAAAmSAwABAAAAAAAAAAqSBQABAAAAZgIAAHySBwBiAAAAbgIAAACgBwAEAAAAMDEwMAGgAwABAAAAAQAAAAKgBAABAAAAEAAAAAOgBAABAAAACQAAAAKkAwABAAAAAAAAAAOkAwABAAAAAAAAAAWkAwABAAAAHAAAAAakAwABAAAAAAAAACCkAgAeAAAA0AIAAAAAAAABAAAAMgAAABMAAAAKAAAAMjAxNjowODoxNSAwMDowNDoxNwAyMDE2OjA4OjE1IDAwOjA0OjE3ACMsAADSBwAAOTEAAJQaAAAMAQAAZAAAAAAAAAABAAAAOTEAAJQaAAArAAAACgAAAAcAAQAHAAQAAAAwMTAwAgAEAAEAAAAAIAEADAAEAAEAAAAAAAAAEAAFAAEAAABaAAAAQAAEAAEAAAAAAAAAUAAEAAEAAAABAAAAAAEDAAEAAAAAAAAAAAAAAAAAAAAAAAAAQTE2TExJQzA4U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URL', () => {
        it('should return null if the src type is not supported', (done) => {
            findTagsInObjectURL('blabla').then(tags => {
                expect(tags === null).to.equal(true);
                done();
            });
        });

        it('should fail for an invalid blob type', (done) => {
            findTagsInObjectURL('blob:balbla')
                .then(() => {
                    done(new Error('Expected promise to reject'));
                })
                .catch(err => {
                    expect(err).to.exist;
                    done();
                });
        });

        it('should extract orientation from a valid Blob URL', (done) => {
            // Create a Blob from a valid JPEG base64 fixture
            const base64 = fixtures.orientation['6'].replace(/^data:image\/jpeg;base64,/, '');
            const binary = atob(base64);
            const array = new Uint8Array(binary.length);
            for (let i = 0; i < binary.length; i++) array[i] = binary.charCodeAt(i);
            const blob = new Blob([array], { type: 'image/jpeg' });
            const url = URL.createObjectURL(blob);
            findTagsInObjectURL(url).then(tags => {
                expect(tags).to.deep.equal({ orientation: 6 });
                URL.revokeObjectURL(url);
                done();
            }).catch(err => {
                URL.revokeObjectURL(url);
                done(err);
            });
        });
    });

    describe('findTagsInBuffer', () => {
        it('should result in a rotation value of 1', () => {
            const result = findTagsInBuffer(base64ToArrayBuffer(fixtures.orientation['1']));
            expect(result).to.deep.equal({orientation: 1});
        });
        it('should result in a rotation value of 6', () => {
            const result = findTagsInBuffer(base64ToArrayBuffer(fixtures.orientation['6']));
            expect(result).to.deep.equal({orientation: 6});
        });
        it('should result in a rotation value of 3', () => {
            const result = findTagsInBuffer(base64ToArrayBuffer(fixtures.orientation['3']));
            expect(result).to.deep.equal({orientation: 3});
        });
        it('should result in a rotation value of 4', () => {
            const result = findTagsInBuffer(base64ToArrayBuffer(fixtures.orientation['8']));
            expect(result).to.deep.equal({orientation: 8});
        });
        it('should return nothing if orientation is not found', () => {
            const result = findTagsInBuffer(base64ToArrayBuffer(fixtures.orientation.none));
            expect(result).to.deep.equal({});
        });
    });
});
