Skip to content

Commit 87f9d8e

Browse files
committed
setup jasmine for gulp
1 parent a119e33 commit 87f9d8e

9 files changed

+164
-402
lines changed

.travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ branches:
1111
- stable
1212
- beta
1313
before_script:
14-
- npm install -g grunt-cli
14+
- npm install -g gulp
1515
- npm install -g bower
1616
- bower install

dist/js/jquery.atwho.js

+104-104
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,110 @@
77
factory(jQuery);
88
}
99
}(function($) {
10+
var DEFAULT_CALLBACKS, KEY_CODE;
11+
12+
KEY_CODE = {
13+
DOWN: 40,
14+
UP: 38,
15+
ESC: 27,
16+
TAB: 9,
17+
ENTER: 13,
18+
CTRL: 17,
19+
A: 65,
20+
P: 80,
21+
N: 78,
22+
LEFT: 37,
23+
UP: 38,
24+
RIGHT: 39,
25+
DOWN: 40,
26+
BACKSPACE: 8,
27+
SPACE: 32
28+
};
29+
30+
DEFAULT_CALLBACKS = {
31+
beforeSave: function(data) {
32+
return Controller.arrayToDefaultHash(data);
33+
},
34+
matcher: function(flag, subtext, should_startWithSpace, acceptSpaceBar) {
35+
var _a, _y, match, regexp, space;
36+
flag = flag.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
37+
if (should_startWithSpace) {
38+
flag = '(?:^|\\s)' + flag;
39+
}
40+
_a = decodeURI("%C3%80");
41+
_y = decodeURI("%C3%BF");
42+
space = acceptSpaceBar ? "\ " : "";
43+
regexp = new RegExp(flag + "([A-Za-z" + _a + "-" + _y + "0-9_" + space + "\'\.\+\-]*)$|" + flag + "([^\\x00-\\xff]*)$", 'gi');
44+
match = regexp.exec(subtext);
45+
if (match) {
46+
return match[2] || match[1];
47+
} else {
48+
return null;
49+
}
50+
},
51+
filter: function(query, data, searchKey) {
52+
var _results, i, item, len;
53+
_results = [];
54+
for (i = 0, len = data.length; i < len; i++) {
55+
item = data[i];
56+
if (~new String(item[searchKey]).toLowerCase().indexOf(query.toLowerCase())) {
57+
_results.push(item);
58+
}
59+
}
60+
return _results;
61+
},
62+
remoteFilter: null,
63+
sorter: function(query, items, searchKey) {
64+
var _results, i, item, len;
65+
if (!query) {
66+
return items;
67+
}
68+
_results = [];
69+
for (i = 0, len = items.length; i < len; i++) {
70+
item = items[i];
71+
item.atwho_order = new String(item[searchKey]).toLowerCase().indexOf(query.toLowerCase());
72+
if (item.atwho_order > -1) {
73+
_results.push(item);
74+
}
75+
}
76+
return _results.sort(function(a, b) {
77+
return a.atwho_order - b.atwho_order;
78+
});
79+
},
80+
tplEval: function(tpl, map) {
81+
var error, error1, template;
82+
template = tpl;
83+
try {
84+
if (typeof tpl !== 'string') {
85+
template = tpl(map);
86+
}
87+
return template.replace(/\$\{([^\}]*)\}/g, function(tag, key, pos) {
88+
return map[key];
89+
});
90+
} catch (error1) {
91+
error = error1;
92+
return "";
93+
}
94+
},
95+
highlighter: function(li, query) {
96+
var regexp;
97+
if (!query) {
98+
return li;
99+
}
100+
regexp = new RegExp(">\\s*(\\w*?)(" + query.replace("+", "\\+") + ")(\\w*)\\s*<", 'ig');
101+
return li.replace(regexp, function(str, $1, $2, $3) {
102+
return '> ' + $1 + '<strong>' + $2 + '</strong>' + $3 + ' <';
103+
});
104+
},
105+
beforeInsert: function(value, $li) {
106+
return value;
107+
},
108+
beforeReposition: function(offset) {
109+
return offset;
110+
},
111+
afterMatchFailed: function(at, el) {}
112+
};
113+
10114
var App;
11115

12116
App = (function() {
@@ -984,110 +1088,6 @@ View = (function() {
9841088

9851089
})();
9861090

987-
var DEFAULT_CALLBACKS, KEY_CODE;
988-
989-
KEY_CODE = {
990-
DOWN: 40,
991-
UP: 38,
992-
ESC: 27,
993-
TAB: 9,
994-
ENTER: 13,
995-
CTRL: 17,
996-
A: 65,
997-
P: 80,
998-
N: 78,
999-
LEFT: 37,
1000-
UP: 38,
1001-
RIGHT: 39,
1002-
DOWN: 40,
1003-
BACKSPACE: 8,
1004-
SPACE: 32
1005-
};
1006-
1007-
DEFAULT_CALLBACKS = {
1008-
beforeSave: function(data) {
1009-
return Controller.arrayToDefaultHash(data);
1010-
},
1011-
matcher: function(flag, subtext, should_startWithSpace, acceptSpaceBar) {
1012-
var _a, _y, match, regexp, space;
1013-
flag = flag.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
1014-
if (should_startWithSpace) {
1015-
flag = '(?:^|\\s)' + flag;
1016-
}
1017-
_a = decodeURI("%C3%80");
1018-
_y = decodeURI("%C3%BF");
1019-
space = acceptSpaceBar ? "\ " : "";
1020-
regexp = new RegExp(flag + "([A-Za-z" + _a + "-" + _y + "0-9_" + space + "\'\.\+\-]*)$|" + flag + "([^\\x00-\\xff]*)$", 'gi');
1021-
match = regexp.exec(subtext);
1022-
if (match) {
1023-
return match[2] || match[1];
1024-
} else {
1025-
return null;
1026-
}
1027-
},
1028-
filter: function(query, data, searchKey) {
1029-
var _results, i, item, len;
1030-
_results = [];
1031-
for (i = 0, len = data.length; i < len; i++) {
1032-
item = data[i];
1033-
if (~new String(item[searchKey]).toLowerCase().indexOf(query.toLowerCase())) {
1034-
_results.push(item);
1035-
}
1036-
}
1037-
return _results;
1038-
},
1039-
remoteFilter: null,
1040-
sorter: function(query, items, searchKey) {
1041-
var _results, i, item, len;
1042-
if (!query) {
1043-
return items;
1044-
}
1045-
_results = [];
1046-
for (i = 0, len = items.length; i < len; i++) {
1047-
item = items[i];
1048-
item.atwho_order = new String(item[searchKey]).toLowerCase().indexOf(query.toLowerCase());
1049-
if (item.atwho_order > -1) {
1050-
_results.push(item);
1051-
}
1052-
}
1053-
return _results.sort(function(a, b) {
1054-
return a.atwho_order - b.atwho_order;
1055-
});
1056-
},
1057-
tplEval: function(tpl, map) {
1058-
var error, error1, template;
1059-
template = tpl;
1060-
try {
1061-
if (typeof tpl !== 'string') {
1062-
template = tpl(map);
1063-
}
1064-
return template.replace(/\$\{([^\}]*)\}/g, function(tag, key, pos) {
1065-
return map[key];
1066-
});
1067-
} catch (error1) {
1068-
error = error1;
1069-
return "";
1070-
}
1071-
},
1072-
highlighter: function(li, query) {
1073-
var regexp;
1074-
if (!query) {
1075-
return li;
1076-
}
1077-
regexp = new RegExp(">\\s*(\\w*?)(" + query.replace("+", "\\+") + ")(\\w*)\\s*<", 'ig');
1078-
return li.replace(regexp, function(str, $1, $2, $3) {
1079-
return '> ' + $1 + '<strong>' + $2 + '</strong>' + $3 + ' <';
1080-
});
1081-
},
1082-
beforeInsert: function(value, $li) {
1083-
return value;
1084-
},
1085-
beforeReposition: function(offset) {
1086-
return offset;
1087-
},
1088-
afterMatchFailed: function(at, el) {}
1089-
};
1090-
10911091
var Api;
10921092

10931093
Api = {

gulpfile.js

+11-7
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@ gulp.task('coffee', function() {
2424
gulp.task('concat', function() {
2525
fileList = [
2626
//'build/js/noConflict.js',
27+
'build/js/default.js',
2728
'build/js/app.js',
2829
'build/js/controller.js',
2930
'build/js/textareaController.js',
3031
'build/js/editableController.js',
3132
'build/js/model.js',
3233
'build/js/view.js',
33-
'build/js/default.js',
3434
'build/js/api.js'
3535
]
3636
gulp.src(fileList)
@@ -60,17 +60,21 @@ gulp.task('compress', function() {
6060

6161

6262
gulp.task('jasmine', function () {
63-
gulp.src('spec/build/javascripts/*.js')
63+
gulp.src('spec/build/javascripts/*.spec.js')
6464
.pipe(jasmine({
6565
integration: true,
66+
specHtml: "specRunner.html"
67+
/* TODO: have to add css to spec
6668
vendor: [
6769
'bower_components/jquery/dist/jquery.js',
68-
'bower_components/Caret.js/src/*.js',
69-
'bower_components/jasmine-jquery/lib/jasmine-jquery.js',
70-
'spec/build/spec_helper.js',
71-
'spec/helpers/*.js'
70+
'bower_components/Caret.js/dist/jquery.caret.js',
71+
'dist/js/jquery.atwho.js',
72+
'node_modules/jasmine-jquery/lib/*.js',
73+
'node_modules/jasmine-ajax/lib/*.js',
74+
'spec/helpers/*.js',
75+
'spec/build/spec_helper.js'
7276
],
73-
77+
*/
7478
}));
7579
});
7680

package.json

+7-4
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@
88
"homepage": "http://ichord.github.com/At.js",
99
"license": "MIT",
1010
"version": "1.4.0",
11-
"repository" : {
12-
"type" : "git",
13-
"url" : "https://github.com/ichord/At.js"
11+
"repository": {
12+
"type": "git",
13+
"url": "https://github.com/ichord/At.js"
1414
},
1515
"engines": {
1616
"node": ">= 0.6.0"
1717
},
1818
"scripts": {
19-
"test": "gulp test --verbose"
19+
"test": "gulp test"
2020
},
2121
"dependencies": {
2222
"jquery": "~1.7.0"
@@ -32,6 +32,9 @@
3232
"gulp-uglify": "^1.5.1",
3333
"gulp-umd": "^0.2.0",
3434
"gulp-util": "^3.0.7",
35+
"jasmine-ajax": "^3.2.0",
36+
"jasmine-jquery": "^2.1.1",
37+
"phantomjs": "^1.9.19",
3538
"umd-templates": "0.0.3"
3639
},
3740
"spm": {

0 commit comments

Comments
 (0)