import React from 'react';
import DesignerSelectionToolbox, { isOriginallyVector, getPrintQuality } from './DesignerSelectionToolbox';
// eslint-disable-next-line no-unused-vars
import {
    CanvasProvider,
    CanvasStateProvider,
} from 'redhotmagma-graphics-editor/CanvasInterface/CanvasProvider';
import { Canvas } from 'redhotmagma-graphics-editor/CanvasAdapters/Mock';

const canvas = new Canvas();

// eslint-disable-next-line no-unused-vars
const selectionToolbox = (
    <CanvasProvider canvas={canvas}>
        <CanvasStateProvider canvas={canvas}>
            <DesignerSelectionToolbox />
        </CanvasStateProvider>
    </CanvasProvider>
);

describe('Designer/DesignerSelectionToolbox', () => {
    test('isOriginallyVector returns the correct result', () => {
        const createObject = (type, format) => ({ type, imageData: { original: { format } } });

        expect(isOriginallyVector(createObject('Image', 'eps'))).toEqual(true);
        expect(isOriginallyVector(createObject('Image', 'ept'))).toEqual(true);
        expect(isOriginallyVector(createObject('Image', 'pdf'))).toEqual(true);
        expect(isOriginallyVector(createObject('Image', 'ai'))).toEqual(true);
        expect(isOriginallyVector(createObject('Image', 'svg'))).toEqual(true);
        expect(isOriginallyVector(createObject('Image', 'jpg'))).toEqual(false);
        expect(isOriginallyVector(createObject('Image', 'jpeg'))).toEqual(false);
        expect(isOriginallyVector(createObject('Image', 'png'))).toEqual(false);
        expect(isOriginallyVector(createObject('Image', 'gif'))).toEqual(false);
        expect(isOriginallyVector(createObject('Text', 'svg'))).toEqual(false);
        expect(isOriginallyVector(null)).toEqual(false);
    });

    test('getPrintQuality returns the correct quality', () => {
        const createObject = (type, format, outputFormat, scaling) => ({
            type,
            imageData: { original: { format } },
            src: `image.${outputFormat}`,
            scaling,
        });

        expect(getPrintQuality(createObject('Image', 'jpg', 'jpg', 1))).toEqual('great');
        expect(getPrintQuality(createObject('Image', 'jpg', 'jpg', 1.5))).toEqual('ok');
        expect(getPrintQuality(createObject('Image', 'jpg', 'jpg', 3))).toEqual('poor');
        expect(getPrintQuality(createObject('Image', 'svg', 'svg', 1))).toEqual('great');
        expect(getPrintQuality(createObject('Image', 'svg', 'svg', 1.5))).toEqual('great');
        expect(getPrintQuality(createObject('Image', 'svg', 'svg', 3))).toEqual('great');
        expect(getPrintQuality(createObject('Image', 'svg', 'jpg', 3))).toEqual('great');
        expect(getPrintQuality(createObject('Image', 'jpg', 'svg', 3))).toEqual('great');
    });
});
