├── .bowerrc ├── .editorconfig ├── .ember-cli ├── .gitignore ├── .jshintrc ├── .npmignore ├── .watchmanconfig ├── LICENSE.md ├── README.md ├── addon └── .gitkeep ├── app └── .gitkeep ├── bower.json ├── circle.yml ├── config ├── ember-try.js └── environment.js ├── ember-cli-build.js ├── index.js ├── package.json ├── test-support └── ember-test-component │ └── index.js ├── testem.js ├── tests ├── .jshintrc ├── dummy │ ├── app │ │ ├── app.js │ │ ├── components │ │ │ └── .gitkeep │ │ ├── controllers │ │ │ └── .gitkeep │ │ ├── helpers │ │ │ └── .gitkeep │ │ ├── index.html │ │ ├── models │ │ │ └── .gitkeep │ │ ├── resolver.js │ │ ├── router.js │ │ ├── routes │ │ │ └── .gitkeep │ │ ├── styles │ │ │ └── app.css │ │ └── templates │ │ │ └── components │ │ │ ├── .gitkeep │ │ │ ├── foo-bar.hbs │ │ │ ├── ui-child.hbs │ │ │ └── ui-parent.hbs │ ├── config │ │ └── environment.js │ └── public │ │ ├── crossdomain.xml │ │ └── robots.txt ├── helpers │ ├── destroy-app.js │ ├── module-for-acceptance.js │ ├── resolver.js │ └── start-app.js ├── index.html ├── integration │ ├── .gitkeep │ └── components │ │ └── foo-bar-test.js ├── test-helper.js └── unit │ └── .gitkeep └── vendor └── .gitkeep /.bowerrc: -------------------------------------------------------------------------------- 1 | { 2 | "directory": "bower_components", 3 | "analytics": false 4 | } 5 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig helps developers define and maintain consistent 2 | # coding styles between different editors and IDEs 3 | # editorconfig.org 4 | 5 | root = true 6 | 7 | 8 | [*] 9 | end_of_line = lf 10 | charset = utf-8 11 | trim_trailing_whitespace = true 12 | insert_final_newline = true 13 | indent_style = space 14 | indent_size = 2 15 | 16 | [*.hbs] 17 | insert_final_newline = false 18 | 19 | [*.{diff,md}] 20 | trim_trailing_whitespace = false 21 | -------------------------------------------------------------------------------- /.ember-cli: -------------------------------------------------------------------------------- 1 | { 2 | /** 3 | Ember CLI sends analytics information by default. The data is completely 4 | anonymous, but there are times when you might want to disable this behavior. 5 | 6 | Setting `disableAnalytics` to true will prevent any data from being sent. 7 | */ 8 | "disableAnalytics": false 9 | } 10 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See http://help.github.com/ignore-files/ for more about ignoring files. 2 | 3 | # compiled output 4 | /dist 5 | /tmp 6 | 7 | # dependencies 8 | /node_modules 9 | /bower_components 10 | 11 | # misc 12 | /.sass-cache 13 | /connect.lock 14 | /coverage/* 15 | /libpeerconnection.log 16 | npm-debug.log 17 | testem.log 18 | -------------------------------------------------------------------------------- /.jshintrc: -------------------------------------------------------------------------------- 1 | { 2 | "predef": [ 3 | "document", 4 | "window", 5 | "-Promise" 6 | ], 7 | "browser": true, 8 | "boss": true, 9 | "curly": true, 10 | "debug": false, 11 | "devel": true, 12 | "eqeqeq": true, 13 | "evil": true, 14 | "forin": false, 15 | "immed": false, 16 | "laxbreak": false, 17 | "newcap": true, 18 | "noarg": true, 19 | "noempty": false, 20 | "nonew": false, 21 | "nomen": false, 22 | "onevar": false, 23 | "plusplus": false, 24 | "regexp": false, 25 | "undef": true, 26 | "sub": true, 27 | "strict": false, 28 | "white": false, 29 | "eqnull": true, 30 | "esversion": 6, 31 | "unused": true 32 | } 33 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | /bower_components 2 | /config/ember-try.js 3 | /dist 4 | /tests 5 | /tmp 6 | **/.gitkeep 7 | .bowerrc 8 | .editorconfig 9 | .ember-cli 10 | .gitignore 11 | .jshintrc 12 | .watchmanconfig 13 | .travis.yml 14 | bower.json 15 | ember-cli-build.js 16 | testem.js 17 | -------------------------------------------------------------------------------- /.watchmanconfig: -------------------------------------------------------------------------------- 1 | { 2 | "ignore_dirs": ["tmp", "dist"] 3 | } 4 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ember-test-component ![Download count all time](https://img.shields.io/npm/dt/ember-test-component.svg) [![CircleCI](https://circleci.com/gh/poteto/ember-test-component.svg?style=shield)](https://circleci.com/gh/poteto/ember-test-component) [![npm version](https://badge.fury.io/js/ember-test-component.svg)](https://badge.fury.io/js/ember-test-component) [![Ember Observer Score](http://emberobserver.com/badges/ember-test-component.svg)](http://emberobserver.com/addons/ember-test-component) 2 | 3 | Test helper for using dependency injected components. Read the [blog post](https://emberway.io/component-dependency-injection-in-ember-js-a46a39a5d30a#.6do6b9t6o) for more detail on using dependency injection (DI) to reduce coupling of your components. 4 | 5 | Compatible with Ember LTS (`2.4.x`) and up only. 6 | 7 | ``` 8 | ember install ember-test-component 9 | ``` 10 | 11 | ## Dependency injection for the UI layer 12 | 13 | Let's say you have a parent component with a number of child components in its template. Using dependency injection (DI) means that we pass in the child components to the parent component as opposed to using them directly in the parent's template. For example, here is how you would pass components into your parent component: 14 | 15 | ```hbs 16 | 17 | 18 | {{edit-location 19 | ui=(hash 20 | location-map=(component "google-map") 21 | location-form=(component "edit-location-form") 22 | location-activity=(component "location-activity")) 23 | }} 24 | ``` 25 | 26 | Then, in your parent component's template: 27 | 28 | ```hbs 29 | 30 | 31 | {{ui.location-map foo="foo"}} 32 | {{ui.location-form bar="bar"}} 33 | {{ui.location-activity baz="baz"}} 34 | ``` 35 | 36 | ## Usage 37 | 38 | Now in your parent component's integration test, we can register a test component (called `test-component`) which will be used in place of our child components. 39 | 40 | First, we'll need to add a small bit of setup by importing the test helpers and setting up `beforeEach` hooks: 41 | 42 | ```js 43 | import { registerTestComponent, unregisterTestComponent } from 'my-app/tests/ember-test-component'; 44 | 45 | moduleForComponent('...', { 46 | integration: true, 47 | beforeEach() { 48 | unregisterTestComponent(this); 49 | } 50 | }); 51 | ``` 52 | 53 | This will ensure the `test-component` will not leak to other tests. Then, we can use `registerTestComponent` to make our `test-component`. 54 | 55 | ```js 56 | test('it does something', function(assert) { 57 | registerTestComponent(this); 58 | this.render(hbs` 59 | {{edit-location ui=(hash 60 | location-map=(component "test-component") 61 | location-form=(component "test-component") 62 | location-activity=(component "test-component")) 63 | }} 64 | `); 65 | // ... 66 | }); 67 | ``` 68 | 69 | Optionally, the options passed to `registerTestComponent` is an object that is the same kind of object you would pass to `Ember.Component.extend`, meaning you can make use of component hooks, computed properties and so forth. For most cases, you won't need to pass in too many things since you should not be testing a dependency in the parent component's test. Here is a simple example using inline layouts: 70 | 71 | ```js 72 | test('it does something', function(assert) { 73 | registerTestComponent(this, { 74 | foo: "i'm a dummy", 75 | layout: hbs` 76 |

