Skip to content
This repository has been archived by the owner on Oct 3, 2023. It is now read-only.

Commit

Permalink
Merge pull request #19 from Turbo87/tests
Browse files Browse the repository at this point in the history
Add test suite
  • Loading branch information
Turbo87 authored Sep 8, 2016
2 parents 8b204f7 + 43bc839 commit e4a8de0
Show file tree
Hide file tree
Showing 14 changed files with 113 additions and 133 deletions.
14 changes: 0 additions & 14 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,8 @@ insert_final_newline = true
indent_style = space
indent_size = 2

[*.js]
indent_style = space
indent_size = 2

[*.hbs]
insert_final_newline = false
indent_style = space
indent_size = 2

[*.css]
indent_style = space
indent_size = 2

[*.html]
indent_style = space
indent_size = 2

[*.{diff,md}]
trim_trailing_whitespace = false
2 changes: 1 addition & 1 deletion .jshintrc
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@
"strict": false,
"white": false,
"eqnull": true,
"esnext": true,
"esversion": 6,
"unused": true
}
33 changes: 10 additions & 23 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,35 +1,22 @@
---
sudo: false

language: node_js
node_js:
- "0.10"
- "0.12"

sudo: false
- "4"
- "6"
- "stable"

cache:
directories:
- node_modules

env:
- EMBER_TRY_SCENARIO=default
- EMBER_TRY_SCENARIO=old-test-loader
- 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
- $HOME/.npm
- $HOME/.cache # includes bowers cache

before_install:
- export PATH=/usr/local/phantomjs-2.0.0/bin:$PATH
- "npm config set spin false"
- "npm install -g npm@^2"
- npm config set spin false
- npm install -g bower phantomjs-prebuilt

install:
- npm install -g bower
- npm install
- bower install

script:
- ember try:one $EMBER_TRY_SCENARIO
7 changes: 3 additions & 4 deletions bower.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
{
"name": "ember-cli-qunit",
"name": "ember-cli-jshint",
"dependencies": {
"ember": "~2.4.1",
"ember-cli-shims": "0.1.0",
"ember-cli-test-loader": "0.2.2",
"ember": "~2.7.0",
"ember-cli-shims": "0.1.1",
"ember-qunit-notifications": "0.1.0"
}
}
21 changes: 16 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
"description": "JSHint support for ember-cli projects",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"build": "ember build",
"start": "ember server",
"test": "mocha"
},
"ember-addon": {
"main": "index.js",
Expand All @@ -28,15 +30,24 @@
"url": "https://github.com/ember-cli/ember-cli-jshint/issues"
},
"homepage": "https://github.com/ember-cli/ember-cli-jshint",
"engines": {
"node": ">= 0.10.0"
},
"dependencies": {
"broccoli-jshint": "^1.0.0"
},
"bundledDependencies": [],
"devDependencies": {
"ember-cli": "^2.4.2",
"chai": "^3.5.0",
"ember-cli": "2.7.0",
"ember-cli-babel": "^5.1.6",
"ember-cli-htmlbars": "^1.0.3",
"ember-cli-qunit": "^2.0.0",
"ember-cli-test-loader": "^1.1.0",
"ember-load-initializers": "^0.5.1",
"ember-resolver": "^2.0.3",
"ember-try": "^0.2.2",
"loader.js": "^4.0.1"
"es6-promise": "^3.2.1",
"fs-extra": "^0.30.0",
"loader.js": "^4.0.1",
"mocha": "^3.0.2"
}
}
61 changes: 61 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
var fs = require('fs-extra');
var exec = require('child_process').exec;
var Promise = require('es6-promise').Promise;

var expect = require('chai').expect;

var FAILING_FILE = __dirname + '/tests/dummy/app/unused.js';

