import ScreenSizeDetection from './ScreenSizeDetection';

describe('ScreenSizeDetection', () => {

  let $window;

  beforeEach(
    inject(function( _$window_) {
      $window = _$window_;
    })
  );

  it('Should return an BehaviorSubject', () => {
    let subject = ScreenSizeDetection.get();
    expect(subject.constructor.name).toBe('BehaviorSubject');
  });

  it('The BehaviorSubject should return the correct string for the screensize', (done) => {
    let currentExpectation;

    ScreenSizeDetection.get().subscribe(screenSize => {
      if (currentExpectation) {
        expect(screenSize).toBe(currentExpectation);
        if (screenSize === 'xl') {
          done();
        }
      }
    });

    let map = {
      'xs': 500,
      'sm': 600,
      'md': 800,
      'lg': 1000,
      'xl': 1400
    };
    for (let step of Object.keys(map)) {
      currentExpectation = step;
      ScreenSizeDetection.mocksize = map[step];
      ScreenSizeDetection.resizeHandler();
    }

  });

});
