2017-05-29 21:50:03 +03:00
|
|
|
import Service from 'ember-service';
|
|
|
|
import hbs from 'htmlbars-inline-precompile';
|
2016-11-24 01:50:57 +03:00
|
|
|
import {describe, it} from 'mocha';
|
2017-05-29 21:50:03 +03:00
|
|
|
import {expect} from 'chai';
|
2016-11-24 01:50:57 +03:00
|
|
|
import {setupComponentTest} from 'ember-mocha';
|
2016-01-19 17:25:36 +03:00
|
|
|
|
2016-06-11 19:52:36 +03:00
|
|
|
const featureStub = Service.extend({
|
2016-05-05 17:03:09 +03:00
|
|
|
testFlag: true
|
|
|
|
});
|
2016-01-19 17:25:36 +03:00
|
|
|
|
2016-11-24 01:50:57 +03:00
|
|
|
describe('Integration: Component: gh-feature-flag', function() {
|
|
|
|
setupComponentTest('gh-feature-flag', {
|
2016-01-19 17:25:36 +03:00
|
|
|
integration: true
|
2016-11-24 01:50:57 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
beforeEach(function () {
|
|
|
|
this.register('service:feature', featureStub);
|
|
|
|
this.inject.service('feature', {as: 'feature'});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('renders properties correctly', function () {
|
|
|
|
this.render(hbs`{{gh-feature-flag "testFlag"}}`);
|
|
|
|
expect(this.$()).to.have.length(1);
|
|
|
|
expect(this.$('label').attr('for')).to.equal(this.$('input[type="checkbox"]').attr('id'));
|
|
|
|
});
|
|
|
|
|
|
|
|
it('renders correctly when flag is set to true', function () {
|
|
|
|
this.render(hbs`{{gh-feature-flag "testFlag"}}`);
|
|
|
|
expect(this.$()).to.have.length(1);
|
|
|
|
expect(this.$('label input[type="checkbox"]').prop('checked')).to.be.true;
|
|
|
|
});
|
|
|
|
|
|
|
|
it('renders correctly when flag is set to false', function () {
|
|
|
|
this.set('feature.testFlag', false);
|
|
|
|
|
|
|
|
this.render(hbs`{{gh-feature-flag "testFlag"}}`);
|
|
|
|
expect(this.$()).to.have.length(1);
|
|
|
|
|
|
|
|
expect(this.$('label input[type="checkbox"]').prop('checked')).to.be.false;
|
|
|
|
});
|
|
|
|
|
|
|
|
it('updates to reflect changes in flag property', function () {
|
|
|
|
this.render(hbs`{{gh-feature-flag "testFlag"}}`);
|
|
|
|
expect(this.$()).to.have.length(1);
|
|
|
|
|
|
|
|
expect(this.$('label input[type="checkbox"]').prop('checked')).to.be.true;
|
|
|
|
|
|
|
|
this.$('label').click();
|
|
|
|
|
|
|
|
expect(this.$('label input[type="checkbox"]').prop('checked')).to.be.false;
|
|
|
|
});
|
|
|
|
});
|