Skip to content

Commit 695ca84

Browse files
committed
Updated unit tests to run off of the combined NEXT source.
1 parent ab3e686 commit 695ca84

File tree

4 files changed

+72
-117
lines changed

4 files changed

+72
-117
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,5 @@ docs/**/
1717
main.css
1818
*.codekit
1919
*.sass-cache
20+
tests/.grunt
21+
_SpecRunner.html

tests/Gruntfile.js

+68-50
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,88 @@
11
module.exports = function (grunt) {
22
grunt.initConfig(
3-
{
4-
pkg: grunt.file.readJSON('package.json'),
3+
{
4+
pkg: grunt.file.readJSON('package.json'),
55

6-
jasmine: {
7-
run: {
8-
src: [
9-
'../lib/preloadjs-0.4.1.combined.js'
10-
],
11-
options: {
12-
specs: 'spec/*Spec.js',
13-
helpers: []
14-
}
15-
}
16-
},
17-
18-
connect: {
19-
server: {
20-
options: {
21-
keepalive: true,
22-
base: ['../_assets/', '../lib/', '../', './'],
23-
middleware: function (connect, options, middlewares) {
24-
middlewares.unshift(function echo(req, res, next) {
25-
if (req.method == "POST") {
26-
res.end(JSON.stringify(req.body));
27-
} else {
28-
next();
29-
}
30-
});
6+
jasmine: {
7+
run: {
8+
src: [
9+
'../lib/preloadjs-NEXT.combined.js',
10+
'../lib/movieclip-NEXT.combined.js'
11+
],
3112

32-
var bodyParser = require('body-parser')
33-
middlewares.unshift(bodyParser.json());
34-
middlewares.unshift(bodyParser.urlencoded({
35-
extended: true
36-
}));
37-
38-
return middlewares;
39-
},
13+
options: {
14+
specs: 'spec/*Spec.js',
15+
helpers: [
16+
'spec/Helpers.js'
17+
],
18+
vendor: [
19+
'../_assets/libs/easeljs-NEXT.min.js',
20+
'../_assets/libs/preloadjs-NEXT.min.js'
21+
],
22+
host: 'http://127.0.0.1:<%=connect.serve.options.port%>/'
23+
}
4024
}
41-
}
42-
},
25+
},
4326

44-
findopenport: {
4527
connect: {
46-
options: {
47-
ports: [8000, 8888, 9000, 9999, 9001, 8001],
48-
configName: "connect.server.options.port"
28+
serve: {
29+
options: {
30+
keepalive: true,
31+
base: [
32+
{
33+
path: __dirname,
34+
options: {
35+
index: '_SpecRunner.html'
36+
}
37+
}, '..', '../_assets/', '../lib/', './'
38+
],
39+
useAvailablePort: true,
40+
port: 8000,
41+
open: true,
42+
// Used to test the POST functionality, it just echo's back what data was sent.
43+
middleware: function (connect, options, middlewares) {
44+
middlewares.unshift(function echo (req, res, next) {
45+
if (req.method == "POST") {
46+
res.end(JSON.stringify(req.body));
47+
} else {
48+
next();
49+
}
50+
});
51+
var bodyParser = require('body-parser')
52+
middlewares.unshift(bodyParser.json());
53+
middlewares.unshift(bodyParser.urlencoded({
54+
extended: true
55+
}));
56+
57+
return middlewares;
58+
},
59+
}
4960
}
50-
}
51-
},
61+
},
5262

53-
listips: {
54-
run: {
55-
options: {
56-
port: "<%=connect.server.options.port %>",
57-
label: "Normal"
63+
listips: {
64+
run: {
65+
options: {
66+
label: "Normal"
67+
}
5868
}
5969
}
6070
}
61-
}
6271
);
6372

73+
grunt.registerTask('configureConnectHeadless', function () {
74+
grunt.config('connect.serve.options.keepalive', false);
75+
grunt.config('connect.serve.options.open', false);
76+
});
77+
6478
// Load all the tasks we need
6579
grunt.loadNpmTasks('grunt-contrib-jasmine');
6680
grunt.loadNpmTasks('grunt-contrib-connect');
6781
grunt.loadTasks('tasks/');
6882

69-
grunt.registerTask("default", ["findopenport", "listips", "connect"]);
83+
grunt.registerTask("default", "Launches browser-based tests", "serve");
84+
grunt.registerTask("serve", "Launches browser-based tests", ["listips", "connect"]);
85+
86+
grunt.registerTask("headless", "phantom");
87+
grunt.registerTask("phantom", "Launches phantom-based tests", ["configureConnectHeadless", "connect", "jasmine"]);
7088
};

tests/index.html

-65
This file was deleted.

tests/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
"devDependencies": {
88
"body-parser": "^1.9.2",
99
"grunt": "~0.4.5",
10-
"grunt-contrib-connect": "^0.8.0",
11-
"grunt-contrib-jasmine": "^0.8.1"
10+
"grunt-contrib-connect": "^0.9.0",
11+
"grunt-contrib-jasmine": "^0.8.2"
1212
},
1313
"engine": "node >= 0.10.22"
1414
}

0 commit comments

Comments
 (0)