forked from Hypertopic/Tire-a-part
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
REFACTORING: Modified test files to get their url from vhost.js
- Loading branch information
Showing
3 changed files
with
95 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,66 @@ | ||
const frisby = require('frisby'); | ||
const Joi = frisby.Joi; // Frisby exports Joi for convenience on type assersions | ||
const V = require('./vhost'); | ||
|
||
it ('GET should return a status of 200 OK', function () { | ||
return frisby | ||
.get('http://tireapart.local:5984/attribute/UTT/') | ||
.expect('status', 200); | ||
}); | ||
describe('GET /attribute/C/', function() | ||
{ | ||
const uri = V.HOST + '/attribute/UTT'; | ||
|
||
it('should have a JSON Content-Type header', function () { | ||
return frisby.get('http://tireapart.local:5984/attribute/UTT/') | ||
.expect('header', 'Content-Type', 'application/json'); | ||
}); | ||
it ('should return a status of 200 OK', function () { | ||
return frisby | ||
.get(uri) | ||
.expect('status', 200); | ||
}); | ||
|
||
it('should not return an error', function () { | ||
return frisby.get('https://httpbin.org/headers') | ||
// Should not return an error | ||
.expectNot('json', { result: 'error' }); | ||
}); | ||
it('should have a JSON Content-Type header', function () { | ||
return frisby.get(uri) | ||
.expect('header', 'Content-Type', 'application/json'); | ||
}); | ||
|
||
it ('GET /attribute/C/ should return an array of keys and a value', function () { | ||
return frisby | ||
.get('http://tireapart.local:5984/attribute/UTT/') | ||
.expect('status', 200) | ||
.expect('jsonTypes', 'rows.*', { // Assert *each* object in 'items' array | ||
'key': Joi.array().required(), | ||
'value': Joi.number().required() | ||
}); | ||
it('should not return an error', function () { | ||
return frisby.get(uri) | ||
// Should not return an error | ||
.expectNot('json', { result: 'error' }); | ||
}); | ||
|
||
it ('should return an array of keys and a value', function () { | ||
return frisby | ||
.get(uri) | ||
.expect('status', 200) | ||
.expect('jsonTypes', 'rows.*', { // Assert *each* object in 'items' array | ||
'key': Joi.array().required(), | ||
'value': Joi.number().required() | ||
}); | ||
}); | ||
}); | ||
|
||
it ('GET /attribute/C/A/ should return an array of keys and a value', function () { | ||
return frisby | ||
.get('http://tireapart.local:5984/attribute/UTT/DC.publisher') | ||
.expect('status', 200) | ||
.expect('jsonTypes', 'rows.*', { // Assert *each* object in 'items' array | ||
'key': Joi.array().required(), | ||
'value': Joi.number().required() | ||
}); | ||
describe('GET /attribute/C/', function() | ||
{ | ||
const uri = V.HOST + '/attribute/UTT/DC.publisher'; | ||
|
||
it ('GET /attribute/C/A/ should return an array of keys and a value', function () { | ||
return frisby | ||
.get(uri) | ||
.expect('status', 200) | ||
.expect('jsonTypes', 'rows.*', { // Assert *each* object in 'items' array | ||
'key': Joi.array().required(), | ||
'value': Joi.number().required() | ||
}); | ||
}); | ||
}); | ||
|
||
it ('GET /attribute/C/A/V should return an id, an array of keys and a value', function () { | ||
return frisby | ||
.get('http://tireapart.local:5984/attribute/UTT/DC.publisher/ACM') | ||
.expect('status', 200) | ||
.expect('jsonTypes', 'rows.*', { // Assert *each* object in 'items' array | ||
'id': Joi.string().required(), | ||
'key': Joi.array().required(), | ||
'value': Joi.object().required() | ||
}); | ||
describe('GET /attribute/C/A/V', function() | ||
{ | ||
const uri = V.HOST + '/attribute/UTT/DC.publisher/ACM'; | ||
|
||
it ('should return an id, an array of keys and a value', function () { | ||
return frisby | ||
.get(uri) | ||
.expect('status', 200) | ||
.expect('jsonTypes', 'rows.*', { // Assert *each* object in 'items' array | ||
'id': Joi.string().required(), | ||
'key': Joi.array().required(), | ||
'value': Joi.object().required() | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,25 @@ | ||
const frisby = require('frisby'); | ||
const Joi = frisby.Joi; // Frisby exports Joi for convenience on type assersions | ||
const V = require('./vhost'); | ||
|
||
it ('GET should return a status of 200 OK', function () { | ||
return frisby | ||
.get('http://tireapart.local:5984/corpus/UTT/') | ||
.expect('status', 200); | ||
}); | ||
describe('GET /corpus/C/', function() | ||
{ | ||
const uri = V.HOST + '/corpus/UTT'; | ||
|
||
it ('should return a status of 200 OK', function () { | ||
return frisby | ||
.get(uri) | ||
.expect('status', 200); | ||
}); | ||
|
||
it ('GET /corpus/C/ should return an array of keys and a value', function () { | ||
return frisby | ||
.get('http://tireapart.local:5984/corpus/UTT/') | ||
.expect('status', 200) | ||
.expect('jsonTypes', 'rows.*', { // Assert *each* object in 'items' array | ||
'id': Joi.string().required(), | ||
'key': Joi.array().required(), | ||
'value': Joi.object().required() | ||
}); | ||
it ('should return an array of keys and a value', function () { | ||
return frisby | ||
.get(uri) | ||
.expect('status', 200) | ||
.expect('jsonTypes', 'rows.*', { // Assert *each* object in 'items' array | ||
'id': Joi.string().required(), | ||
'key': Joi.array().required(), | ||
'value': Joi.object().required() | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,25 @@ | ||
const frisby = require('frisby'); | ||
const Joi = frisby.Joi; // Frisby exports Joi for convenience on type assersions | ||
const V = require('./vhost'); | ||
|
||
it ('GET should return a status of 200 OK', function () { | ||
return frisby | ||
.get('http://tireapart.local:5984/item/UTT/1fd0ab35225b9a7796149762e87a7e63') | ||
.expect('status', 200); | ||
}); | ||
describe('GET /user/ID', function() | ||
{ | ||
const uri = V.HOST + '/item/UTT/007f0eb5cb689c041bd224830f6b7d63'; | ||
|
||
it ('should return a status of 200 OK', function () { | ||
return frisby | ||
.get(uri) | ||
.expect('status', 200); | ||
}); | ||
|
||
it ('GET /item/C/I should return an array of keys and a value', function () { | ||
return frisby | ||
.get('http://tireapart.local:5984/item/UTT/007f0eb5cb689c041bd224830f6b7d63') | ||
.expect('status', 200) | ||
.expect('jsonTypes', 'rows.*', { // Assert *each* object in 'items' array | ||
'id': Joi.string().required(), | ||
'key': Joi.array().required(), | ||
'value': Joi.object().required() | ||
}); | ||
it ('should return an array of keys and a value', function () { | ||
return frisby | ||
.get(uri) | ||
.expect('status', 200) | ||
.expect('jsonTypes', 'rows.*', { // Assert *each* object in 'items' array | ||
'id': Joi.string().required(), | ||
'key': Joi.array().required(), | ||
'value': Joi.object().required() | ||
}); | ||
}); | ||
}); |