-
-
Notifications
You must be signed in to change notification settings - Fork 259
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #309 from bendemboski/get-root-element
Make getRootElement() public
- Loading branch information
Showing
3 changed files
with
40 additions
and
1 deletion.
There are no files selected for viewing
4 changes: 3 additions & 1 deletion
4
addon-test-support/@ember/test-helpers/dom/get-root-element.js
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,36 @@ | ||
import { module, test } from 'qunit'; | ||
import { getRootElement, setupContext, teardownContext } from '@ember/test-helpers'; | ||
import hasEmberVersion from 'ember-test-helpers/has-ember-version'; | ||
|
||
module('DOM Helper: getRootElement', function(hooks) { | ||
if (!hasEmberVersion(2, 4)) { | ||
return; | ||
} | ||
|
||
let context; | ||
|
||
hooks.beforeEach(function() { | ||
context = {}; | ||
}); | ||
|
||
hooks.afterEach(async function() { | ||
if (context.owner) { | ||
await teardownContext(context); | ||
} | ||
|
||
document.getElementById('ember-testing').innerHTML = ''; | ||
}); | ||
|
||
test('works with context set', async function(assert) { | ||
await setupContext(context); | ||
|
||
let fixture = document.querySelector('#ember-testing'); | ||
assert.equal(getRootElement(), fixture); | ||
}); | ||
|
||
test('throws without context set', function(assert) { | ||
assert.throws(() => { | ||
getRootElement(); | ||
}, /Must setup rendering context before attempting to interact with elements/); | ||
}); | ||
}); |