{{foo}}

77 | ` 78 | }); 79 | // ... 80 | }); 81 | ``` 82 | 83 | You can even pass it a `hbs` file as a layout: 84 | 85 | ```js 86 | import layout from 'my-app/templates/components/foo-bar'; 87 | 88 | test('it does something', function(assert) { 89 | registerTestComponent(this, { 90 | layout, 91 | foo: "i'm a dummy" 92 | }); 93 | // ... 94 | }); 95 | ``` 96 | 97 | ## Installation 98 | 99 | * `git clone` this repository 100 | * `npm install` 101 | * `bower install` 102 | 103 | ## Running 104 | 105 | * `ember server` 106 | * Visit your app at http://localhost:4200. 107 | 108 | ## Running Tests 109 | 110 | * `npm test` (Runs `ember try:testall` to test your addon against multiple Ember versions) 111 | * `ember test` 112 | * `ember test --server` 113 | 114 | ## Building 115 | 116 | * `ember build` 117 | 118 | For more information on using ember-cli, visit [http://ember-cli.com/](http://ember-cli.com/). 119 | -------------------------------------------------------------------------------- /addon/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/poteto/ember-test-component/c460b8e3da24ca0f4761def2c0b498e7402526dc/addon/.gitkeep -------------------------------------------------------------------------------- /app/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/poteto/ember-test-component/c460b8e3da24ca0f4761def2c0b498e7402526dc/app/.gitkeep -------------------------------------------------------------------------------- /bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ember-test-component", 3 | "dependencies": { 4 | "ember": "~2.7.0", 5 | "ember-cli-shims": "0.1.1", 6 | "ember-qunit-notifications": "0.1.0" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /circle.yml: -------------------------------------------------------------------------------- 1 | machine: 2 | node: 3 | version: "stable" 4 | dependencies: 5 | pre: 6 | - npm install -g bower 7 | post: 8 | - bower install 9 | test: 10 | override: 11 | - npm test 12 | -------------------------------------------------------------------------------- /config/ember-try.js: -------------------------------------------------------------------------------- 1 | /*jshint node:true*/ 2 | module.exports = { 3 | scenarios: [ 4 | { 5 | name: 'ember-lts', 6 | bower: { 7 | dependencies: { 8 | 'ember': '~2.4.0' 9 | } 10 | } 11 | }, 12 | { 13 | name: 'ember-latest', 14 | bower: { 15 | dependencies: { 16 | 'ember': 'release' 17 | }, 18 | resolutions: { 19 | 'ember': 'release' 20 | } 21 | } 22 | }, 23 | { 24 | name: 'ember-beta', 25 | allowedToFail: true, 26 | bower: { 27 | dependencies: { 28 | 'ember': 'beta' 29 | }, 30 | resolutions: { 31 | 'ember': 'beta' 32 | } 33 | } 34 | }, 35 | { 36 | name: 'ember-canary', 37 | allowedToFail: true, 38 | bower: { 39 | dependencies: { 40 | 'ember': 'canary' 41 | }, 42 | resolutions: { 43 | 'ember': 'canary' 44 | } 45 | } 46 | }, 47 | { 48 | name: 'ember-alpha', 49 | allowedToFail: true, 50 | bower: { 51 | dependencies: { 52 | 'ember': 'alpha' 53 | }, 54 | resolutions: { 55 | 'ember': 'alpha' 56 | } 57 | } 58 | } 59 | ] 60 | }; 61 | -------------------------------------------------------------------------------- /config/environment.js: -------------------------------------------------------------------------------- 1 | /*jshint node:true*/ 2 | 'use strict'; 3 | 4 | module.exports = function(/* environment, appConfig */) { 5 | return { }; 6 | }; 7 | -------------------------------------------------------------------------------- /ember-cli-build.js: -------------------------------------------------------------------------------- 1 | /*jshint node:true*/ 2 | /* global require, module */ 3 | var EmberAddon = require('ember-cli/lib/broccoli/ember-addon'); 4 | 5 | module.exports = function(defaults) { 6 | var app = new EmberAddon(defaults, { 7 | // Add options here 8 | }); 9 | 10 | /* 11 | This build file specifies the options for the dummy test app of this 12 | addon, located in `/tests/dummy` 13 | This build file does *not* influence how the addon or the app using it 14 | behave. You most likely want to be modifying `./index.js` or app's build file 15 | */ 16 | 17 | return app.toTree(); 18 | }; 19 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | /* jshint node: true */ 2 | 'use strict'; 3 | 4 | module.exports = { 5 | name: 'ember-test-component' 6 | }; 7 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ember-test-component", 3 | "version": "0.2.1", 4 | "description": "Create dummy components in a test environment", 5 | "directories": { 6 | "doc": "doc", 7 | "test": "tests" 8 | }, 9 | "scripts": { 10 | "build": "ember build", 11 | "start": "ember server", 12 | "test": "ember try:each" 13 | }, 14 | "repository": "https://github.com/poteto/ember-test-component", 15 | "bugs": "https://github.com/poteto/ember-test-component/issues", 16 | "homepage": "https://github.com/poteto/ember-test-component", 17 | "engines": { 18 | "node": ">= 0.10.0" 19 | }, 20 | "author": "Lauren Tan ", 21 | "license": "MIT", 22 | "devDependencies": { 23 | "broccoli-asset-rev": "^2.4.5", 24 | "ember-ajax": "2.4.1", 25 | "ember-cli": "2.7.0", 26 | "ember-cli-app-version": "^1.0.0", 27 | "ember-cli-dependency-checker": "^1.3.0", 28 | "ember-cli-htmlbars": "^1.0.3", 29 | "ember-cli-htmlbars-inline-precompile": "^0.3.3", 30 | "ember-cli-inject-live-reload": "^1.4.0", 31 | "ember-cli-jshint": "^1.0.0", 32 | "ember-cli-qunit": "^2.2.1", 33 | "ember-cli-release": "^0.2.9", 34 | "ember-cli-sri": "^2.1.0", 35 | "ember-cli-test-loader": "^1.1.0", 36 | "ember-cli-uglify": "^1.2.0", 37 | "ember-disable-prototype-extensions": "^1.1.0", 38 | "ember-export-application-global": "^1.0.5", 39 | "ember-load-initializers": "^0.5.1", 40 | "ember-resolver": "^2.0.3", 41 | "loader.js": "^4.0.1" 42 | }, 43 | "keywords": [ 44 | "ember-addon", 45 | "dummy component", 46 | "dependency injection" 47 | ], 48 | "dependencies": { 49 | "ember-cli-babel": "^5.1.6" 50 | }, 51 | "ember-addon": { 52 | "configPath": "tests/dummy/config" 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /test-support/ember-test-component/index.js: -------------------------------------------------------------------------------- 1 | import Ember from 'ember'; 2 | 3 | const { Component, getOwner } = Ember; 4 | const assign = Ember.assign || Ember.merge; 5 | 6 | export function registerTestComponent(context, opts = {}) { 7 | let owner = context.owner || getOwner(context); 8 | let options = assign({ tagName: 'dummy' }, opts); 9 | let TestComponent = Component.extend(options); 10 | 11 | unregisterTestComponent(context); 12 | owner.register('component:test-component', TestComponent); 13 | } 14 | 15 | export function unregisterTestComponent(context) { 16 | let owner = context.owner || getOwner(context); 17 | 18 | if (owner.resolveRegistration('component:test-component')) { 19 | owner.unregister('component:test-component'); 20 | } 21 | } 22 | 23 | export default registerTestComponent; 24 | -------------------------------------------------------------------------------- /testem.js: -------------------------------------------------------------------------------- 1 | /*jshint node:true*/ 2 | module.exports = { 3 | "framework": "qunit", 4 | "test_page": "tests/index.html?hidepassed", 5 | "disable_watching": true, 6 | "launch_in_ci": [ 7 | "Chrome" 8 | ], 9 | "launch_in_dev": [ 10 | "Chrome" 11 | ] 12 | }; 13 | -------------------------------------------------------------------------------- /tests/.jshintrc: -------------------------------------------------------------------------------- 1 | { 2 | "predef": [ 3 | "document", 4 | "window", 5 | "location", 6 | "setTimeout", 7 | "$", 8 | "-Promise", 9 | "define", 10 | "console", 11 | "visit", 12 | "exists", 13 | "fillIn", 14 | "click", 15 | "keyEvent", 16 | "triggerEvent", 17 | "find", 18 | "findWithAssert", 19 | "wait", 20 | "DS", 21 | "andThen", 22 | "currentURL", 23 | "currentPath", 24 | "currentRouteName" 25 | ], 26 | "node": false, 27 | "browser": false, 28 | "boss": true, 29 | "curly": true, 30 | "debug": false, 31 | "devel": false, 32 | "eqeqeq": true, 33 | "evil": true, 34 | "forin": false, 35 | "immed": false, 36 | "laxbreak": false, 37 | "newcap": true, 38 | "noarg": true, 39 | "noempty": false, 40 | "nonew": false, 41 | "nomen": false, 42 | "onevar": false, 43 | "plusplus": false, 44 | "regexp": false, 45 | "undef": true, 46 | "sub": true, 47 | "strict": false, 48 | "white": false, 49 | "eqnull": true, 50 | "esversion": 6, 51 | "unused": true 52 | } 53 | -------------------------------------------------------------------------------- /tests/dummy/app/app.js: -------------------------------------------------------------------------------- 1 | import Ember from 'ember'; 2 | import Resolver from './resolver'; 3 | import loadInitializers from 'ember-load-initializers'; 4 | import config from './config/environment'; 5 | 6 | let App; 7 | 8 | Ember.MODEL_FACTORY_INJECTIONS = true; 9 | 10 | App = Ember.Application.extend({ 11 | modulePrefix: config.modulePrefix, 12 | podModulePrefix: config.podModulePrefix, 13 | Resolver 14 | }); 15 | 16 | loadInitializers(App, config.modulePrefix); 17 | 18 | export default App; 19 | -------------------------------------------------------------------------------- /tests/dummy/app/components/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/poteto/ember-test-component/c460b8e3da24ca0f4761def2c0b498e7402526dc/tests/dummy/app/components/.gitkeep -------------------------------------------------------------------------------- /tests/dummy/app/controllers/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/poteto/ember-test-component/c460b8e3da24ca0f4761def2c0b498e7402526dc/tests/dummy/app/controllers/.gitkeep -------------------------------------------------------------------------------- /tests/dummy/app/helpers/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/poteto/ember-test-component/c460b8e3da24ca0f4761def2c0b498e7402526dc/tests/dummy/app/helpers/.gitkeep -------------------------------------------------------------------------------- /tests/dummy/app/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Dummy 7 | 8 | 9 | 10 | {{content-for "head"}} 11 | 12 | 13 | 14 | 15 | {{content-for "head-footer"}} 16 | 17 | 18 | {{content-for "body"}} 19 | 20 | 21 | 22 | 23 | {{content-for "body-footer"}} 24 | 25 | 26 | -------------------------------------------------------------------------------- /tests/dummy/app/models/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/poteto/ember-test-component/c460b8e3da24ca0f4761def2c0b498e7402526dc/tests/dummy/app/models/.gitkeep -------------------------------------------------------------------------------- /tests/dummy/app/resolver.js: -------------------------------------------------------------------------------- 1 | import Resolver from 'ember-resolver'; 2 | 3 | export default Resolver; 4 | -------------------------------------------------------------------------------- /tests/dummy/app/router.js: -------------------------------------------------------------------------------- 1 | import Ember from 'ember'; 2 | import config from './config/environment'; 3 | 4 | const Router = Ember.Router.extend({ 5 | location: config.locationType, 6 | rootURL: config.rootURL 7 | }); 8 | 9 | Router.map(function() { 10 | }); 11 | 12 | export default Router; 13 | -------------------------------------------------------------------------------- /tests/dummy/app/routes/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/poteto/ember-test-component/c460b8e3da24ca0f4761def2c0b498e7402526dc/tests/dummy/app/routes/.gitkeep -------------------------------------------------------------------------------- /tests/dummy/app/styles/app.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/poteto/ember-test-component/c460b8e3da24ca0f4761def2c0b498e7402526dc/tests/dummy/app/styles/app.css -------------------------------------------------------------------------------- /tests/dummy/app/templates/components/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/poteto/ember-test-component/c460b8e3da24ca0f4761def2c0b498e7402526dc/tests/dummy/app/templates/components/.gitkeep -------------------------------------------------------------------------------- /tests/dummy/app/templates/components/foo-bar.hbs: -------------------------------------------------------------------------------- 1 |

