|
1 | 1 | import { test, module } from 'qunit'; |
2 | 2 | import { setupTest } from 'ember-qunit'; |
3 | 3 | import require from 'require'; |
| 4 | +import { create } from 'ember-cli-page-object'; |
4 | 5 |
|
5 | 6 | if (require.has('@ember/test-helpers')) { |
6 | 7 | module('Unit | supports rfc268', function(hooks) { |
| 8 | + function getExecutionContext(pageObject) { |
| 9 | + window.require.unsee('ember-cli-page-object/test-support/-private/execution_context'); |
| 10 | + return require('ember-cli-page-object/test-support/-private/execution_context').getExecutionContext(pageObject); |
| 11 | + } |
| 12 | + |
7 | 13 | function supportsRfc268() { |
8 | 14 | window.require.unsee('ember-cli-page-object/test-support/-private/execution_context'); |
9 | 15 | return require('ember-cli-page-object/test-support/-private/execution_context').supportsRfc268(); |
@@ -41,8 +47,13 @@ if (require.has('@ember/test-helpers')) { |
41 | 47 | }); |
42 | 48 |
|
43 | 49 | module('without context', function() { |
44 | | - test('works', function(assert) { |
45 | | - assert.notOk(supportsRfc268()); |
| 50 | + test('throws', function(assert) { |
| 51 | + assert.throws( |
| 52 | + () => getExecutionContext(create()), |
| 53 | + new Error(`Looks like you attempt to access page object property outside of test context. |
| 54 | +If that's not the case, please make sure you use the latest version of "@ember/test-helpers".`), |
| 55 | + 'Throws with a correct message' |
| 56 | + ); |
46 | 57 | }); |
47 | 58 | }); |
48 | 59 | }); |
|
0 commit comments