2018-09-25 16:28:26 +00:00
|
|
|
import { resolve } from 'rsvp';
|
|
|
|
import EmberObject from '@ember/object';
|
|
|
|
import { module, test } from 'qunit';
|
|
|
|
import { setupRenderingTest } from 'ember-qunit';
|
|
|
|
import { render, settled } from '@ember/test-helpers';
|
2018-04-23 20:32:43 +00:00
|
|
|
import hbs from 'htmlbars-inline-precompile';
|
|
|
|
import sinon from 'sinon';
|
2019-02-14 18:52:34 +00:00
|
|
|
import Service from '@ember/service';
|
2018-04-23 20:32:43 +00:00
|
|
|
|
|
|
|
import { create } from 'ember-cli-page-object';
|
|
|
|
import authConfigForm from 'vault/tests/pages/components/auth-config-form/options';
|
|
|
|
|
|
|
|
const component = create(authConfigForm);
|
2019-02-14 18:52:34 +00:00
|
|
|
const routerService = Service.extend({
|
|
|
|
transitionTo() {
|
|
|
|
return {
|
|
|
|
followRedirects() {
|
|
|
|
return resolve();
|
|
|
|
},
|
|
|
|
};
|
|
|
|
},
|
|
|
|
replaceWith() {
|
|
|
|
return resolve();
|
|
|
|
},
|
|
|
|
});
|
2018-04-23 20:32:43 +00:00
|
|
|
|
2018-09-25 16:28:26 +00:00
|
|
|
module('Integration | Component | auth-config-form options', function(hooks) {
|
|
|
|
setupRenderingTest(hooks);
|
|
|
|
|
|
|
|
hooks.beforeEach(function() {
|
|
|
|
this.owner.lookup('service:flash-messages').registerTypes(['success']);
|
2019-02-14 18:52:34 +00:00
|
|
|
this.owner.register('service:router', routerService);
|
|
|
|
this.router = this.owner.lookup('service:router');
|
2018-09-25 16:28:26 +00:00
|
|
|
});
|
2018-04-23 20:32:43 +00:00
|
|
|
|
2018-09-25 16:28:26 +00:00
|
|
|
test('it submits data correctly', async function(assert) {
|
|
|
|
let model = EmberObject.create({
|
|
|
|
tune() {
|
|
|
|
return resolve();
|
2018-04-23 20:32:43 +00:00
|
|
|
},
|
2018-09-25 16:28:26 +00:00
|
|
|
config: {
|
|
|
|
serialize() {
|
|
|
|
return {};
|
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|
|
|
|
sinon.spy(model.config, 'serialize');
|
|
|
|
this.set('model', model);
|
|
|
|
await render(hbs`{{auth-config-form/options model=model}}`);
|
|
|
|
component.save();
|
|
|
|
return settled().then(() => {
|
|
|
|
assert.ok(model.config.serialize.calledOnce);
|
|
|
|
});
|
2018-04-23 20:32:43 +00:00
|
|
|
});
|
|
|
|
});
|