How do I import a component from my addon into an addon dummy test?

I am writing an addon that defines a StickyHeaderListComponent

pod addon

and imports it according to the "Components" section of the addons section of the manuals .

I would like to write some tests + use a dummy app, but the dummy app doesn't have access to {{sticky-header-list}}

. How do I import it?

+3


source to share


1 answer


The folder app

is bundled into an app that consumes the addon at build time.
So the file sticky-header-list.js

should be under app/components

.
Your best bet is to write a mixin that will include all your component code inaddon/mixins

// addon/mixins/sticky-header-list.js

export default Ember.Mixin.create({
  //Put all the component code here
});

      

And the actual component will be



// app/components/sticky-header-list.js

import StickyHeaderListMixin from '<your-addon-name>/mixins/sticky-header-list';
export default Ember.Component.extend(StickyHeaderListMixin);

      

Thus, the developer who installs your addon can choose to use a mixin since the component code is not available at dev time.
The mixin will be imported along the way <your-addon-name>/mixins/sticky-header-list.js

.
You can see an example in the ember-cli-lightbox tab .

+3


source







All Articles