Permalink
Browse files

Enable running tests with one command

  • Loading branch information...
1 parent 4d6f0b9 commit 392ada28a528cdbefea4b47933135c41730e4b84 @timdream committed Jun 30, 2013
Showing with 51 additions and 8 deletions.
  1. +0 −3 .gitmodules
  2. +18 −0 CONTRIBUTE.md
  3. +24 −0 Gruntfile.js
  4. +1 −1 PRODUCTION.md
  5. +6 −1 package.json
  6. +2 −2 test/index.html
  7. +0 −1 test/qunit
View
@@ -7,9 +7,6 @@
[submodule "assets/go2"]
path = assets/go2
url = git://github.com/timdream/google-oauth2-web-client.git
-[submodule "test/qunit"]
- path = test/qunit
- url = git://github.com/jquery/qunit.git
[submodule "assets/canvas-to-blob"]
path = assets/canvas-to-blob
url = git://github.com/blueimp/JavaScript-Canvas-to-Blob.git
View
@@ -11,6 +11,12 @@ You'll need the following skill/tools
* [Compass](http://compass-style.org/), preferably [Compass.app](http://compass.handlino.com/)
* The ability to run a localhost HTTP server (Compass.app have that built-in, with Livereload)
+Additionally, would need to install the following for running tests
+
+* [`node`](http://nodejs.org/) (comes with [`npm`](http://npmjs.org/) built-in)
+* [`grunt`](http://gruntjs.com/)
+* [QUnit](http://qunitjs.com/)
+
### Install
1. Clone the code base
@@ -25,6 +31,18 @@ However, you could save some trouble set them up simply by using the `timc.idv.t
**You must use the key correspond to the correct hostname/domain to test these functions.**
To test your local code with keys associated with `timc.idv.tw`, you must connect to your working copy via `http://localhost.timc.idv.tw/`.
+## Running tests
+
+With `node` and `npm`, set up the environment by running
+
+ npm install
+
+To run tests, do
+
+ npm test # run |grunt test| with one keystroke less
+
+Tests require Internet access.
+
## Coding style
* You must agree to submit your contribution under [MIT License](./MIT-LICENSE.txt).
View
@@ -2,6 +2,8 @@
module.exports = function(grunt) {
+ var HTTPD_PORT = 28080 + Math.floor(Math.random() * 10);
+
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
clean: {
@@ -77,6 +79,22 @@ module.exports = function(grunt) {
options: {
dirs: ['production']
}
+ },
+ connect: {
+ test: {
+ options: {
+ port: HTTPD_PORT
+ }
+ }
+ },
+ qunit: {
+ test: {
+ options: {
+ urls: [
+ 'http://localhost:' + HTTPD_PORT + '/test/'
+ ]
+ }
+ }
}
});
@@ -89,6 +107,9 @@ module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-shell');
grunt.loadNpmTasks('grunt-useMin');
+ grunt.loadNpmTasks('grunt-contrib-qunit');
+ grunt.loadNpmTasks('grunt-contrib-connect');
+
// Build web app for production
grunt.registerTask('default', [
'clean', 'copy', 'useminPrepare',
@@ -97,6 +118,9 @@ module.exports = function(grunt) {
// Quick shell command to rsync the code to my site
grunt.registerTask('deploy', ['shell:deploy']);
+ // Run the test suite with QUnit on PhantomJS
+ grunt.registerTask('test', ['connect', 'qunit']);
+
// Simple target to check remaining client credit.
grunt.registerTask('check-imgur-credit', function checkImgurCredit() {
var https = require('https');
View
@@ -1,6 +1,6 @@
## Build for production
-Require `node` and `npm`. Run
+Require `node`, and `grunt`. Run
npm install
grunt
View
@@ -4,6 +4,9 @@
"type": "git",
"url": "https://github.com/timdream/wordcloud.git"
},
+ "scripts": {
+ "test": "grunt test"
+ },
"devDependencies": {
"grunt": "~0.4.1",
"grunt-contrib-clean": "~0.4.1",
@@ -13,6 +16,8 @@
"grunt-usemin": "~0.1.12",
"grunt-replace": "~0.4.4",
"grunt-rev": "~0.1.0",
- "grunt-shell": "~0.2.2"
+ "grunt-shell": "~0.2.2",
+ "grunt-contrib-qunit": "~0.2.2",
+ "grunt-contrib-connect": "~0.3.0"
}
}
View
@@ -3,11 +3,11 @@
<head>
<meta charset="utf-8">
<title>wordcloud app tests</title>
- <link rel="stylesheet" href="qunit/qunit/qunit.css">
+ <link rel="stylesheet" href="http://code.jquery.com/qunit/qunit-1.12.0.css">
</head>
<body>
<div id="qunit"></div>
- <script src="qunit/qunit/qunit.js"></script>
+ <script src="http://code.jquery.com/qunit/qunit-1.12.0.js"></script>
<script>
QUnit.config.testTimeout = 10*1E3;
</script>
Submodule qunit deleted from 6ca372

0 comments on commit 392ada2

Please sign in to comment.