'use strict';

import { getDefaultFont } from '../Selectors';

describe('Reducers/Fonts/Selectors', () => {
    test('getDefaultFont returns the correct font object (isDefault is true)', () => {
        const state1 = {
            fonts: [
                {
                    name: 'Calibri',
                    family: 'Calibri',
                    isDefault: false,
                },
                {
                    name: 'OpenSans',
                    family: 'OpenSans',
                    isDefault: false,
                },
                {
                    name: 'TimesNewRoman',
                    family: 'TimesNewRoman',
                    isDefault: true,
                },
            ],
        };
        expect(getDefaultFont(state1)).toEqual({
            name: 'TimesNewRoman',
            family: 'TimesNewRoman',
            isDefault: true,
        });
    });

    test('getDefaultFont returns the first font object if no default is set', () => {
        const state1 = {
            fonts: [
                {
                    name: 'Calibri',
                    family: 'Calibri',
                    isDefault: false,
                },
                {
                    name: 'OpenSans',
                    family: 'OpenSans',
                    isDefault: false,
                },
                {
                    name: 'OpenSans',
                    family: 'OpenSans',
                    isDefault: false,
                },
            ],
        };
        expect(getDefaultFont(state1)).toEqual({
            name: 'Calibri',
            family: 'Calibri',
            isDefault: false,
        });
    });
});
