// @flow
import { currentTheme } from '../../../utils/tests';
import {
  getTextAlign,
  getFontStyle,
  getTextDecoration,
  getFontSize,
  getFontFamily,
  getFontWeight,
} from './typography.css-rules';

describe('typography', () => {
  describe('getTextAlign', () => {
    it('returns alignment', () => {
      expect(getTextAlign({ align: 'center' })).toBe('center');
    });
  });

  describe('getFontStyle', () => {
    it('returns undefined if italics is not defined', () => {
      expect(getFontStyle({})).toBe();
    });

    it('sets italic style if italic is defined', () => {
      expect(getFontStyle({ italic: true })).toBe('italic');
    });
  });

  describe('getTextDecoration', () => {
    it('returns undefined if underlined is not defined', () => {
      expect(getTextDecoration({})).toBe();
    });

    it('sets underline style if underlined is defined', () => {
      expect(getTextDecoration({ underlined: true })).toBe('underline');
    });
  });

  describe('getTextTransform', () => {
    it('returns undefined if underlined is not defined', () => {
      expect(getTextDecoration({})).toBe();
    });

    it('sets underline style if underlined is defined', () => {
      expect(getTextDecoration({ underlined: true })).toBe('underline');
    });
  });

  describe('getFontSize', () => {
    it('defaults fontSize to be `f2`', () => {
      expect(getFontSize({ theme: currentTheme })).toBe(
        currentTheme.typescale.f2,
      );
    });
  });

  describe('getFontFamily', () => {
    it('defaults face to be sans', () => {
      expect(getFontFamily({ theme: currentTheme })).toBe(
        currentTheme.fonts.sans,
      );
    });
  });

  describe('getFontWeight', () => {
    it('returns a different weight if bold is true', () => {
      const boldWeight = getFontWeight({ bold: true });
      const regularWeight = getFontWeight({});

      expect(boldWeight).not.toBe(regularWeight);
    });
  });
});
