forked from adopted-ember-addons/ember-collection
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fallback to setTimeout if requestAnimationFrame is not present
This is mostly to allow tests to run in PhantomJS without requring a 'requestAnimationFrame' pollyfill. Closes adopted-ember-addons#43.
- Loading branch information
Showing
4 changed files
with
56 additions
and
8 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import Ember from 'ember'; | ||
import { test, moduleForComponent } from 'ember-qunit'; | ||
import wait from 'ember-test-helpers/wait'; | ||
import { generateContent, sortItemsByPosition } from '../helpers/helpers'; | ||
import template from '../templates/fixed-grid'; | ||
|
||
moduleForComponent('ember-collection', 'raf', { | ||
integration: true, | ||
}); | ||
|
||
test('works without requestAnimationFrame', function(assert) { | ||
var originalRaf = window.requestAnimationFrame; | ||
window.requestAnimationFrame = undefined; | ||
|
||
var width = 150, height = 500, itemWidth = 50, itemHeight = 50; | ||
var offsetY = 100; | ||
var content = generateContent(5); | ||
|
||
this.setProperties({ width, height, itemWidth, itemHeight, content, offsetY }); | ||
this.render(template); | ||
var positionSorted = sortItemsByPosition(this); | ||
|
||
assert.equal( | ||
Ember.$(positionSorted[0]).text().trim(), | ||
"Item 1", "We rendered without requestAnimationFrame" | ||
); | ||
|
||
wait(). | ||
then(function() { | ||
window.requestAnimationFrame = originalRaf; | ||
}); | ||
}); |
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