Skip to content

Commit

Permalink
Merge pull request #4 from simplabs/add-tests
Browse files Browse the repository at this point in the history
Add tests
  • Loading branch information
marcoow committed Mar 2, 2016
2 parents 040fc26 + 1684462 commit 7c917ff
Show file tree
Hide file tree
Showing 27 changed files with 389 additions and 47 deletions.
14 changes: 2 additions & 12 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,6 @@ cache:
directories:
- node_modules

env:
- EMBER_TRY_SCENARIO=default
- EMBER_TRY_SCENARIO=ember-release
- EMBER_TRY_SCENARIO=ember-beta
- EMBER_TRY_SCENARIO=ember-canary

matrix:
fast_finish: true
allow_failures:
- env: EMBER_TRY_SCENARIO=ember-canary

before_install:
- export PATH=/usr/local/phantomjs-2.0.0/bin:$PATH
- "npm config set spin false"
Expand All @@ -31,7 +20,8 @@ install:
- bower install

script:
- ember try $EMBER_TRY_SCENARIO test
- npm run-script test
- npm run-script jshint

notifications:
email: false
Expand Down
45 changes: 45 additions & 0 deletions config/ember-try.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*jshint node:true*/
module.exports = {
scenarios: [
{
name: 'default',
dependencies: { }
},
{
name: 'ember-1-13',
dependencies: {
'ember': 'components/ember#1.13'
},
resolutions: {
'ember': '1.13'
}
},
{
name: 'ember-release',
dependencies: {
'ember': 'components/ember#release'
},
resolutions: {
'ember': 'release'
}
},
{
name: 'ember-beta',
dependencies: {
'ember': 'components/ember#beta'
},
resolutions: {
'ember': 'beta'
}
},
{
name: 'ember-canary',
dependencies: {
'ember': 'components/ember#canary'
},
resolutions: {
'ember': 'canary'
}
}
]
};
6 changes: 6 additions & 0 deletions config/environment.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/*jshint node:true*/
'use strict';

module.exports = function(/* environment, appConfig */) {
return { };
};
14 changes: 8 additions & 6 deletions ember-cli-build.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
/*jshint node:true*/
/* global require, module */
var EmberAddon = require('ember-cli/lib/broccoli/ember-addon');
var StripTestSelectorsTransform = require('./strip-test-selectors');

module.exports = function(defaults) {
var app = new EmberAddon(defaults, {
// Add options here
});

/*
This build file specifies the options for the dummy test app of this
addon, located in `/tests/dummy`
This build file does *not* influence how the addon or the app using it
behave. You most likely want to be modifying `./index.js` or app's build file
*/
// add the StripTestSelectorsTransform to the registry, so the dummy app has
// it added in the HTMLBars build pipeline: all data-test-* attributes are
// therefore stripped
app.registry.add('htmlbars-ast-plugin', {
name: 'strip-test-selectors',
plugin: StripTestSelectorsTransform
});

return app.toTree();
};
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
"test": "tests"
},
"scripts": {
"test": "mocha test/*.js",
"test:debug": "mocha debug test/*.js"
"test": "ember try:testall",
"jshint": "mocha"
},
"repository": "",
"engines": {
Expand Down Expand Up @@ -36,7 +36,7 @@
"ember-resolver": "^2.0.3",
"ember-try": "~0.0.8",
"mocha": "^1.21.4",
"mocha-jshint": "^0.0.9"
"mocha-jshint": "^2.3.1"
},
"keywords": [
"ember-addon"
Expand Down
2 changes: 1 addition & 1 deletion strip-test-selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ StripTestSelectorsTransform.prototype.transform = function(ast) {
attributesToDelete.push(attribute.name);
}
});