describe('ember-cli-jshint', function() {
this.timeout(60000);

afterEach(function() {
fs.removeSync(FAILING_FILE);
});

it('passes if JSHint tests pass', function() {
return emberTest().then(function(result) {
expect(result.error).to.not.exist;
expect(result.stdout.match(/[^\r\n]+/g))
.to.contain('ok 1 PhantomJS 2.1 - JSHint | app.js: should pass jshint')
.to.contain('ok 2 PhantomJS 2.1 - JSHint | helpers/destroy-app.js: should pass jshint')
.to.contain('ok 3 PhantomJS 2.1 - JSHint | helpers/module-for-acceptance.js: should pass jshint')
.to.contain('ok 4 PhantomJS 2.1 - JSHint | helpers/resolver.js: should pass jshint')
.to.contain('ok 5 PhantomJS 2.1 - JSHint | helpers/start-app.js: should pass jshint')
.to.contain('ok 6 PhantomJS 2.1 - JSHint | resolver.js: should pass jshint')
.to.contain('ok 7 PhantomJS 2.1 - JSHint | router.js: should pass jshint')
.to.contain('ok 8 PhantomJS 2.1 - JSHint | test-helper.js: should pass jshint')
.to.not.contain('not ok 9 PhantomJS 2.1 - JSHint | unused.js: should pass jshint');
})
});

it('fails if a JSHint tests fails', function() {
fs.outputFileSync(FAILING_FILE, 'let unused = 6;\n');

return emberTest().then(function(result) {
expect(result.error).to.exist;
expect(result.stdout.match(/[^\r\n]+/g))
.to.contain('ok 1 PhantomJS 2.1 - JSHint | app.js: should pass jshint')
.to.contain('ok 2 PhantomJS 2.1 - JSHint | helpers/destroy-app.js: should pass jshint')
.to.contain('ok 3 PhantomJS 2.1 - JSHint | helpers/module-for-acceptance.js: should pass jshint')
.to.contain('ok 4 PhantomJS 2.1 - JSHint | helpers/resolver.js: should pass jshint')
.to.contain('ok 5 PhantomJS 2.1 - JSHint | helpers/start-app.js: should pass jshint')
.to.contain('ok 6 PhantomJS 2.1 - JSHint | resolver.js: should pass jshint')
.to.contain('ok 7 PhantomJS 2.1 - JSHint | router.js: should pass jshint')
.to.contain('ok 8 PhantomJS 2.1 - JSHint | test-helper.js: should pass jshint')
.to.contain('not ok 9 PhantomJS 2.1 - JSHint | unused.js: should pass jshint');
})
});
});

function emberTest() {
return new Promise(function(resolve) {
exec('node_modules/.bin/ember test', { cwd: __dirname }, function (error, stdout, stderr) {
resolve({
error: error,
stdout: stdout,
stderr: stderr,
});
});
});
}
2 changes: 1 addition & 1 deletion tests/.jshintrc
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,6 @@
"strict": false,
"white": false,
"eqnull": true,
"esnext": true,
"esversion": 6,
"unused": true
}
8 changes: 4 additions & 4 deletions tests/dummy/app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@

{{content-for "head"}}

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

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

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

{{content-for "body-footer"}}
</body>
Expand Down
3 changes: 2 additions & 1 deletion tests/dummy/app/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import Ember from 'ember';
import config from './config/environment';

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

Router.map(function() {
Expand Down
3 changes: 1 addition & 2 deletions tests/dummy/config/environment.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module.exports = function(environment) {
var ENV = {
modulePrefix: 'dummy',
environment: environment,
baseURL: '/',
rootURL: '/',
locationType: 'auto',
EmberENV: {
FEATURES: {
Expand All @@ -29,7 +29,6 @@ module.exports = function(environment) {

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

// keep test console output quieter
Expand Down
12 changes: 6 additions & 6 deletions tests/helpers/module-for-acceptance.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
import { module } from 'qunit';
import Ember from 'ember';
import startApp from '../helpers/start-app';
import destroyApp from '../helpers/destroy-app';

const { RSVP: { Promise } } = Ember;

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

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

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

destroyApp(this.application);
let afterEach = options.afterEach && options.afterEach.apply(this, arguments);
return Promise.resolve(afterEach).then(() => destroyApp(this.application));
}
});
}
17 changes: 8 additions & 9 deletions tests/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
{{content-for "head"}}
{{content-for "test-head"}}

<link rel="stylesheet" href="assets/vendor.css">
<link rel="stylesheet" href="assets/dummy.css">
<link rel="stylesheet" href="assets/test-support.css">
<link rel="stylesheet" href="{{rootURL}}assets/vendor.css">
<link rel="stylesheet" href="{{rootURL}}assets/dummy.css">
<link rel="stylesheet" href="{{rootURL}}assets/test-support.css">

{{content-for "head-footer"}}
{{content-for "test-head-footer"}}
Expand All @@ -21,12 +21,11 @@
{{content-for "body"}}
{{content-for "test-body"}}

<script src="testem.js" integrity=""></script>
<script src="assets/vendor.js"></script>
<script src="assets/test-support.js"></script>
<script src="assets/dummy.js"></script>
<script src="assets/tests.js"></script>
<script src="assets/test-loader.js"></script>
<script src="{{rootURL}}testem.js" integrity=""></script>
<script src="{{rootURL}}assets/vendor.js"></script>
<script src="{{rootURL}}assets/test-support.js"></script>
<script src="{{rootURL}}assets/dummy.js"></script>
<script src="{{rootURL}}assets/tests.js"></script>

{{content-for "body-footer"}}
{{content-for "test-body-footer"}}
Expand Down
8 changes: 0 additions & 8 deletions tests/unit/qunit-configuration-test.js

This file was deleted.

55 changes: 0 additions & 55 deletions tests/unit/test-loader-test.js

This file was deleted.

0 comments on commit e4a8de0

Please sign in to comment.