import {expect} from 'chai'
import chai from 'chai'
import spies from 'chai-spies'

import {
  createAndMountComponent, destroyComponent, onGwtReady,
  onNextTick
} from '../../vue-gwt-tests-utils'

describe('@PropValidator', () => {
  let component;

  beforeEach(() => onGwtReady().then(() => {
    chai.use(spies);
    chai.spy.on(console, 'error');

    component = createAndMountComponent(
        'com.axellience.vuegwt.tests.client.components.basic.propvalidator.PropValidatorParentTestComponent');
  }));

  afterEach(() => {
    chai.spy.restore(console);
    destroyComponent(component);
  });

  it('should not fire an error if the value is correct', () => {
    component.validatedPropParent = 6;
    return onNextTick(() => {
      expect(console.error).to.not.have.been.called();
    });
  });

  it('should fire an error if the value is incorrect', () => {
    component.validatedPropParent = 106;
    return onNextTick(() => {
      expect(console.error).to.have.been.called.once;
    });
  });
});
import {expect} from 'chai'
import chai from 'chai'
import spies from 'chai-spies'

import {
  createAndMountComponent, destroyComponent, onGwtReady,
  onNextTick
} from '../../vue-gwt-tests-utils'

describe('@PropValidator', () => {
  let component;

  beforeEach(() => onGwtReady().then(() => {
    chai.use(spies);
    chai.spy.on(console, 'error');

    component = createAndMountComponent(
        'com.axellience.vuegwt.tests.client.components.basic.propvalidator.PropValidatorParentTestComponent');
  }));

  afterEach(() => {
    chai.spy.restore(console);
    destroyComponent(component);
  });

  it('should not fire an error if the value is correct', () => {
    component.validatedPropParent = 6;
    return onNextTick(() => {
      expect(console.error).to.not.have.been.called();
    });
  });

  it('should fire an error if the value is incorrect in dev mode', () => {
    if (Vue.config.productionTip === true) {
      component.validatedPropParent = 106;
      return onNextTick(() => {
        expect(console.error).to.have.been.called.once;
      });
    }
  });

  it('should not fire an error if the value is incorrect in production mode', () => {
    if (Vue.config.productionTip === false) {
      component.validatedPropParent = 106;
      return onNextTick(() => {
        expect(console.error).to.not.have.been.called();
      });
    }
  });
});
Fix PropValidator test to work with Vue in production mode
Fix PropValidator test to work with Vue in production mode

PropValidator are only used in dev mode so the test should be ignored
when running Vue in production mode.
