Ghost/ghost/admin/tests/integration/components/gh-feature-flag-test.js
Kevin Ansfield a85f5fae35 Switch to eslint-plugin-ghost extending plugin:ghost/ember
no issue
- fix lint errors in lib/gh-koenig
- fix ghost:base eslint errors
- update ember plugin refs, remove ember-suave plugin refs
- remove old jshint refs
- add `lint:js` script
- switch to `eslint-plugin-ghost` extending `plugin:ghost/ember`
2018-01-12 12:17:56 +00:00

53 lines
1.7 KiB
JavaScript

import Service from '@ember/service';
import hbs from 'htmlbars-inline-precompile';
import {describe, it} from 'mocha';
import {expect} from 'chai';
import {setupComponentTest} from 'ember-mocha';
const featureStub = Service.extend({
testFlag: true
});
describe('Integration: Component: gh-feature-flag', function () {
setupComponentTest('gh-feature-flag', {
integration: true
});
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;
});
});