Skip to content

Commit

Permalink
modify search variable to validQuery and invalidQuery
Browse files Browse the repository at this point in the history
  • Loading branch information
mercyoseni committed Jun 6, 2017
1 parent adf035a commit bf968e2
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
14 changes: 7 additions & 7 deletions server/tests/api/documents.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -366,8 +366,8 @@ describe('Document API:', () => {
// GET requests -
// Search document(s): Gets all documents relevant to search query
describe('GET: (/api/search/documents?search) - ', () => {
const search = 'computer';
const term = 'abc';
const validQuery = 'computer';
const invalidQuery = 'abc';
it('should not return document(s) if search term is empty', (done) => {
request.get('/api/search/documents?search=')
.set({ Authorization: regularUserToken })
Expand All @@ -381,7 +381,7 @@ describe('Document API:', () => {

it('should not return document(s) if search term doesn\'t match',
(done) => {
request.get(`/api/search/documents?search=${term}`)
request.get(`/api/search/documents?search=${invalidQuery}`)
.set({ Authorization: regularUserToken })
.end((error, response) => {
expect(response.status).to.equal(404);
Expand All @@ -393,7 +393,7 @@ describe('Document API:', () => {

it('should return matching documents if search term match',
(done) => {
request.get(`/api/search/documents?search=${search}`)
request.get(`/api/search/documents?search=${validQuery}`)
.set({ Authorization: regularUserToken })
.end((error, response) => {
expect(response.status).to.equal(200);
Expand All @@ -406,7 +406,7 @@ describe('Document API:', () => {
it(`should search through all documents if user is admin
and return matching documents if search term match`,
(done) => {
request.get(`/api/search/documents?search=${search}`)
request.get(`/api/search/documents?search=${validQuery}`)
.set({ Authorization: adminUserToken })
.end((error, response) => {
expect(response.status).to.equal(200);
Expand All @@ -420,8 +420,8 @@ describe('Document API:', () => {
or user have the same role as owner and return matching
documents if search term match`,
(done) => {
const newSearch = 'YOYOL';
request.get(`/api/search/documents?search=${newSearch}`)
const newQuery = 'YOYOL';
request.get(`/api/search/documents?search=${newQuery}`)
.set({ Authorization: regularUserToken })
.end((error, response) => {
expect(response.status).to.equal(200);
Expand Down
8 changes: 4 additions & 4 deletions server/tests/api/roles.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,8 @@ describe('Role API:', () => {
});
// GET requests - Search role(s): Gets all roles relevant to search query
describe('GET: (/api/search/roles?search) - ', () => {
const search = 'admin';
const term = 'xyz';
const validQuery = 'admin';
const invalidQuery = 'xyz';
it('should not return role(s) if search term is empty', (done) => {
request.get('/api/search/roles?search=')
.set({ Authorization: adminUserToken })
Expand All @@ -275,7 +275,7 @@ describe('Role API:', () => {
});

it('should not return role(s) if search term doesn\'t match', (done) => {
request.get(`/api/search/roles?search=${term}`)
request.get(`/api/search/roles?search=${invalidQuery}`)
.set({ Authorization: adminUserToken })
.end((error, response) => {
expect(response.status).to.equal(404);
Expand All @@ -287,7 +287,7 @@ describe('Role API:', () => {

it('should return matching roles if search term match',
(done) => {
request.get(`/api/search/roles?search=${search}`)
request.get(`/api/search/roles?search=${validQuery}`)
.set({ Authorization: adminUserToken })
.end((error, response) => {
expect(response.status).to.equal(200);
Expand Down
8 changes: 4 additions & 4 deletions server/tests/api/users.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -540,8 +540,8 @@ describe('User API:', () => {

// GET requests - Search user(s): Gets all users relevant to search query
describe('GET: (/api/search/users?search) - ', () => {
const search = 'mercy';
const term = 'abc';
const validQuery = 'mercy';
const invalidQuery = 'abc';
it('should not return user(s) if search term is empty', (done) => {
request.get('/api/search/users?search=')
.set({ Authorization: adminUserToken })
Expand All @@ -554,7 +554,7 @@ describe('User API:', () => {
});

it('should not return user(s) if search term doesn\'t match', (done) => {
request.get(`/api/search/users?search=${term}`)
request.get(`/api/search/users?search=${invalidQuery}`)
.set({ Authorization: regularUserToken })
.end((error, response) => {
expect(response.status).to.equal(404);
Expand All @@ -566,7 +566,7 @@ describe('User API:', () => {

it('should return matching users if search term match',
(done) => {
request.get(`/api/search/users?search=${search}`)
request.get(`/api/search/users?search=${validQuery}`)
.set({ Authorization: regularUserToken })
.end((error, response) => {
expect(response.status).to.equal(200);
Expand Down

0 comments on commit bf968e2

Please sign in to comment.