1 |
|
2 | var config =
|
3 | module.exports = function(config) {
|
4 |
|
5 | config.set({
|
6 |
|
7 |
|
8 | basePath: './',
|
9 |
|
10 |
|
11 |
|
12 |
|
13 | frameworks: ['jasmine'],
|
14 |
|
15 |
|
16 |
|
17 | files: [
|
18 | 'node_modules/jquery/dist/jquery.js',
|
19 | 'node_modules/bootstrap/dist/js/bootstrap.js',
|
20 | 'node_modules/patternfly-bootstrap-combobox/js/bootstrap-combobox.js',
|
21 | 'node_modules/bootstrap-datepicker/dist/js/bootstrap-datepicker.js',
|
22 | 'node_modules/bootstrap-select/dist/js/bootstrap-select.js',
|
23 | 'node_modules/datatables.net/js/jquery.dataTables.js',
|
24 | 'node_modules/datatables.net-select/js/dataTables.select.js',
|
25 | 'node_modules/bootstrap-switch/dist/js/bootstrap-switch.js',
|
26 | 'node_modules/patternfly-bootstrap-treeview/src/js/bootstrap-treeview.js',
|
27 | 'node_modules/c3/c3.js',
|
28 | 'node_modules/d3/d3.js',
|
29 | 'node_modules/jasmine-jquery/lib/jasmine-jquery.js',
|
30 | {pattern: 'dist/img/**/*', watched: true, included: false, served: true},
|
31 | {pattern: 'dist/fonts/**/*', watched: true, included: false, served: true},
|
32 | {pattern: 'dist/css/*.map', watched: true, included: false, served: true},
|
33 | 'dist/css/*.css',
|
34 | 'dist/js/patternfly.js',
|
35 | 'dist/js/patternfly.min.js',
|
36 | {pattern: 'dist/tests/**/*', watched: true, included: false, served: true},
|
37 |
|
38 |
|
39 | 'tests/unit/globals.js',
|
40 | 'tests/unit/*.spec.js'
|
41 | ],
|
42 |
|
43 |
|
44 |
|
45 | exclude: [
|
46 | ],
|
47 |
|
48 |
|
49 |
|
50 |
|
51 | preprocessors: {
|
52 | },
|
53 |
|
54 |
|
55 |
|
56 |
|
57 |
|
58 | reporters: ['progress'],
|
59 |
|
60 |
|
61 |
|
62 | port: 9876,
|
63 |
|
64 |
|
65 |
|
66 | colors: true,
|
67 |
|
68 |
|
69 |
|
70 |
|
71 | logLevel: config.LOG_INFO,
|
72 |
|
73 |
|
74 |
|
75 | autoWatch: true,
|
76 |
|
77 |
|
78 |
|
79 |
|
80 | browsers: ['PhantomJS'],
|
81 |
|
82 |
|
83 | middleware: ['custom'],
|
84 |
|
85 |
|
86 | plugins: [
|
87 | 'karma-jasmine',
|
88 | 'karma-chrome-launcher',
|
89 | 'karma-firefox-launcher',
|
90 | 'karma-phantomjs-launcher',
|
91 | {'middleware:custom': ['factory', CustomMiddlewareFactory]}
|
92 | ],
|
93 |
|
94 |
|
95 |
|
96 | singleRun: true,
|
97 |
|
98 |
|
99 | browserNoActivityTimeout: 100000
|
100 | });
|
101 | };
|
102 |
|
103 |
|
104 | var fs = require('fs');
|
105 |
|
106 | var CustomMiddlewareFactory = function (config) {
|
107 | return function (request, response) {
|
108 |
|
109 | if(/^\/dist*/.test(request.url)){
|
110 | var newPath = request._parsedUrl.pathname.substring(1);
|
111 | var file = fs.readFileSync(newPath, "utf8");
|
112 |
|
113 | if(config.logLevel === config.LOG_DEBUG){
|
114 | console.log('Intercepted:' + request.url + ' Serving: ' + newPath);
|
115 | }
|
116 |
|
117 | if(request.url.indexOf('.svg') > 0) {
|
118 | response.writeHeader(200, {'Content-Type': 'image/svg+xml'});
|
119 | } else if (request.url.indexOf('.js') > 0) {
|
120 | response.writeHeader(200, {'Content-Type': 'application/javascript'});
|
121 | } else if (request.url.indexOf('.css') > 0) {
|
122 | response.writeHeader(200, {'Content-Type': 'text/css'});
|
123 | }
|
124 |
|
125 | response.write(file);
|
126 | }
|
127 | return response.end();
|
128 | }
|
129 | };
|