mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
Upgrade ember qunit, create new interface for testing components
This commit is contained in:
@@ -1,19 +1,17 @@
|
||||
import componentTest from 'helpers/component-test';
|
||||
|
||||
moduleForComponent('ace-editor', {integration: true});
|
||||
|
||||
test('css editor', function(assert) {
|
||||
andThen(() => {
|
||||
this.render('{{ace-editor mode="css"}}');
|
||||
});
|
||||
andThen(() => {
|
||||
componentTest('css editor', {
|
||||
template: '{{ace-editor mode="css"}}',
|
||||
test(assert) {
|
||||
assert.ok(this.$('.ace_editor').length, 'it renders the ace editor');
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
test('html editor', function(assert) {
|
||||
andThen(() => {
|
||||
this.render('{{ace-editor mode="html"}}');
|
||||
});
|
||||
andThen(() => {
|
||||
componentTest('html editor', {
|
||||
template: '{{ace-editor mode="html"}}',
|
||||
test(assert) {
|
||||
assert.ok(this.$('.ace_editor').length, 'it renders the ace editor');
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
14
test/javascripts/components/post-menu-test.js.es6
Normal file
14
test/javascripts/components/post-menu-test.js.es6
Normal file
@@ -0,0 +1,14 @@
|
||||
import componentTest from 'helpers/component-test';
|
||||
|
||||
moduleForComponent('post-menu', {integration: true});
|
||||
|
||||
componentTest('render buttons', {
|
||||
template: "{{post-menu post=post}}",
|
||||
setup(store) {
|
||||
const topic = store.createRecord('topic', {id: 123});
|
||||
this.set('post', store.createRecord('post', {id: 1, post_number: 1, topic}));
|
||||
},
|
||||
test(assert) {
|
||||
assert.ok(this.$('.post-menu-area').length, 'it renders a post menu');
|
||||
}
|
||||
});
|
||||
@@ -1,31 +1,30 @@
|
||||
import componentTest from 'helpers/component-test';
|
||||
moduleForComponent('value-list', {integration: true});
|
||||
|
||||
test('functionality', function(assert) {
|
||||
andThen(() => {
|
||||
this.render('{{value-list value=values}}');
|
||||
});
|
||||
componentTest('functionality', {
|
||||
template: '{{value-list value=values}}',
|
||||
test: function(assert) {
|
||||
andThen(() => {
|
||||
assert.ok(this.$('.values .value').length === 0, 'it has no values');
|
||||
assert.ok(this.$('input').length, 'it renders the input');
|
||||
assert.ok(this.$('.btn-primary[disabled]').length, 'it is disabled with no value');
|
||||
});
|
||||
|
||||
andThen(() => {
|
||||
assert.ok(this.$('.values .value').length === 0, 'it has no values');
|
||||
assert.ok(this.$('input').length, 'it renders the input');
|
||||
assert.ok(this.$('.btn-primary[disabled]').length, 'it is disabled with no value');
|
||||
});
|
||||
fillIn('input', 'eviltrout');
|
||||
andThen(() => {
|
||||
assert.ok(!this.$('.btn-primary[disabled]').length, "it isn't disabled anymore");
|
||||
});
|
||||
|
||||
fillIn('input', 'eviltrout');
|
||||
andThen(() => {
|
||||
assert.ok(!this.$('.btn-primary[disabled]').length, "it isn't disabled anymore");
|
||||
});
|
||||
|
||||
click('.btn-primary');
|
||||
andThen(() => {
|
||||
assert.ok(this.$('.values .value').length === 1, 'it adds the value');
|
||||
assert.ok(this.$('input').val() === '', 'it clears the input');
|
||||
assert.ok(this.$('.btn-primary[disabled]').length, "it is disabled again");
|
||||
});
|
||||
|
||||
click('.value .btn-small');
|
||||
andThen(() => {
|
||||
assert.ok(this.$('.values .value').length === 0, 'it removes the value');
|
||||
});
|
||||
click('.btn-primary');
|
||||
andThen(() => {
|
||||
assert.ok(this.$('.values .value').length === 1, 'it adds the value');
|
||||
assert.ok(this.$('input').val() === '', 'it clears the input');
|
||||
assert.ok(this.$('.btn-primary[disabled]').length, "it is disabled again");
|
||||
});
|
||||
|
||||
click('.value .btn-small');
|
||||
andThen(() => {
|
||||
assert.ok(this.$('.values .value').length === 0, 'it removes the value');
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
22
test/javascripts/helpers/component-test.js.es6
Normal file
22
test/javascripts/helpers/component-test.js.es6
Normal file
@@ -0,0 +1,22 @@
|
||||
import createStore from 'helpers/create-store';
|
||||
|
||||
export default function(name, opts) {
|
||||
opts = opts || {};
|
||||
|
||||
test(name, function(assert) {
|
||||
if (opts.setup) {
|
||||
const store = createStore();
|
||||
opts.setup.call(this, store);
|
||||
}
|
||||
this.container.register('site-settings:main', Discourse.SiteSettings, { instantiate: false });
|
||||
this.container.injection('component', 'siteSettings', 'site-settings:main');
|
||||
|
||||
andThen(() => {
|
||||
this.render(opts.template);
|
||||
});
|
||||
|
||||
andThen(() => {
|
||||
opts.test.call(this, assert);
|
||||
});
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user