2da6673197
supersedes #6773 - update `feature` service and `gh-feature-flag` component to work synchronously rather than async - use the application route's `afterModel` hook so that settings are loaded before first load - override `session` service's `authenticate` method to load the settings after successful authentication before any other routes are processed
61 lines
1.9 KiB
JavaScript
61 lines
1.9 KiB
JavaScript
import { expect } from 'chai';
|
|
import {
|
|
describeComponent,
|
|
it
|
|
} from 'ember-mocha';
|
|
import hbs from 'htmlbars-inline-precompile';
|
|
import Ember from 'ember';
|
|
import wait from 'ember-test-helpers/wait';
|
|
|
|
const featureStub = Ember.Service.extend({
|
|
testFlag: true
|
|
});
|
|
|
|
describeComponent(
|
|
'gh-feature-flag',
|
|
'Integration: Component: gh-feature-flag',
|
|
{
|
|
integration: true
|
|
},
|
|
function() {
|
|
let server;
|
|
|
|
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;
|
|
});
|
|
}
|
|
);
|