Created
November 11, 2015 00:01
-
-
Save gogogarrett/949e758add93994eda54 to your computer and use it in GitHub Desktop.
We are loading async content and embedding a canvas element when the component is `didInsertElement`d. We created this test waiter to make sure the canvas element is on the page and ready to go (and everything works!), but if we run more than one test at a time, it fails..!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
import { module, test } from 'qunit'; | |
import startApp from '../helpers/start-app'; | |
import StudentProgress from "../helpers/student-progress"; | |
var application = null; | |
module('Acceptance: ArcadeAuthorization', { | |
beforeEach () { | |
application = startApp(); | |
StudentProgress.setupStudent(); // setups some mirage user objects | |
return; | |
}, | |
afterEach () { | |
Ember.run(application, 'destroy'); | |
} | |
}); | |
// #arcade/index | |
test('arcade/index', function (assert) { | |
visit('/arcade'); | |
andThen(function() { | |
assert.equal(currentURL(), '/arcade', "takes you to the main arcade page"); | |
assert.equal(Ember.$("canvas").data('loaded'), true, "canvas is loaded"); | |
}); | |
}); | |
// #arcade/game/:arcade_wheres_my_shadow | |
test('arcade/game/arcade_wheres_my_shadow', function (assert) { | |
visit('/arcade/game/arcade_wheres_my_shadow'); | |
andThen(function() { | |
assert.equal(currentURL(), '/arcade', "takes you to the lobby if token is not set"); | |
assert.equal(Ember.$("canvas").data('loaded'), true, "canvas is loaded"); | |
}); | |
}); | |
test('arcade/index - clicking around', function(assert) { | |
visit('/arcade'); | |
andThen(function() { | |
assert.equal(currentURL(), '/arcade', "takes you to the main arcade page"); | |
assert.equal(Ember.$("canvas").data('loaded'), true, "canvas is loaded"); | |
}); | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
function interval () { | |
let hasCanvas = Ember.$("canvas").size() === 1, | |
canvasLoaded = Ember.$('canvas').data('loaded'); | |
if ( hasCanvas && canvasLoaded ) { | |
Ember.Test.unregisterWaiter(interval); | |
return true; | |
} | |
} | |
Ember.Test.registerWaiter(interval); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment