// @flow
import { getStackedRules, getStackedDisplay } from './stacking.css-rules';

describe('stacking', () => {
  describe('getStackedRules', () => {
    it('does not produce rules if not stacked', () => {
      const rules = getStackedRules({});
      expect(rules).toEqual({});
    });

    it('sets flex direction based on how it is stacked', () => {
      const rules = getStackedRules({ stacked: 'column' });
      expect(rules).toEqual(
        expect.objectContaining({
          flexDirection: 'column',
        }),
      );
    });

    describe('justify', () => {
      it('sets default justify', () => {
        const rules = getStackedRules({ stacked: 'row' });
        expect(rules).toEqual(
          expect.objectContaining({
            justifyContent: 'flex-start',
          }),
        );
      });

      it('sets `justifyContent` based on justify value', () => {
        const rules = getStackedRules({ stacked: 'row', justify: 'end' });
        expect(rules).toEqual(
          expect.objectContaining({
            justifyContent: 'flex-end',
          }),
        );
      });
    });

    describe('align', () => {
      it('sets default align', () => {
        const rules = getStackedRules({ stacked: 'row' });
        expect(rules).toEqual(
          expect.objectContaining({
            alignItems: 'stretch',
          }),
        );
      });

      it('sets `alignItems` based on align value', () => {
        const rules = getStackedRules({ stacked: 'row', align: 'end' });
        expect(rules).toEqual(
          expect.objectContaining({
            alignItems: 'flex-end',
          }),
        );
      });
    });
  });

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

    it('returns flex is stacked is defined', () => {
      expect(getStackedDisplay({ stacked: 'row' })).toBe('flex');
    });
  });
});
