Skip to content

Commit 92ba6c0

Browse files
committed
Added linting and karma
1 parent a2a5eb8 commit 92ba6c0

File tree

7 files changed

+70
-2
lines changed

7 files changed

+70
-2
lines changed

Gulp and Visual Studio/Gulp and Visual Studio.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
<IISExpressAnonymousAuthentication />
2121
<IISExpressWindowsAuthentication />
2222
<IISExpressUseClassicPipelineMode />
23+
<UseGlobalApplicationHostFile />
2324
</PropertyGroup>
2425
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
2526
<DebugSymbols>true</DebugSymbols>
@@ -125,6 +126,7 @@
125126
<Content Include="fonts\glyphicons-halflings-regular.svg" />
126127
<Content Include="Global.asax" />
127128
<Content Include="gulpfile.js" />
129+
<Content Include="karma.conf.js" />
128130
<Content Include="Scripts\Libraries\bootstrap.js" />
129131
<Content Include="Scripts\Libraries\bootstrap.min.js" />
130132
<Content Include="Scripts\Libraries\jquery.js" />
@@ -138,6 +140,8 @@
138140
<Content Include="Scripts\Libraries\respond.js" />
139141
<Content Include="Scripts\Libraries\respond.min.js" />
140142
<Content Include="Scripts\Libraries\_references.js" />
143+
<Content Include="Scripts\main.js" />
144+
<Content Include="Scripts\Specs\tests.js" />
141145
<Content Include="Web.config" />
142146
<Content Include="Web.Debug.config">
143147
<DependentUpon>Web.config</DependentUpon>
Binary file not shown.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
describe("A suite", function () {
2+
it("contains spec with an expectation", function () {
3+
expect(foo.addTwoNumbers(1, 2)).toBe(3);
4+
});
5+
});
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
var foo = (function () {
2+
"use strict";
3+
4+
return {
5+
addTwoNumbers: function (x, y) {
6+
return x + y;
7+
}
8+
}
9+
10+
}());
11+

Gulp and Visual Studio/gulpfile.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
var gulp = require('gulp');
22
var plugins = require('gulp-load-plugins')();
33

4+
45
gulp.task('sass', function () {
56
gulp.src('./Content/*.scss')
67
.pipe(plugins.sourcemaps.init())
@@ -52,4 +53,30 @@ gulp.task('watch-sass', function () {
5253
gulp.watch('./Content/*.scss', ['sass']);
5354
});
5455

56+
var sources = ['./Scripts/*.js', '!./Scripts/libs/*.js'];
57+
58+
gulp.task('watch-lint', function () {
59+
gulp.watch(sources, ['lint']);
60+
});
61+
62+
gulp.task('lint', function () {
63+
return gulp.src(sources)
64+
.pipe(plugins.jshint({
65+
strict: true,
66+
predef: [""]
67+
}))
68+
.pipe(plugins.jshint.reporter('default'))
69+
.pipe(plugins.jshint.reporter('fail'))
70+
;
71+
});
72+
73+
var Server = require('karma').Server;
74+
75+
gulp.task('runTests', function () {
76+
new Server({
77+
configFile: __dirname + '/karma.conf.js',
78+
singleRun: true
79+
}).start();
80+
});
81+
5582
gulp.task('default', ['watch-sass']);

Gulp and Visual Studio/karma.conf.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
module.exports = function (config) {
2+
config.set({
3+
files: ['./Scripts/*.js',
4+
'./Scripts/Specs/**/*.js',
5+
],
6+
7+
exclude: ['./Scripts/libs/*.js'],
8+
9+
frameworks: ['jasmine'],
10+
11+
autoWatchBatchDelay: 1000,
12+
13+
reporters: ['progress'],
14+
15+
browsers: ['PhantomJS']
16+
});
17+
};

Gulp and Visual Studio/package.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{
1+
{
22
"scripts": { "install": "echo Done" },
33

44
"devDependencies": {
@@ -13,7 +13,11 @@
1313
"gulp-minify-css": "~1.2.1",
1414
"gulp-rev": "~5.1.0",
1515
"gulp-rev-replace": "~0.4.2",
16-
"gulp-filter": "~3.0.0"
16+
"gulp-filter": "~3.0.0",
17+
"gulp-jshint": "~1.11.2",
18+
"karma-jasmine": "~0.3.6",
19+
"karma": "~0.13.9",
20+
"karma-phantomjs-launcher": "~0.2.1"
1721

1822
}
1923
}

0 commit comments

Comments
 (0)