open-vault/ui/tests/integration/components/auth-config-form/options-test.js

56 lines
1.5 KiB
JavaScript
Raw Normal View History

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';
import hbs from 'htmlbars-inline-precompile';
import sinon from 'sinon';
2019-02-14 18:52:34 +00:00
import Service from '@ember/service';
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();
},
});
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');
});
test('it submits data correctly', async function(assert) {
let model = EmberObject.create({
tune() {
return resolve();
},
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);
});
});
});