Skip to content

Commit d04fb52

Browse files
committed
initial commit
1 parent 600a82e commit d04fb52

4 files changed

Lines changed: 86 additions & 15 deletions

File tree

.gitignore

100644100755
Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,2 @@
1-
lib-cov
2-
*.seed
3-
*.log
4-
*.csv
5-
*.dat
6-
*.out
7-
*.pid
8-
*.gz
9-
10-
pids
11-
logs
12-
results
13-
14-
npm-debug.log
15-
node_modules
1+
.idea
2+
/bower_components

.jshintrc

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
"indent": 2,
3+
"maxlen": 120,
4+
"asi": true,
5+
"quotmark": "double",
6+
"laxcomma": true,
7+
"smarttabs": true,
8+
"trailing": true,
9+
"strict": false,
10+
"boss": false,
11+
"white": false,
12+
"newcap": true,
13+
"noarg": true,
14+
"nonew": true,
15+
"browser": true,
16+
"jquery": true,
17+
"mootools": true,
18+
"node": true,
19+
"devel": true,
20+
"undef": true,
21+
"unused": true,
22+
"latedef": true,
23+
"onecase": true,
24+
"globals": {
25+
"describe": false,
26+
"it": false,
27+
"before": false,
28+
"beforeEach": false,
29+
"after": false,
30+
"afterEach": false,
31+
"module": false,
32+
"inject": false,
33+
"define": false
34+
}
35+
}

angular-socket.io-mock.js

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
define(["bower_components/angular/angular"],function(angular){
2+
var ng = angular.module("btford.socket-io",[])
3+
ng.provider("socket",function(){
4+
this.$get = function($rootScope){
5+
6+
var obj = {}
7+
obj.events = {}
8+
obj.emits = {}
9+
10+
// intercept 'on' calls and capture the callbacks
11+
obj.on = function(eventName, callback){
12+
if(!this.events[eventName]) this.events[eventName] = []
13+
this.events[eventName].push(callback)
14+
}
15+
16+
// intercept 'emit' calls from the client and record them to assert against in the test
17+
obj.emit = function(eventName){
18+
var args = Array.prototype.slice.call(arguments,1)
19+
20+
if(!this.emits[eventName])
21+
this.emits[eventName] = []
22+
this.emits[eventName].push(args)
23+
}
24+
25+
//simulate an inbound message to the socket from the server (only called from the test)
26+
obj.receive = function(eventName){
27+
var args = Array.prototype.slice.call(arguments,1)
28+
29+
if(this.events[eventName]){
30+
angular.forEach(this.events[eventName], function(callback){
31+
$rootScope.$apply(function() {
32+
callback.apply(this, args)
33+
})
34+
})
35+
}
36+
}
37+
return obj
38+
}
39+
})
40+
})

bower.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"name": "angular-socket.io-mock",
3+
"version": "0.0.1",
4+
"dependencies": {
5+
"angular": "latest",
6+
"angular-socket-io": "latest",
7+
"requirejs": "latest"
8+
}
9+
}

0 commit comments

Comments
 (0)