Skip to content

Commit

Permalink
Still refactoring / testing
Browse files Browse the repository at this point in the history
  • Loading branch information
wejendorp committed Apr 11, 2014
1 parent 72af8e9 commit e84d237
Show file tree
Hide file tree
Showing 12 changed files with 10,373 additions and 10 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
components
node_modules
build
46 changes: 41 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,47 @@

build: components index.js
@component build --dev
BROWSERS= "ie6..11, chrome, safari, firefox"
SRC= $(wildcard index.js lib/*.js)
tests ?= *
BINS= node_modules/.bin
C= $(BINS)/component
TEST= http://localhost:4334
PHANTOM= $(BINS)/mocha-phantomjs \
--setting local-to-remote-url-access=true \
--setting web-security=false


build: node_modules components $(SRC)
@$(C) build --dev

components: component.json
@component install --dev
@$(C) install --dev

kill:
-@test -e test/pid.txt \
&& kill `cat test/pid.txt` \
&& rm -f test/pid.txt

node_modules: package.json
@npm install

server: build kill
@tests=$(tests) node test/server &
@sleep 1

test: build server
@$(PHANTOM) $(TEST)

test-browser: build server
@open $(TEST)

test-coverage: build server
@open $(TEST)/coverage

test-sauce: build server
@BROWSERS=$(BROWSERS) $(GRAVY) --url $(TEST)

clean:
rm -fr build components template.js
rm -rf components build

.PHONY: clean
.PHONY: clean server test test-browser
.PHONY: test-sauce test-coverage
10 changes: 7 additions & 3 deletions component.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,16 @@
"version": "0.0.1",
"keywords": [],
"dependencies": {
"visionmedia/superagent": "*"
"visionmedia/superagent": "*",
"component/emitter": "*"
},
"development": {
"visionmedia/debug": "0.7.4",
"ianstormtaylor/assert": "*"
},
"development": {},
"license": "MIT",
"main": "index.js",
"scripts": [
"index.js"
]
}
}
6 changes: 4 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ angular.module('ngSuperagent', ['ng'])
var Emitter = require('emitter');

var $q, $timeout, $log;
Emitter.call(agent);
Emitter(agent);

var requestProvider = {};
requestProvider.defaults = {
Expand Down Expand Up @@ -69,7 +69,9 @@ angular.module('ngSuperagent', ['ng'])
};
function providerEmit(ctx, type) {
return function() {
agent.emit.apply(ctx, Array.prototype.unshift.call(arguments, type));
var args = Array.prototype.slice.call(arguments);
Array.prototype.unshift.call(args, type);
agent.emit.apply(agent, args);
};
}
function applyTransforms(req) {
Expand Down
33 changes: 33 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"name": "angular-superagent",
"version": "0.0.0",
"description": "Angular wrapper for [Superagent](https://github.com/visionmedia/superagent).",
"main": "test/server.js",
"directories": {
"example": "examples",
"test": "test"
},
"scripts": {
"test": "make test"
},
"repository": {
"type": "git",
"url": "git://github.com/wejendorp/angular-superagent.git"
},
"author": "Jacob Wejendorp",
"license": "BSD",
"bugs": {
"url": "https://github.com/wejendorp/angular-superagent/issues"
},
"homepage": "https://github.com/wejendorp/angular-superagent",
"devDependencies": {
"component": "component/component#fa95027ce8",
"express": "~3.1.0",
"hbs": "~2.3.0",
"mocha-phantomjs": "~3.1.5",
"uglify-js": "~2.4.1",
"underscore": "~1.4.3",
"phantomjs": "~1.9.2-2",
"gravy": "*"
}
}
38 changes: 38 additions & 0 deletions test/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<!doctype html>
<html>
<head>
<title>integrations tests</title>
<link rel="stylesheet" href="test/mocha.css">
<!-- amd -->
<script src='//cdnjs.cloudflare.com/ajax/libs/require.js/2.1.9/require.js'></script>
</head>
<body>
<div id="mocha"></div>
<script src="test/mocha.js"></script>
<script>
mocha.setup({
ui: 'bdd',
ignoreLeaks: true,
slow: 300,
timeout: 10000
});
</script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.16/angular.js"></script>
<script src="http://code.angularjs.org/1.2.16/angular-mocks.js"></script>
<script src="build/build.js"></script>
<script src="test/sinon.js"></script>
<script src="test/spec/agent.js"></script>
<script>
if (window.mochaPhantomJS) {
require('debug').disable();
mochaPhantomJS.run();
} else {
require('debug').enable('*');
// require('gravy')(mocha.run());
}
mocha.run();

// angular.module('ngSuperagent').config(function(RequestProvider) { console.log(RequestProvider); }).run(function(Request) { console.log(Request); })
</script>
</body>
</html>
Loading

0 comments on commit e84d237

Please sign in to comment.