UNPKG

2.04 kBJavaScriptView Raw
1'use strict';
2
3module.exports = {
4 name: require('./package').name,
5
6 options: {
7 nodeAssets: {
8 ceibo: {
9 vendor: ['index.js']
10 },
11 jquery: {
12 vendor: ['dist/jquery.js'],
13 destDir: 'ecpo-jquery'
14 }
15 }
16 },
17
18 included() {
19 this.app = this._findHost();
20
21 this.import('vendor/ceibo/index.js', { type: 'test' });
22
23 if (!this.project.findAddonByName('@ember/jquery') && !this.app.vendorFiles['jquery.js']) {
24 this.import('vendor/ecpo-jquery/dist/jquery.js', { type: 'test' });
25 this.import('vendor/shims/ecpo-jquery.js', { type: 'test' });
26 } else {
27 this.import('vendor/shims/project-jquery.js', { type: 'test' });
28 }
29
30 this._super.included.apply(this, arguments);
31 },
32
33 treeForAddonTestSupport(tree) {
34 const testSupportTree = this._super(tree);
35
36 const mergeTrees = require('broccoli-merge-trees');
37 const writeFile = require('broccoli-file-creator');
38
39 // Generate re-exports for public modules to allow
40 // import w/o "test-support/" part in the path:
41 //
42 // `import { clickable } from 'ember-cli-page-object';`
43 //
44 // instead of:
45 //
46 // `import { clickable } from 'ember-cli-page-object/test-support';`
47 //
48 // which is a default behavior in ember-cli
49 const reexportsTree = mergeTrees([
50 'index',
51 'extend',
52 'macros',
53 '-private/execution_context' // @see: https://github.com/san650/ember-cli-page-object/pull/400#issuecomment-384021927
54 ].map(publicModuleName =>
55 writeFile(
56 `/${this.moduleName()}/${publicModuleName}.js`,
57 `export * from '${this.moduleName()}/test-support/${publicModuleName}';`
58 )
59 ));
60
61 return mergeTrees([
62 testSupportTree,
63 this.preprocessJs(
64 reexportsTree, '/', this.name, { registry: this.registry, }
65 )
66 ]);
67 },
68
69 _findHost() {
70 let current = this;
71 let app;
72
73 do {
74 app = current.app || app;
75 } while (current.parent.parent && (current = current.parent));
76
77 return app;
78 }
79};