Skip to content
Browse files

test base + fix package.json

  • Loading branch information...
1 parent fe88bbf commit c1925cfb2d185fc336af388679a469f604be8a93 @Unitech committed May 15, 2013
Showing with 99 additions and 49 deletions.
  1. +47 −29 package.json
  2. +4 −0 test/mocha.opts
  3. +48 −20 test/test.js
View
76 package.json
@@ -1,31 +1,49 @@
{
- "name": "angular-bridge",
- "author": {
- "name": "Alexandre Strzelewicz"
- },
- "description": "Mongoose Express Angular resources bridge",
- "version": "0.3.3",
- "main": "./index.js",
- "private": false,
- "dependencies": {
- "underscore": "1.x"
- },
- "repository": {
- "type": "git",
- "url": "git://github.com/Alexandre-Strzelewicz/angular-bridge.git"
- },
- "devDependencies": {
- "mocha": "*",
- "should": "~1.2.2",
- "supertest": "~0.6.0"
- },
- "homepage": "https://github.com/Alexandre-Strzelewicz/angular-bridge",
- "readmeFilename": "README.md",
- "_npmUser": {
- "name": "tknew",
- "email": "strzelewicz.alexandre@gmail.com"
- },
- "engines": {
- "node": "*"
- }
+ "name": "angular-bridge",
+ "author": {
+ "name": "Alexandre Strzelewicz",
+ "email" : "strzelewicz.alexandre@gmail.com",
+ "url" : "http://apps.hemca.com"
+ },
+ "description": "Mongoose Express Angular resources bridge",
+ "version": "0.3.4",
+ "main": "./index.js",
+ "private": false,
+ "dependencies": {
+ "underscore": "1.x",
+ "mongoose" : "*",
+ "express" : "*"
+ },
+ "scripts" : {
+ "test" : "NODE_ENV=test ./node_modules/mocha/bin/mocha test"
+ },
+ "keywords": [
+ "angular js",
+ "mongodb",
+ "mongo",
+ "REST",
+ "angularjs",
+ "angular-bridge",
+ "link model",
+ "mongoose"
+ ],
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/Alexandre-Strzelewicz/angular-bridge.git"
+ },
+ "devDependencies": {
+ "mocha": "*",
+ "should": "~1.2.2",
+ "supertest": "~0.6.0",
+ "request" : "*"
+ },
+ "homepage": "https://github.com/Alexandre-Strzelewicz/angular-bridge",
+ "readmeFilename": "README.md",
+ "_npmUser": {
+ "name": "tknew",
+ "email": "strzelewicz.alexandre@gmail.com"
+ },
+ "engines": {
+ "node": "*"
+ }
}
View
4 test/mocha.opts
@@ -0,0 +1,4 @@
+--require should
+--reporter spec
+--timeout 60000
+--slow 600
View
68 test/test.js
@@ -1,42 +1,70 @@
var should = require("should"),
- request = require("supertest"),
+ supertest = require("supertest"),
angularBridge = require("../index"),
express = require("express"),
+ request = require('request'),
mongoose = require("mongoose"),
+ http = require('http'),
schema = require("./schema");
+const URL = 'http://localhost:4000/';
+const RESOURCE = 'pizzasto';
+
describe('Angular-bridge', function(){
var bridge;
var app;
-
- beforeEach(function(done){
+ var server;
+
+ before(function(done){
app = express();
app.use(express.bodyParser());
bridge = new angularBridge(app, null);
- bridge.addResource('pizzas', schema.Pizza);
- done();
+ bridge.addResource(RESOURCE, schema.Pizza);
+
+ server = http.createServer(app);
+
+ server.listen(4000, function(){
+ done();
+ });
+
});
- it('GET /pizzas', function(done){
- request(app)
- .get('/pizzas')
- .expect(200, done);
+ after(function() {
+ server.close();
});
- it('POST /pizzas', function(done){
- request(app)
- .post('/pizzas')
- .send({author: "Author", color: "black", size: 4, password: "secret"})
- .expect(200, done);
+ describe('Right status', function() {
+ it('GET /pizzas', function(done){
+ supertest(app)
+ .get('/' + RESOURCE)
+ .expect(200, done);
+ });
+
+ it('POST /pizzas', function(done){
+ supertest(app)
+ .post('/' + RESOURCE)
+ .send({author: "Author", color: "black", size: 4, password: "secret"})
+ .expect(200, done);
+ });
+
+ it('POST /pizza - invalid data', function(done){
+ supertest(app)
+ .post('/' + RESOURCE)
+ .send({author: "Author", color: "black", size: "four", password: "secret"})
+ .expect(400, done);
+ });
});
- it('POST /pizza - invalid data', function(done){
- request(app)
- .post('/pizzas')
- .send({author: "Author", color: "black", size: "four", password: "secret"})
- .expect(400, done);
- });
+ describe('Data exchange', function() {
+
+ it.skip('should get nothing', function(done) {
+ request(URL + RESOURCE, function(err, req, body) {
+
+ });
+ });
+
+ });
});

0 comments on commit c1925cf

Please sign in to comment.
Something went wrong with that request. Please try again.