Skip to content

Commit

Permalink
Merge pull request #78 from NullVoxPopuli/resolve-77
Browse files Browse the repository at this point in the history
Add convinience import for strict mode
  • Loading branch information
josemarluedke authored Aug 17, 2023
2 parents 81b2c1c + d51c9f7 commit cf0f73c
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 1 deletion.
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

0 comments on commit cf0f73c

Please sign in to comment.