Skip to content

Commit

Permalink
REFACTORING: Modified test files to get their url from vhost.js
Browse files Browse the repository at this point in the history
  • Loading branch information
Pixaria25 committed Jun 16, 2018
1 parent 5345fb5 commit 8b00bc3
Show file tree
Hide file tree
Showing 3 changed files with 95 additions and 67 deletions.
94 changes: 55 additions & 39 deletions spec/api/attribute_spec.js
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()
});
});
});
34 changes: 20 additions & 14 deletions spec/api/corpus_spec.js
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()
});
});
});
34 changes: 20 additions & 14 deletions spec/api/item_spec.js
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()
});
});
});

0 comments on commit 8b00bc3

Please sign in to comment.