-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathGruntParser.spec.js
80 lines (80 loc) · 3.51 KB
/
GruntParser.spec.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
// generated by xUnit Mon Jun 10 2013 20:25:40 GMT+0100 (GMT Summer Time)
// jasmine unit test for grunt-parser.js
/*global describe, it, expect, parse */
define(function (require, exports, module) {
'use strict';
var testapi = require('./GruntParser.js');
describe("test parse(text)", function () {
var text =
"module.exports = function (grunt) {\r\n" +
" 'use strict';\r\n" +
"\r\n" +
" grunt.initConfig({\r\n" +
" typescript: {\r\n" +
" smash: {\r\n" +
" src: ['app/smash.ts'],\r\n" +
" dest: 'public/js/smash.js',\r\n" +
" options: {\r\n" +
" target: 'ES5'\r\n" +
" }\r\n" +
" },\r\n" +
" app: {\r\n" +
" src: ['app.ts'],\r\n" +
" dest: 'app.js',\r\n" +
" options: {\r\n" +
" target: 'ES5'\r\n" +
" }\r\n" +
" }\r\n" +
" },\r\n" +
"\r\n" +
" uglify: {\r\n" +
" smash: {\r\n" +
" files: {\r\n" +
" 'public/js/smash.min.js': ['public/js/smash.js']\r\n" +
" }\r\n" +
" }\r\n" +
" },\r\n" +
"\r\n" +
" watch: {\r\n" +
" smash: {\r\n" +
" files: ['app/*.ts','app/**/*.ts'],\r\n" +
" tasks: ['typescript:smash'],\r\n" +
" options: {\r\n" +
" nospawn: true\r\n" +
" }\r\n" +
" },\r\n" +
" app: {\r\n" +
" files: ['app.ts'],\r\n" +
" tasks: ['typescript:app'],\r\n" +
" options: {\r\n" +
" nospawn: true\r\n" +
" }\r\n" +
" }\r\n" +
" }\r\n" +
" });\r\n" +
"\r\n" +
" grunt.loadNpmTasks('grunt-contrib-uglify');\r\n" +
" grunt.loadNpmTasks('grunt-typescript');\r\n" +
" grunt.loadNpmTasks('grunt-contrib-watch');\r\n" +
" grunt.registerTask('custom', ['typescript', 'uglify']);\r\n" +
" grunt.registerTask('default', ['typescript', 'uglify']);\r\n" +
"}";
var targets = testapi.parse(text);
it("Should return an array", function () {
expect(targets.length).toBeDefined();
});
it("Should return top-level tasks", function () {
expect(targets).toContain("typescript");
expect(targets).toContain("uglify");
expect(targets).toContain("watch");
expect(targets).toContain("custom");
});
it("Should return sub-tasks with colon", function () {
expect(targets).toContain("typescript:smash");
expect(targets).toContain("typescript:app");
expect(targets).toContain("uglify:smash");
expect(targets).toContain("watch:smash");
expect(targets).toContain("watch:app");
});
});
});