Update specs to be a little less brittle/flaky

Test Plan:
  - Automated tests pass

Change-Id: I182bfb60316a79543bd4e97890f846a24d70162c
Reviewed-on: https://gerrit.instructure.com/151955
Reviewed-by: Jeremy Neander <jneander@instructure.com>
Tested-by: Jenkins
Product-Review: Clay Diffrient <cdiffrient@instructure.com>
QA-Review: Clay Diffrient <cdiffrient@instructure.com>
This commit is contained in:
Clay Diffrient 2018-05-30 15:53:45 -06:00
parent 39f387fd9a
commit 0a0ae68561
4 changed files with 56 additions and 42 deletions

View File

@ -1024,21 +1024,20 @@ test('#focusAtEnd sets focus on the options menu trigger', function () {
equal(document.activeElement, this.wrapper.node.optionsMenuTrigger);
});
test('applies the "focused" class when the assignment title has focus', function() {
const link = this.wrapper.find('.assignment-name a')
link.get(0).focus()
ok(this.wrapper.hasClass('focused'))
test('applies the "focused" class when the assignment title has focus', function(assert) {
const done = assert.async();
this.wrapper.setState({ hasFocus: true }, () => {
ok(this.wrapper.hasClass('focused'));
done();
});
})
test('applies the "focused" class when the options menu has focus', function() {
const button = this.wrapper.find('.Gradebook__ColumnHeaderAction button')
button.get(0).focus()
ok(this.wrapper.hasClass('focused'))
})
test('removes the "focused" class when the header blurs', function() {
const link = this.wrapper.find('.assignment-name a')
link.get(0).focus()
link.get(0).blur()
notOk(this.wrapper.hasClass('focused'))
test('removes the "focused" class when the header blurs', function(assert) {
const done = assert.async()
this.wrapper.setState({ hasFocus: true }, () => {
this.wrapper.setState({ hasFocus: false }, () => {
notOk(this.wrapper.hasClass('focused'));
done();
});
});
})

View File

@ -288,15 +288,20 @@ test('#focusAtEnd sets focus on the options menu trigger', function () {
equal(document.activeElement, this.wrapper.node.optionsMenuTrigger);
});
test('applies the "focused" class when the options menu has focus', function() {
const button = this.wrapper.find('.Gradebook__ColumnHeaderAction button')
button.get(0).focus()
ok(this.wrapper.hasClass('focused'))
test('applies the "focused" class when the options menu has focus', function(assert) {
const done = assert.async();
this.wrapper.setState({ hasFocus: true }, () => {
ok(this.wrapper.hasClass('focused'));
done();
});
})
test('removes the "focused" class when the header blurs', function() {
const button = this.wrapper.find('.Gradebook__ColumnHeaderAction button')
button.get(0).focus()
button.get(0).blur()
notOk(this.wrapper.hasClass('focused'))
test('removes the "focused" class when the header blurs', function(assert) {
const done = assert.async()
this.wrapper.setState({ hasFocus: true }, () => {
this.wrapper.setState({ hasFocus: false }, () => {
notOk(this.wrapper.hasClass('focused'));
done();
});
});
})

View File

@ -668,15 +668,20 @@ test('#focusAtEnd sets focus on the options menu trigger', function () {
equal(document.activeElement, this.wrapper.node.optionsMenuTrigger);
});
test('applies the "focused" class when the options menu has focus', function() {
const button = this.wrapper.find('.Gradebook__ColumnHeaderAction button')
button.get(0).focus()
ok(this.wrapper.hasClass('focused'))
test('applies the "focused" class when the options menu has focus', function(assert) {
const done = assert.async();
this.wrapper.setState({ hasFocus: true }, () => {
ok(this.wrapper.hasClass('focused'));
done();
});
})
test('removes the "focused" class when the header blurs', function() {
const button = this.wrapper.find('.Gradebook__ColumnHeaderAction button')
button.get(0).focus()
button.get(0).blur()
notOk(this.wrapper.hasClass('focused'))
test('removes the "focused" class when the header blurs', function(assert) {
const done = assert.async()
this.wrapper.setState({ hasFocus: true }, () => {
this.wrapper.setState({ hasFocus: false }, () => {
notOk(this.wrapper.hasClass('focused'));
done();
});
});
})

View File

@ -472,15 +472,20 @@ test('#focusAtEnd sets focus on the options menu trigger', function () {
equal(document.activeElement, this.wrapper.node.optionsMenuTrigger);
});
test('applies the "focused" class when the options menu has focus', function() {
const button = this.wrapper.find('.Gradebook__ColumnHeaderAction button')
button.get(0).focus()
ok(this.wrapper.hasClass('focused'))
test('applies the "focused" class when the options menu has focus', function(assert) {
const done = assert.async();
this.wrapper.setState({ hasFocus: true }, () => {
ok(this.wrapper.hasClass('focused'));
done();
});
})
test('removes the "focused" class when the header blurs', function() {
const button = this.wrapper.find('.Gradebook__ColumnHeaderAction button')
button.get(0).focus()
button.get(0).blur()
notOk(this.wrapper.hasClass('focused'))
test('removes the "focused" class when the header blurs', function(assert) {
const done = assert.async()
this.wrapper.setState({ hasFocus: true }, () => {
this.wrapper.setState({ hasFocus: false }, () => {
notOk(this.wrapper.hasClass('focused'));
done();
});
});
})