Skip to content

Commit 86fcf77

Browse files
author
paulsouche
committed
unit tests
1 parent bce32d0 commit 86fcf77

File tree

17 files changed

+777
-0
lines changed

17 files changed

+777
-0
lines changed

.bowerrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"directory": "app/vendor"
3+
}

.csslintrc

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{
2+
"important" : true,
3+
"adjoining-classes" : true,
4+
"known-properties" : true,
5+
"box-sizing" : true,
6+
"box-model" : true,
7+
"overqualified-elements" : true,
8+
"display-property-grouping" : true,
9+
"bulletproof-font-face" : true,
10+
"compatible-vendor-prefixes" : true,
11+
"regex-selectors" : true,
12+
"errors" : true,
13+
"duplicate-background-images" : true,
14+
"duplicate-properties" : true,
15+
"empty-rules" : true,
16+
"selector-max-approaching" : true,
17+
"gradients" : true,
18+
"fallback-colors" : true,
19+
"font-sizes" : true,
20+
"font-faces" : true,
21+
"floats" : true,
22+
"star-property-hack" : true,
23+
"outline-none" : true,
24+
"import" : true,
25+
"ids" : true,
26+
"underscore-property-hack" : true,
27+
"rules-count" : true,
28+
"qualified-headings" : true,
29+
"selector-max" : true,
30+
"shorthand" : true,
31+
"text-indent" : true,
32+
"unique-headings" : true,
33+
"universal-selector" : true,
34+
"unqualified-attributes" : true,
35+
"vendor-prefix" : true,
36+
"zero-units" : true
37+
}

.gitignore

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# OS X
2+
*.DS_Store
3+
._*
4+
5+
# Webstorm
6+
.idea/
7+
8+
#npm bower
9+
node_modules/
10+
vendor/
11+
12+
#Front Build Files
13+
.sass-cache
14+
.tmp
15+
dist

.jshintrc

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"undef": true,
3+
"camelcase" : true,
4+
"curly" : true,
5+
"eqeqeq" : true,
6+
"forin" : true,
7+
"immed" : true,
8+
"latedef" : true,
9+
"newcap" : true,
10+
"strict" : true,
11+
"trailing" : true,
12+
"globals": {
13+
"require": false,
14+
"define": false,
15+
"window": false,
16+
"jasmine": false,
17+
"describe":false,
18+
"it":false,
19+
"expect":false,
20+
"module":false
21+
}
22+
}

Gruntfile.js

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
module.exports = function(grunt) {
2+
'use strict';
3+
4+
require('load-grunt-tasks')(grunt);
5+
6+
grunt.initConfig({
7+
assetsDir: 'app',
8+
distDir: 'dist',
9+
testsDir: 'test',
10+
availabletasks: {
11+
tasks: {
12+
options: {
13+
filter: 'include',
14+
groups: {
15+
'Development': ['dev', 'test:unit', 'test:e2e']
16+
},
17+
sort: ['dev', 'test:unit', 'test:e2e'],
18+
descriptions: {
19+
'dev' : 'Launch the static server and watch tasks',
20+
'test:unit' : 'Run unit tests and show coverage report',
21+
'test:e2e' : 'Run end-to-end tests using webdriverJS'
22+
},
23+
tasks: ['dev', 'test:unit', 'test:e2e']
24+
}
25+
}
26+
},
27+
browserSync: {
28+
dev: {
29+
bsFiles: {
30+
src : []
31+
},
32+
options: {
33+
watchTask: true,
34+
ghostMode: {
35+
clicks: true,
36+
scroll: true,
37+
links: false,
38+
forms: false
39+
},
40+
server: {
41+
baseDir: "<%= assetsDir %>"
42+
}
43+
}
44+
}
45+
},
46+
csslint: {
47+
options: {
48+
csslintrc: '.csslintrc'
49+
},
50+
all: {
51+
src: ['<%= assets_dir %>/css/*.css']
52+
}
53+
},
54+
jasmine_node: {
55+
options: {
56+
forceExit: true,
57+
match: '.',
58+
matchall: false,
59+
extensions: 'js',
60+
specNameMatcher: 'spec'
61+
},
62+
all: ['test/e2e/']
63+
},
64+
jshint: {
65+
options: {
66+
jshintrc: '.jshintrc'
67+
},
68+
all : {
69+
src : [
70+
'<%= assetsDir %>/js/*.js','<%= testsDir %>/**/*.js'
71+
]
72+
}
73+
},
74+
karma: {
75+
dev_unit: {
76+
options: {
77+
configFile: 'test/unit/conf/unit-test-conf.js',
78+
background: true,
79+
singleRun: false,
80+
autoWatch: true,
81+
reporters: ['progress']
82+
}
83+
},
84+
dist_unit: {
85+
options: {
86+
configFile: 'test/unit/conf/unit-test-conf.js',
87+
background: false,
88+
singleRun: true,
89+
autoWatch: false,
90+
reporters: ['progress', 'coverage'],
91+
coverageReporter : {
92+
type : 'html',
93+
dir : 'reports/coverage'
94+
}
95+
}
96+
}
97+
},
98+
watch: {
99+
options : {
100+
interrupt: true
101+
},
102+
js: {
103+
files: ['<%= assetsDir %>/**/*.js','<%= testsDir %>/**/*.js'],
104+
tasks: ['newer:jshint','karma:dev_unit:run']
105+
},
106+
css: {
107+
files: ['<%= assetsDir %>/scss/**/*.scss'],
108+
tasks: ['newer:sass']
109+
}
110+
}
111+
});
112+
113+
grunt.registerTask('dev', [
114+
'browserSync',
115+
'karma:dev_unit:start',
116+
'watch'
117+
]);
118+
119+
grunt.registerTask('test:unit', [
120+
'karma:dist_unit:start'
121+
]);
122+
123+
grunt.registerTask('test:e2e', [
124+
125+
]);
126+
127+
grunt.registerTask('ls', ['availabletasks']);
128+
129+
};