{{foo}}

-------------------------------------------------------------------------------- /tests/dummy/app/templates/components/ui-child.hbs: -------------------------------------------------------------------------------- 1 | I'm a child -------------------------------------------------------------------------------- /tests/dummy/app/templates/components/ui-parent.hbs: -------------------------------------------------------------------------------- 1 | {{ui.child-component}} -------------------------------------------------------------------------------- /tests/dummy/config/environment.js: -------------------------------------------------------------------------------- 1 | /* jshint node: true */ 2 | 3 | module.exports = function(environment) { 4 | var ENV = { 5 | modulePrefix: 'dummy', 6 | environment: environment, 7 | rootURL: '/', 8 | locationType: 'auto', 9 | EmberENV: { 10 | FEATURES: { 11 | // Here you can enable experimental features on an ember canary build 12 | // e.g. 'with-controller': true 13 | } 14 | }, 15 | 16 | APP: { 17 | // Here you can pass flags/options to your application instance 18 | // when it is created 19 | } 20 | }; 21 | 22 | if (environment === 'development') { 23 | // ENV.APP.LOG_RESOLVER = true; 24 | // ENV.APP.LOG_ACTIVE_GENERATION = true; 25 | // ENV.APP.LOG_TRANSITIONS = true; 26 | // ENV.APP.LOG_TRANSITIONS_INTERNAL = true; 27 | // ENV.APP.LOG_VIEW_LOOKUPS = true; 28 | } 29 | 30 | if (environment === 'test') { 31 | // Testem prefers this... 32 | ENV.locationType = 'none'; 33 | 34 | // keep test console output quieter 35 | ENV.APP.LOG_ACTIVE_GENERATION = false; 36 | ENV.APP.LOG_VIEW_LOOKUPS = false; 37 | 38 | ENV.APP.rootElement = '#ember-testing'; 39 | } 40 | 41 | if (environment === 'production') { 42 | 43 | } 44 | 45 | return ENV; 46 | }; 47 | -------------------------------------------------------------------------------- /tests/dummy/public/crossdomain.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 15 | 16 | -------------------------------------------------------------------------------- /tests/dummy/public/robots.txt: -------------------------------------------------------------------------------- 1 | # http://www.robotstxt.org 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /tests/helpers/destroy-app.js: -------------------------------------------------------------------------------- 1 | import Ember from 'ember'; 2 | 3 | export default function destroyApp(application) { 4 | Ember.run(application, 'destroy'); 5 | } 6 | -------------------------------------------------------------------------------- /tests/helpers/module-for-acceptance.js: -------------------------------------------------------------------------------- 1 | import { module } from 'qunit'; 2 | import Ember from 'ember'; 3 | import startApp from '../helpers/start-app'; 4 | import destroyApp from '../helpers/destroy-app'; 5 | 6 | const { RSVP: { Promise } } = Ember; 7 | 8 | export default function(name, options = {}) { 9 | module(name, { 10 | beforeEach() { 11 | this.application = startApp(); 12 | 13 | if (options.beforeEach) { 14 | return options.beforeEach.apply(this, arguments); 15 | } 16 | }, 17 | 18 | afterEach() { 19 | let afterEach = options.afterEach && options.afterEach.apply(this, arguments); 20 | return Promise.resolve(afterEach).then(() => destroyApp(this.application)); 21 | } 22 | }); 23 | } 24 | -------------------------------------------------------------------------------- /tests/helpers/resolver.js: -------------------------------------------------------------------------------- 1 | import Resolver from '../../resolver'; 2 | import config from '../../config/environment'; 3 | 4 | const resolver = Resolver.create(); 5 | 6 | resolver.namespace = { 7 | modulePrefix: config.modulePrefix, 8 | podModulePrefix: config.podModulePrefix 9 | }; 10 | 11 | export default resolver; 12 | -------------------------------------------------------------------------------- /tests/helpers/start-app.js: -------------------------------------------------------------------------------- 1 | import Ember from 'ember'; 2 | import Application from '../../app'; 3 | import config from '../../config/environment'; 4 | 5 | export default function startApp(attrs) { 6 | let application; 7 | 8 | let attributes = Ember.merge({}, config.APP); 9 | attributes = Ember.merge(attributes, attrs); // use defaults, but you can override; 10 | 11 | Ember.run(() => { 12 | application = Application.create(attributes); 13 | application.setupForTesting(); 14 | application.injectTestHelpers(); 15 | }); 16 | 17 | return application; 18 | } 19 | -------------------------------------------------------------------------------- /tests/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Dummy Tests 7 | 8 | 9 | 10 | {{content-for "head"}} 11 | {{content-for "test-head"}} 12 | 13 | 14 | 15 | 16 | 17 | {{content-for "head-footer"}} 18 | {{content-for "test-head-footer"}} 19 | 20 | 21 | {{content-for "body"}} 22 | {{content-for "test-body"}} 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | {{content-for "body-footer"}} 31 | {{content-for "test-body-footer"}} 32 | 33 | 34 | -------------------------------------------------------------------------------- /tests/integration/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/poteto/ember-test-component/c460b8e3da24ca0f4761def2c0b498e7402526dc/tests/integration/.gitkeep -------------------------------------------------------------------------------- /tests/integration/components/foo-bar-test.js: -------------------------------------------------------------------------------- 1 | import { moduleForComponent, test } from 'ember-qunit'; 2 | import hbs from 'htmlbars-inline-precompile'; 3 | import { registerTestComponent, unregisterTestComponent } from 'dummy/tests/ember-test-component'; 4 | import layout from 'dummy/templates/components/foo-bar'; 5 | 6 | moduleForComponent('ui-parent', 'Integration | Component | ui parent', { 7 | integration: true, 8 | beforeEach({ test: testCtx }) { 9 | unregisterTestComponent(testCtx.testEnvironment); 10 | } 11 | }); 12 | 13 | test('it can be used with dependency injected components', function(assert) { 14 | registerTestComponent(this, { 15 | foo: "i'm a dummy", 16 | layout: hbs` 17 |

