mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-28 22:43:30 +03:00
Merge pull request #4527 from rwjblue/unit-tests
Add initial client unit test.
This commit is contained in:
commit
1db30f896f
56
Gruntfile.js
56
Gruntfile.js
@ -59,11 +59,19 @@ var _ = require('lodash'),
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
clientTests: {
|
||||||
|
files: {
|
||||||
|
src: [
|
||||||
|
'core/test/client/**/*.js'
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
// Linting files for test code.
|
// Linting files for test code.
|
||||||
test: {
|
test: {
|
||||||
files: {
|
files: {
|
||||||
src: [
|
src: [
|
||||||
'core/test/**/*.js'
|
'core/test/**/*.js',
|
||||||
|
'!core/test/client/**/*.js'
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -106,8 +114,8 @@ var _ = require('lodash'),
|
|||||||
tasks: ['emberTemplates:dev']
|
tasks: ['emberTemplates:dev']
|
||||||
},
|
},
|
||||||
ember: {
|
ember: {
|
||||||
files: ['core/client/**/*.js'],
|
files: ['core/client/**/*.js', 'core/test/client/**/*.js'],
|
||||||
tasks: ['clean:tmp', 'transpile', 'concat_sourcemap:dev']
|
tasks: ['clean:tmp', 'transpile', 'concat_sourcemap:dev', 'concat_sourcemap:tests']
|
||||||
},
|
},
|
||||||
sass: {
|
sass: {
|
||||||
files: [
|
files: [
|
||||||
@ -169,6 +177,11 @@ var _ = require('lodash'),
|
|||||||
jshintrc: 'core/client/.jshintrc'
|
jshintrc: 'core/client/.jshintrc'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
clientTests: {
|
||||||
|
options: {
|
||||||
|
jshintrc: 'core/test/client/.jshintrc'
|
||||||
|
}
|
||||||
|
},
|
||||||
test: {
|
test: {
|
||||||
options: {
|
options: {
|
||||||
jshintrc: 'core/test/.jshintrc'
|
jshintrc: 'core/test/.jshintrc'
|
||||||
@ -193,6 +206,12 @@ var _ = require('lodash'),
|
|||||||
esnext: true
|
esnext: true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
clientTests: {
|
||||||
|
options: {
|
||||||
|
config: '.jscsrc',
|
||||||
|
esnext: true
|
||||||
|
}
|
||||||
|
},
|
||||||
test: {
|
test: {
|
||||||
options: {
|
options: {
|
||||||
config: '.jscsrc'
|
config: '.jscsrc'
|
||||||
@ -297,6 +316,14 @@ var _ = require('lodash'),
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
testem: {
|
||||||
|
command: path.resolve(cwd + '/node_modules/.bin/testem ci'),
|
||||||
|
options: {
|
||||||
|
stdout: true,
|
||||||
|
stdin: false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
// #### Generate coverage report
|
// #### Generate coverage report
|
||||||
// See the `grunt test-coverage` task in the section on [Testing](#testing) for more information.
|
// See the `grunt test-coverage` task in the section on [Testing](#testing) for more information.
|
||||||
coverage: {
|
coverage: {
|
||||||
@ -389,6 +416,18 @@ var _ = require('lodash'),
|
|||||||
src: ['**/*.js', '!loader.js', '!config-*.js'],
|
src: ['**/*.js', '!loader.js', '!config-*.js'],
|
||||||
dest: '.tmp/ember-transpiled/'
|
dest: '.tmp/ember-transpiled/'
|
||||||
}]
|
}]
|
||||||
|
},
|
||||||
|
tests: {
|
||||||
|
type: 'amd',
|
||||||
|
moduleName: function (path) {
|
||||||
|
return 'ghost/tests/' + path;
|
||||||
|
},
|
||||||
|
files: [{
|
||||||
|
expand: true,
|
||||||
|
cwd: 'core/test/client/',
|
||||||
|
src: ['**/*.js'],
|
||||||
|
dest: '.tmp/ember-tests-transpiled/'
|
||||||
|
}]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -402,6 +441,13 @@ var _ = require('lodash'),
|
|||||||
sourcesContent: true
|
sourcesContent: true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
tests: {
|
||||||
|
src: ['.tmp/ember-tests-transpiled/**/*.js'],
|
||||||
|
dest: 'core/built/scripts/ghost-tests.js',
|
||||||
|
options: {
|
||||||
|
sourcesContent: true
|
||||||
|
}
|
||||||
|
},
|
||||||
prod: {
|
prod: {
|
||||||
src: ['.tmp/ember-transpiled/**/*.js', 'core/built/scripts/templates.js',
|
src: ['.tmp/ember-transpiled/**/*.js', 'core/built/scripts/templates.js',
|
||||||
'core/client/loader.js'],
|
'core/client/loader.js'],
|
||||||
@ -769,7 +815,7 @@ var _ = require('lodash'),
|
|||||||
// details of each of the test suites.
|
// details of each of the test suites.
|
||||||
//
|
//
|
||||||
grunt.registerTask('test', 'Run tests and lint code',
|
grunt.registerTask('test', 'Run tests and lint code',
|
||||||
['jshint', 'jscs', 'test-routes', 'test-module', 'test-unit', 'test-integration', 'test-functional']);
|
['jshint', 'jscs', 'test-routes', 'test-module', 'test-unit', 'test-integration', 'test-functional', 'shell:testem']);
|
||||||
|
|
||||||
// ### Lint
|
// ### Lint
|
||||||
//
|
//
|
||||||
@ -934,7 +980,7 @@ var _ = require('lodash'),
|
|||||||
// ### Ember Build *(Utility Task)*
|
// ### Ember Build *(Utility Task)*
|
||||||
// All tasks related to building the Ember client code including transpiling ES6 modules and building templates
|
// All tasks related to building the Ember client code including transpiling ES6 modules and building templates
|
||||||
grunt.registerTask('emberBuildDev', 'Build Ember JS & templates for development',
|
grunt.registerTask('emberBuildDev', 'Build Ember JS & templates for development',
|
||||||
['clean:tmp', 'buildAboutPage', 'emberTemplates:dev', 'transpile', 'concat_sourcemap:dev']);
|
['clean:tmp', 'buildAboutPage', 'emberTemplates:dev', 'transpile', 'concat_sourcemap:dev', 'concat_sourcemap:tests']);
|
||||||
|
|
||||||
// ### Ember Build *(Utility Task)*
|
// ### Ember Build *(Utility Task)*
|
||||||
// All tasks related to building the Ember client code including transpiling ES6 modules and building templates
|
// All tasks related to building the Ember client code including transpiling ES6 modules and building templates
|
||||||
|
@ -25,5 +25,10 @@
|
|||||||
"showdown-ghost": "0.3.4",
|
"showdown-ghost": "0.3.4",
|
||||||
"validator-js": "3.22.1",
|
"validator-js": "3.22.1",
|
||||||
"google-caja": "5669.0.0"
|
"google-caja": "5669.0.0"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"ember-mocha": "~0.1.4",
|
||||||
|
"ember-cli-test-loader": "dgeb/ember-cli-test-loader#test-agnostic",
|
||||||
|
"ember-cli-shims": "stefanpenner/ember-cli-shims#~0.0.3"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
// Loader to create the Ember.js application
|
// Loader to create the Ember.js application
|
||||||
/*global require */
|
/*global require */
|
||||||
|
|
||||||
|
if (!window.disableBoot) {
|
||||||
window.App = require('ghost/app')['default'].create();
|
window.App = require('ghost/app')['default'].create();
|
||||||
|
}
|
||||||
|
46
core/test/client/.jshintrc
Normal file
46
core/test/client/.jshintrc
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
{
|
||||||
|
"node": false,
|
||||||
|
"browser": true,
|
||||||
|
"nomen": false,
|
||||||
|
"bitwise": true,
|
||||||
|
"curly": true,
|
||||||
|
"eqeqeq": true,
|
||||||
|
"forin": true,
|
||||||
|
"immed": true,
|
||||||
|
"latedef": true,
|
||||||
|
"newcap": true,
|
||||||
|
"noarg": true,
|
||||||
|
"noempty": true,
|
||||||
|
"nonew": true,
|
||||||
|
"plusplus": true,
|
||||||
|
"regexp": true,
|
||||||
|
"undef": true,
|
||||||
|
"unused": true,
|
||||||
|
"trailing": true,
|
||||||
|
"indent": 4,
|
||||||
|
"esnext": true,
|
||||||
|
"onevar": true,
|
||||||
|
"white": true,
|
||||||
|
"quotmark": "single",
|
||||||
|
"globals": {
|
||||||
|
"Ember": true,
|
||||||
|
"Em": true,
|
||||||
|
"DS": true,
|
||||||
|
"$": true,
|
||||||
|
"SimpleAuth": true,
|
||||||
|
"validator": true,
|
||||||
|
"ic": true,
|
||||||
|
"_": true,
|
||||||
|
"NProgress": true,
|
||||||
|
"moment": true,
|
||||||
|
"mocha": true,
|
||||||
|
"chai": true,
|
||||||
|
"expect": true,
|
||||||
|
"describe": true,
|
||||||
|
"it": true,
|
||||||
|
"beforeEach": true,
|
||||||
|
"before": true,
|
||||||
|
"afterEach": true,
|
||||||
|
"after": true
|
||||||
|
}
|
||||||
|
}
|
33
core/test/client/index.html
Normal file
33
core/test/client/index.html
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
|
<title>Ghost Admin Tests</title>
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
|
||||||
|
<link rel="stylesheet" href="/bower_components/mocha/mocha.css">
|
||||||
|
<link rel="stylesheet" href="/core/client/assets/css/ghost.min.css">
|
||||||
|
<script>
|
||||||
|
window.disableBoot = true;
|
||||||
|
</script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id="mocha"></div>
|
||||||
|
|
||||||
|
<script src="/core/built/scripts/vendor-dev.js"></script>
|
||||||
|
<script src="/core/built/scripts/ghost-dev.js"></script>
|
||||||
|
<script src="/bower_components/mocha/mocha.js"></script>
|
||||||
|
<script src="/testem.js"></script>
|
||||||
|
<script src="/bower_components/chai/chai.js"></script>
|
||||||
|
<script src="/bower_components/ember-cli-shims/app-shims.js"></script>
|
||||||
|
<script src="/bower_components/ember-mocha-adapter/adapter.js"></script>
|
||||||
|
<script src="/bower_components/ember-mocha/ember-mocha.amd.js"></script>
|
||||||
|
<script src="/core/built/scripts/ghost-tests.js"></script>
|
||||||
|
<script src="/bower_components/ember-cli-test-loader/test-loader.js"></script>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
require('ghost/tests/test-helper');
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
18
core/test/client/test-helper.js
Normal file
18
core/test/client/test-helper.js
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
import TestLoader from 'ember-cli/test-loader';
|
||||||
|
import Resolver from 'ember/resolver';
|
||||||
|
import { setResolver } from 'ember-mocha';
|
||||||
|
|
||||||
|
var resolver = Resolver.create();
|
||||||
|
resolver.namespace = {
|
||||||
|
modulePrefix: 'ghost'
|
||||||
|
};
|
||||||
|
|
||||||
|
setResolver(resolver);
|
||||||
|
|
||||||
|
TestLoader.load();
|
||||||
|
|
||||||
|
window.expect = chai.expect;
|
||||||
|
|
||||||
|
mocha.checkLeaks();
|
||||||
|
mocha.globals(['jQuery', 'EmberInspector']);
|
||||||
|
mocha.run();
|
18
core/test/client/unit/components/gh-trim-focus-input_test.js
Normal file
18
core/test/client/unit/components/gh-trim-focus-input_test.js
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
/* jshint expr:true */
|
||||||
|
import {
|
||||||
|
describeComponent,
|
||||||
|
it
|
||||||
|
} from 'ember-mocha';
|
||||||
|
|
||||||
|
describeComponent('gh-trim-focus-input', function () {
|
||||||
|
it('trims value on focusOut', function () {
|
||||||
|
var component = this.subject({
|
||||||
|
value: 'some random stuff '
|
||||||
|
});
|
||||||
|
|
||||||
|
this.render();
|
||||||
|
|
||||||
|
component.$().focusout();
|
||||||
|
expect(component.$().val()).to.equal('some random stuff');
|
||||||
|
});
|
||||||
|
});
|
@ -98,6 +98,7 @@
|
|||||||
"should": "~4.0.4",
|
"should": "~4.0.4",
|
||||||
"sinon": "~1.10.3",
|
"sinon": "~1.10.3",
|
||||||
"supertest": "~0.13.0",
|
"supertest": "~0.13.0",
|
||||||
|
"testem": "^0.6.23",
|
||||||
"top-gh-contribs": "0.0.2"
|
"top-gh-contribs": "0.0.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
9
testem.json
Normal file
9
testem.json
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"test_page": "core/test/client/index.html",
|
||||||
|
"launch_in_ci": [
|
||||||
|
"PhantomJS"
|
||||||
|
],
|
||||||
|
"launch_in_dev": [
|
||||||
|
"PhantomJS"
|
||||||
|
]
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user