import commonModule from '../';

describe('wsProgressCheckmark directive', () => {
  let outerScope;
  let isolatedScope;
  let element;

  beforeEach(angular.mock.module(commonModule));

  function injectElement(elementHtml) {
    beforeEach(angular.mock.inject(($rootScope, $compile) => {
      outerScope = $rootScope.$new();
      element = angular.element(elementHtml);
      $compile(element)(outerScope);
      outerScope.$digest();
      isolatedScope = element.isolateScope();
    }));
  }

  describe('with progress complete', () => {
    injectElement('<ws-progress-checkmark total-steps="3" completed-steps="3"/>');

    it('shows all progress is complete', () => {
      expect(isolatedScope.progressCompleted()).toEqual(true);
    });
  });

  describe('with progress more than complete', () => {
    injectElement('<ws-progress-checkmark total-steps="3" completed-steps="100"/>');

    it('shows all progress is complete', () => {
      expect(isolatedScope.progressCompleted()).toEqual(true);
    });
  });

  describe('with total steps not greater than zero', () => {
    injectElement('<ws-progress-checkmark total-steps="0" completed-steps="100"/>');

    it('shows nothing', () => {
      expect(isolatedScope.progressCompleted()).toEqual(undefined);
    });
  });

  describe('with progress incomplete', () => {
    injectElement('<ws-progress-checkmark total-steps="3" completed-steps="1"/>');

    it('shows all progress is not complete', () => {
      expect(isolatedScope.progressCompleted()).toEqual(false);
    });
  });
});
