mirror of
https://github.com/discourse/discourse.git
synced 2025-05-31 00:27:58 +08: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');
|
||||
});
|
||||
}
|
||||
});
|
||||
|
Reference in New Issue
Block a user