app/index.html

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<!doctype html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<title>Todoliste Jquery + RequireJS</title>
6+
</head>
7+
<body>
8+
<div class="container">
9+
<h2>Todo</h2>
10+
<div>
11+
<form class="todoForm" novalidate>
12+
<input class="todo" type="text" size="30" placeholder="add new todo here"/>
13+
<button type="submit">add</button>
14+
</form>
15+
<ul class="todoList"></ul>
16+
</div>
17+
</div>
18+
<script data-main="js/config" src="vendor/requirejs/require.js"></script>
19+
</body>
20+
</html>

app/js/config.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
(function() {
2+
'use strict';
3+
4+
require.config({
5+
paths: {
6+
jQuery: '../vendor/jquery/dist/jquery.min'
7+
},
8+
shim: {
9+
jQuery: {
10+
exports: '$'
11+
}
12+
}
13+
});
14+
15+
require(['main'], function (main) {
16+
main.run();
17+
});
18+
19+
})();
20+

app/js/main.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
define(['jQuery','widgets/todoList'],function($,todoList) {
2+
'use strict';
3+
4+
return {
5+
run: function() {
6+
$(window.document).ready(function() {
7+
todoList.init();
8+
});
9+
}
10+
};
11+
12+
});

app/js/widgets/todoList.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
define(['jQuery'],function($) {
2+
'use strict';
3+
4+
return {
5+
init: function() {
6+
var todos = [];
7+
8+
$('.todoForm').on('submit',function(event) {
9+
var todolist = $('.todoList'),
10+
todoVal = $('.todo').val(),
11+
remove = function () {
12+
var todo = $(this);
13+
todos.splice($.inArray(todo.text(),todos),1);
14+
todo.remove();
15+
};
16+
17+
event.preventDefault();
18+
if (todoVal && $.inArray(todoVal,todos) < 0) {
19+
todos.push(todoVal);
20+
todolist.append(function() {
21+
return $('<li><span>' + todoVal + '</span></li>').click(remove);
22+
});
23+
}
24+
25+
});
26+
}
27+
};
28+
29+
});

bower.json

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"name": "devFactory-jquery-requirejs",
3+
"version": "0.0.1",
4+
"homepage": "https://github.com/paulsouche/devFactory-jquery-requirejs",
5+
"authors": [
6+
"paulsouche"
7+
],
8+
"description": "empty dev factory to bootstrap a project with jquery and requirejs",
9+
"main": "GruntFile.js",
10+
"moduleType": [
11+
"node"
12+
],
13+
"keywords": [
14+
"devFactory",
15+
"tests",
16+
"unit",
17+
"e2e",
18+
"endtoend",
19+
"requirejs",
20+
"jquery"
21+
],
22+
"license": "MIT",
23+
"devDependencies": {
24+
"squire": "~0.2.0",
25+
"jasmine.async": "~0.1.0"
26+
},
27+
"dependencies": {
28+
"requirejs": "~2.1.14",
29+
"jquery": "~2.1.1"
30+
}
31+
}

0 commit comments

Comments
 (0)