if (attributesToDelete.length > 0) {
_.remove(node.attributes, function(attribute) {
return _.includes(attributesToDelete, attribute.name);
Expand Down
1 change: 0 additions & 1 deletion test/fixtures/data-test-attributes.hbs

This file was deleted.

4 changes: 3 additions & 1 deletion test/jshint.spec.js
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
require('mocha-jshint')();
require('mocha-jshint')({
paths: ['./strip-test-selectors.js']
});
23 changes: 0 additions & 23 deletions test/strip-test-selectors-test.js

This file was deleted.

52 changes: 52 additions & 0 deletions tests/.jshintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
"predef": [
"document",
"window",
"location",
"setTimeout",
"$",
"-Promise",
"define",
"console",
"visit",
"exists",
"fillIn",
"click",
"keyEvent",
"triggerEvent",
"find",
"findWithAssert",
"wait",
"DS",
"andThen",
"currentURL",
"currentPath",
"currentRouteName"
],
"node": false,
"browser": false,
"boss": true,
"curly": true,
"debug": false,
"devel": false,
"eqeqeq": true,
"evil": true,
"forin": false,
"immed": false,
"laxbreak": false,
"newcap": true,
"noarg": true,
"noempty": false,
"nonew": false,
"nomen": false,
"onevar": false,
"plusplus": false,
"regexp": false,
"undef": true,
"sub": true,
"strict": false,
"white": false,
"eqnull": true,
"esnext": true,
"unused": true
}
18 changes: 18 additions & 0 deletions tests/dummy/app/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import Ember from 'ember';
import Resolver from './resolver';
import loadInitializers from 'ember/load-initializers';
import config from './config/environment';

let App;

Ember.MODEL_FACTORY_INJECTIONS = true;

App = Ember.Application.extend({
modulePrefix: config.modulePrefix,
podModulePrefix: config.podModulePrefix,
Resolver
});

loadInitializers(App, config.modulePrefix);

export default App;
25 changes: 25 additions & 0 deletions tests/dummy/app/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Dummy</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">

{{content-for "head"}}

<link rel="stylesheet" href="assets/vendor.css">
<link rel="stylesheet" href="assets/dummy.css">

{{content-for "head-footer"}}
</head>
<body>
{{content-for "body"}}

<script src="assets/vendor.js"></script>
<script src="assets/dummy.js"></script>

{{content-for "body-footer"}}
</body>
</html>
3 changes: 3 additions & 0 deletions tests/dummy/app/resolver.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import Resolver from 'ember-resolver';

export default Resolver;
11 changes: 11 additions & 0 deletions tests/dummy/app/router.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import Ember from 'ember';
import config from './config/environment';

const Router = Ember.Router.extend({
location: config.locationType
});

Router.map(function() {
});

export default Router;
Empty file added tests/dummy/app/styles/.gitkeep
Empty file.
3 changes: 3 additions & 0 deletions tests/dummy/app/templates/application.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<h2 id="title">Welcome to Ember</h2>

{{outlet}}
4 changes: 4 additions & 0 deletions tests/dummy/app/templates/components/data-test.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
"Please disperse. Nothing to see here." - Frank Drebin

This component only exists so we can convenietly use moduleForComponent for the
tests which check that data-test-* attributes are stripped.
47 changes: 47 additions & 0 deletions tests/dummy/config/environment.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/* jshint node: true */

module.exports = function(environment) {
var ENV = {
modulePrefix: 'dummy',
environment: environment,
baseURL: '/',
locationType: 'auto',
EmberENV: {
FEATURES: {
// Here you can enable experimental features on an ember canary build
// e.g. 'with-controller': true
}
},

APP: {
// Here you can pass flags/options to your application instance
// when it is created
}
};

if (environment === 'development') {
// ENV.APP.LOG_RESOLVER = true;
// ENV.APP.LOG_ACTIVE_GENERATION = true;
// ENV.APP.LOG_TRANSITIONS = true;
// ENV.APP.LOG_TRANSITIONS_INTERNAL = true;
// ENV.APP.LOG_VIEW_LOOKUPS = true;
}

if (environment === 'test') {
// Testem prefers this...
ENV.baseURL = '/';
ENV.locationType = 'none';

// keep test console output quieter
ENV.APP.LOG_ACTIVE_GENERATION = false;
ENV.APP.LOG_VIEW_LOOKUPS = false;

ENV.APP.rootElement = '#ember-testing';
}

if (environment === 'production') {

}

return ENV;
};
15 changes: 15 additions & 0 deletions tests/dummy/public/crossdomain.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM "http://www.adobe.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
<!-- Read this: www.adobe.com/devnet/articles/crossdomain_policy_file_spec.html -->

<!-- Most restrictive policy: -->
<site-control permitted-cross-domain-policies="none"/>

<!-- Least restrictive policy: -->
<!--
<site-control permitted-cross-domain-policies="all"/>
<allow-access-from domain="*" to-ports="*" secure="false"/>
<allow-http-request-headers-from domain="*" headers="*" secure="false"/>
-->
</cross-domain-policy>
3 changes: 3 additions & 0 deletions tests/dummy/public/robots.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# http://www.robotstxt.org
User-agent: *
Disallow:
5 changes: 5 additions & 0 deletions tests/helpers/destroy-app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import Ember from 'ember';

export default function destroyApp(application) {
Ember.run(application, 'destroy');
}
23 changes: 23 additions & 0 deletions tests/helpers/module-for-acceptance.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { module } from 'qunit';
import startApp from '../helpers/start-app';
import destroyApp from '../helpers/destroy-app';

export default function(name, options = {}) {
module(name, {
beforeEach() {
this.application = startApp();

if (options.beforeEach) {
options.beforeEach.apply(this, arguments);
}
},

afterEach() {
destroyApp(this.application);

if (options.afterEach) {
options.afterEach.apply(this, arguments);
}
}
});
}
Loading

0 comments on commit 7c917ff

Please sign in to comment.