Skip to content

Commit b99d376

Browse files
Update unit test dependencies
1 parent 08814ee commit b99d376

File tree

5 files changed

+159
-173
lines changed

5 files changed

+159
-173
lines changed

Gruntfile.js

+16-10
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ module.exports = function (grunt) {
1515
var contextRoot = grunt.option('contextRoot') || "dev-console";
1616
var isMac = /^darwin/.test(process.platform) || grunt.option('mac');
1717

18+
1819
// Load grunt tasks automatically
1920
require('load-grunt-tasks')(grunt, {
2021
pattern: ['grunt-*', '!grunt-template-jasmine-istanbul']
@@ -602,9 +603,8 @@ module.exports = function (grunt) {
602603

603604
// Test settings
604605
karma: {
605-
unit: {
606+
options: {
606607
configFile: 'test/karma.conf.js',
607-
singleRun: true,
608608
// default in karma.conf.js is Firefox, however, Chrome has much better
609609
// error messages when writing tests. Call like this:
610610
// grunt test
@@ -613,36 +613,38 @@ module.exports = function (grunt) {
613613
browsers: grunt.option('browsers') ?
614614
grunt.option('browsers').split(',') :
615615
['Firefox']
616+
},
617+
unit: {
618+
singleRun: true,
616619
}
617620
},
618621

619622
protractor: {
620623
options: {
621-
configFile: "test/protractor.conf.js", // Default config file
624+
configFile: "test/protractor.conf.js",
622625
keepAlive: false, // If false, the grunt process stops when the test fails.
623-
noColor: false, // If true, protractor will not use colors in its output.
626+
noColor: false,
624627
args: {
625-
// Arguments passed to the command
626628
suite: grunt.option('suite') || 'full',
627629
baseUrl: grunt.option('baseUrl') || ("https://localhost:9000/" + contextRoot + "/")
628630
}
629631
},
630632
default: {
631633
options: {
632-
configFile: "test/protractor.conf.js", // Target-specific config file
634+
configFile: "test/protractor.conf.js",
633635
args: {
634636
baseUrl: grunt.option('baseUrl') || ("https://localhost:9000/" + contextRoot + "/"),
635637
browser: grunt.option('browser') || "firefox"
636-
} // Target-specific arguments
638+
}
637639
}
638640
},
639641
mac: {
640642
options: {
641-
configFile: "test/protractor-mac.conf.js", // Target-specific config file
643+
configFile: "test/protractor-mac.conf.js",
642644
args: {
643645
baseUrl: grunt.option('baseUrl') || ("https://localhost:9000/" + contextRoot + "/"),
644646
browser: grunt.option('browser') || "firefox"
645-
} // Target-specific arguments
647+
}
646648
}
647649
}
648650
},
@@ -728,7 +730,7 @@ module.exports = function (grunt) {
728730
grunt.loadNpmTasks('grunt-angular-templates');
729731

730732
// karma must run prior to coverage since karma will generate the coverage results
731-
grunt.registerTask('test', [
733+
grunt.registerTask('test-unit', [
732734
'clean:server',
733735
'concurrent:test',
734736
'postcss',
@@ -737,6 +739,10 @@ module.exports = function (grunt) {
737739
// 'coverage' - add back if we want to enforce coverage percentages
738740
]);
739741

742+
// test as an alias to unit. after updating protractor,
743+
// will make test an alias for both unit & e2e
744+
grunt.registerTask('test', ['test-unit']);
745+
740746
grunt.registerTask('test-integration',
741747
grunt.option('baseUrl') ?
742748
[isMac ? 'protractor:mac' : 'protractor:default'] : // if a baseUrl is defined assume we dont want to run the local grunt server

package.json

+19-7
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,17 @@
1212
"clean-css": "3.4.12",
1313
"connect-modrewrite": "0.7.9",
1414
"geckodriver": "1.3.0",
15+
1516
"grunt": "0.4.5",
17+
1618
"grunt-angular-templates": "1.0.3",
1719
"grunt-cli": "1.1.0",
1820
"grunt-concurrent": "2.3.1",
1921
"grunt-contrib-clean": "1.0.0",
2022
"grunt-contrib-concat": "1.0.0",
23+
2124
"grunt-contrib-connect": "1.0.2",
25+
2226
"grunt-contrib-copy": "1.0.0",
2327
"grunt-contrib-cssmin": "1.0.1",
2428
"grunt-contrib-htmlmin": "1.3.0",
@@ -29,7 +33,9 @@
2933
"grunt-contrib-watch": "1.0.0",
3034
"grunt-htmlhint": "0.4.1",
3135
"grunt-istanbul-coverage": "0.0.5",
32-
"grunt-karma": "0.9.0",
36+
37+
"grunt-karma": "^2.0.0",
38+
3339
"grunt-newer": "0.7.0",
3440
"grunt-ng-annotate": "0.3.2",
3541
"grunt-postcss": "^0.8.0",
@@ -40,19 +46,25 @@
4046
"grunt-wiredep": "3.0.0",
4147
"html-minifier": "1.1.1",
4248
"imagemin": "1.0.5",
49+
50+
"jasmine-core": "^2.8.0",
4351
"jasmine-beforeall": "0.1.1",
4452
"jasmine-spec-reporter": "1.1.2",
53+
4554
"jshint-stylish": "0.2.0",
46-
"karma": "0.12.23",
47-
"karma-chrome-launcher": "^2.0.0",
48-
"karma-coverage": "0.2.6",
49-
"karma-firefox-launcher": "^1.0.0",
50-
"karma-jasmine": "0.1.5",
51-
"karma-ng-html2js-preprocessor": "1.0.0",
55+
56+
"karma": "^1.7.1",
57+
"karma-chrome-launcher": "^2.2.0",
58+
"karma-coverage": "^1.1.1",
59+
"karma-firefox-launcher": "^1.0.1",
60+
"karma-jasmine": "^1.1.0",
61+
"karma-ng-html2js-preprocessor": "^1.0.0",
5262
"karma-phantomjs-launcher": "^1.0.4",
63+
5364
"less": "2.6.1",
5465
"load-grunt-tasks": "0.4.0",
5566
"lodash": "3.10.1",
67+
5668
"protractor": "1.7.0",
5769
"protractor-screenshot-reporter": "0.0.5",
5870
"serve-static": "1.10.2",

test/karma.conf.js

+15-18
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,14 @@ module.exports = function(config) {
77
'use strict';
88

99
config.set({
10+
// maximum boot-up time allowed for a browser to start and connect to Karma
11+
// a browser gets 3x changes within this timeout range to connect to Karma
12+
// there are other timeouts as well, consult the config file
13+
// docs: https://karma-runner.github.io/1.0/config/configuration-file.html
14+
captureTimeout: 3000,
1015
// enable / disable watching file and executing tests whenever any file changes
11-
autoWatch: true,
16+
// why set to true when we have grunt watch?
17+
autoWatch: false,
1218

1319
// base path, that will be used to resolve files and exclude
1420
basePath: '../',
@@ -107,7 +113,7 @@ module.exports = function(config) {
107113
exclude: [],
108114

109115
// web server port
110-
port: 8443,
116+
// port: 8443,
111117

112118
// Start these browsers, currently available:
113119
// - Chrome
@@ -128,18 +134,12 @@ module.exports = function(config) {
128134

129135
// Continuous Integration mode
130136
// if true, it capture browsers, run tests and exit
131-
singleRun: false,
132-
133-
colors: true,
137+
singleRun: false,
134138

135139
// level of logging
136140
// possible values: LOG_DISABLE || LOG_ERROR || LOG_WARN || LOG_INFO || LOG_DEBUG
137-
logLevel: config.LOG_DEBUG,
141+
logLevel: config.LOG_ERROR,
138142

139-
// Help karma find the views on disk in the app subdirectory
140-
proxies: {
141-
'/views/': '/app/views/'
142-
},
143143
// URL root prevent conflicts with the site root
144144
// urlRoot: '_karma_'
145145

@@ -153,18 +153,15 @@ module.exports = function(config) {
153153

154154
ngHtml2JsPreprocessor: {
155155
moduleName: 'openshiftConsoleTemplates',
156-
cacheIdFromPath: function(filepath) {
157-
return filepath.replace('app/', '');
158-
},
156+
stripPrefix: '/app',
159157
},
160158

161159
reporters: ['progress', 'coverage'],
162160

163161
coverageReporter: {
164-
reporters:[
165-
{type: 'json', dir:'test/coverage/'},
166-
{type: 'text-summary', dir:'test/coverage/'}
167-
]
168-
}
162+
type: 'text',
163+
// outputs the results of coverage reporter to this dir
164+
dir: 'test-results/coverage/'
165+
},
169166
});
170167
};

test/spec/services/applicationGeneratorSpec.js

+66-70
Original file line numberDiff line numberDiff line change
@@ -255,77 +255,73 @@ describe("ApplicationGenerator", function(){
255255
});
256256

257257
it("should generate a BuildConfig for the source", function(){
258-
expect(resources.buildConfig).toEqual(
258+
var generatedBuildConfig = resources.buildConfig;
259+
260+
expect(generatedBuildConfig.apiVersion).toEqual('v1');
261+
expect(generatedBuildConfig.kind).toEqual('BuildConfig');
262+
expect(generatedBuildConfig.metadata.name).toEqual('ruby-hello-world');
263+
expect(generatedBuildConfig.metadata.labels).toEqual({
264+
"foo" : "bar",
265+
"abc" : "xyz"
266+
});
267+
expect(generatedBuildConfig.metadata.annotations).toEqual({
268+
"openshift.io/generated-by": "OpenShiftWebConsole"
269+
});
270+
expect(generatedBuildConfig.spec.output).toEqual({
271+
"to": {
272+
"name": "ruby-hello-world:latest",
273+
"kind": "ImageStreamTag"
274+
}
275+
});
276+
expect(generatedBuildConfig.spec.source).toEqual({
277+
"git": {
278+
"ref": "master",
279+
"uri": "https://github.com/openshift/ruby-hello-world.git"
280+
},
281+
"type": "Git"
282+
});
283+
expect(generatedBuildConfig.spec.strategy.type).toEqual('Source');
284+
285+
expect(generatedBuildConfig.spec.strategy.sourceStrategy.from.kind).toEqual('ImageStreamTag');
286+
expect(generatedBuildConfig.spec.strategy.sourceStrategy.from.name).toEqual('origin-ruby-sample:latest');
287+
expect(generatedBuildConfig.spec.strategy.sourceStrategy.from).toEqual({
288+
"kind": "ImageStreamTag",
289+
"name": "origin-ruby-sample:latest",
290+
"namespace": undefined
291+
});
292+
expect(generatedBuildConfig.spec.strategy.sourceStrategy.env).toEqual([
259293
{
260-
"apiVersion": "v1",
261-
"kind": "BuildConfig",
262-
"metadata": {
263-
"name": "ruby-hello-world",
264-
"labels": {
265-
"foo" : "bar",
266-
"abc" : "xyz"
267-
},
268-
"annotations": {
269-
"openshift.io/generated-by": "OpenShiftWebConsole"
270-
}
271-
},
272-
"spec": {
273-
"output": {
274-
"to": {
275-
"name": "ruby-hello-world:latest",
276-
"kind": "ImageStreamTag"
277-
}
278-
},
279-
"source": {
280-
"git": {
281-
"ref": "master",
282-
"uri": "https://github.com/openshift/ruby-hello-world.git"
283-
},
284-
"type": "Git"
285-
},
286-
"strategy": {
287-
"type": "Source",
288-
"sourceStrategy" : {
289-
"from": {
290-
"kind": "ImageStreamTag",
291-
"name": "origin-ruby-sample:latest"
292-
},
293-
"env": [
294-
{
295-
"name": "BUILD_ENV_1",
296-
"value": "someValue"
297-
},
298-
{
299-
"name": "BUILD_ENV_2",
300-
"value": "anotherValue"
301-
}
302-
]
303-
}
304-
},
305-
"triggers": [
306-
{
307-
"generic": {
308-
"secret": "secret101"
309-
},
310-
"type": "Generic"
311-
},
312-
{
313-
"github": {
314-
"secret": "secret101"
315-
},
316-
"type": "GitHub"
317-
},
318-
{
319-
"imageChange" : {},
320-
"type" : "ImageChange"
321-
},
322-
{
323-
"type": "ConfigChange"
324-
}
325-
]
326-
}
327-
}
328-
);
294+
"name": "BUILD_ENV_1",
295+
"value": "someValue"
296+
},
297+
{
298+
"name": "BUILD_ENV_2",
299+
"value": "anotherValue"
300+
}
301+
]);
302+
303+
expect(generatedBuildConfig.spec.triggers).toEqual([
304+
{
305+
"generic": {
306+
"secret": "secret101"
307+
},
308+
"type": "Generic"
309+
},
310+
{
311+
"github": {
312+
"secret": "secret101"
313+
},
314+
"type": "GitHub"
315+
},
316+
{
317+
"imageChange" : {},
318+
"type" : "ImageChange"
319+
},
320+
{
321+
"type": "ConfigChange"
322+
}
323+
]);
324+
329325
});
330326

331327
it("should generate an ImageStream for the build output", function(){

0 commit comments

Comments
 (0)