Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add convinience import for strict mode #78

Merged
merged 2 commits into from
Aug 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/ember-focus-trap/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
}
},
"exports": {
".": "./dist/index.js",
"./*": "./dist/*",
"./addon-main.js": "./addon-main.js"
}
Expand Down
2 changes: 1 addition & 1 deletion packages/ember-focus-trap/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default {
plugins: [
// These are the modules that users should be able to import from your
// addon. Anything not listed here may get optimized away.
addon.publicEntrypoints(['modifiers/**/*.js']),
addon.publicEntrypoints(['index.js', 'modifiers/**/*.js']),

// These are the modules that should get reexported into the traditional
// "app" tree. Things in here should also be in publicEntrypoints above, but
Expand Down
1 change: 1 addition & 0 deletions packages/ember-focus-trap/src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default as focusTrap } from './modifiers/focus-trap.js';
26 changes: 26 additions & 0 deletions packages/test-app/tests/integration/modifiers/focus-trap-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { module, test } from 'qunit';
import { setupRenderingTest } from 'ember-qunit';
import { render, find } from '@ember/test-helpers';
import sinon from 'sinon';
import { focusTrap } from 'ember-focus-trap';
let noop = () => {
// empty
};
Expand Down Expand Up @@ -30,6 +31,31 @@ module('Integration | Modifier | focus-trap', function (hooks) {
});

module('installModifier', function () {
test('default activation (explicit usage (no global resolver))', async function (assert) {
this.setProperties({ focusTrap });
await render(
hbs`<div
data-test
{{this.focusTrap
focusTrapOptions=(hash onDeactivate=this.noop)
_createFocusTrap=this.fakeFocusTrap
}}
>
<button type="button">Some button</button>
</div>`
);
assert.equal(this.fakeFocusTrap.callCount, 1, 'should have called once');

assert.ok(
this.fakeFocusTrap.calledWithExactly(find('[data-test]'), {
onDeactivate: noop,
returnFocusOnDeactivate: true
}),
'should have called with the element and options'
);
assert.equal(this.instance.activate.callCount, 1, 'should have called');
});

test('default activation ', async function (assert) {
await render(
hbs`<div
Expand Down