// @flow
import { currentTheme } from '../../../../utils/tests';
import {
  getBackgroundColor,
  getBarColor,
  getBarWidth,
} from './progress-bar.css-rules';

describe('ProgressBar', () => {
  describe('css-rules', () => {
    describe('getBackgroundColor', () => {
      it('returns a valid color', () => {
        expect(getBackgroundColor({ theme: currentTheme })).toBeHexCode();
      });
    });

    describe('getBarColor', () => {
      it('returns a valid color', () => {
        expect(
          getBarColor({
            theme: currentTheme,
            totalSteps: 10,
            currentStep: 5,
            error: true,
          }),
        ).toBeHexCode();
      });
    });

    describe('getBarWidth', () => {
      it('returns a percentage depending on current and total steps', () => {
        const width = getBarWidth({ totalSteps: 10, currentStep: 4 });
        expect(width).toBe('40%');
      });

      it('returns a larger percentage if quickProgress is true', () => {
        const width = getBarWidth({
          totalSteps: 10,
          currentStep: 4,
          quickProgress: true,
        });
        expect(width).toBe('64%');
      });
    });
  });
});