{{foo}}

18 | ` 19 | }); 20 | 21 | this.render(hbs` 22 | {{ui-parent ui=(hash 23 | child-component=(component "test-component")) 24 | }} 25 | `); 26 | assert.equal(this.$().text().trim(), "i'm a dummy"); 27 | }); 28 | 29 | test('it creates a test component with inline layout', function(assert) { 30 | registerTestComponent(this, { 31 | foo: "i'm a dummy", 32 | layout: hbs` 33 |

{{foo}}

34 | ` 35 | }); 36 | 37 | this.render(hbs`{{test-component}}`); 38 | assert.equal(this.$().text().trim(), "i'm a dummy"); 39 | }); 40 | 41 | test('it creates a test component with imported layout', function(assert) { 42 | registerTestComponent(this, { 43 | layout, 44 | foo: "i'm a dummy" 45 | }); 46 | 47 | this.render(hbs`{{test-component}}`); 48 | assert.equal(this.$().text().trim(), "i'm a dummy"); 49 | }); 50 | 51 | test('it does not leak', function(assert) { 52 | this.render(hbs`{{test-component}}`); 53 | assert.notOk(this.$('dummy').length, 'should not leak'); 54 | }); 55 | -------------------------------------------------------------------------------- /tests/test-helper.js: -------------------------------------------------------------------------------- 1 | import resolver from './helpers/resolver'; 2 | import { 3 | setResolver 4 | } from 'ember-qunit'; 5 | 6 | setResolver(resolver); 7 | -------------------------------------------------------------------------------- /tests/unit/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/poteto/ember-test-component/c460b8e3da24ca0f4761def2c0b498e7402526dc/tests/unit/.gitkeep -------------------------------------------------------------------------------- /vendor/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/poteto/ember-test-component/c460b8e3da24ca0f4761def2c0b498e7402526dc/vendor/.gitkeep --------------------------------------------------------------------------------