-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c5924d1
commit ad7337a
Showing
13 changed files
with
185 additions
and
112 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
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
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,37 +1,37 @@ | ||
import jsonServer from 'json-server'; | ||
|
||
const port = process.env.PORT || 3001; | ||
const users = [ { | ||
'id' : 1, | ||
'name' : 'Leigh', | ||
'email' : 'helvy0@feedburner.com' | ||
}, { | ||
'id' : 2, | ||
'name' : 'Ancell', | ||
'email' : 'pancell1@gravatar.com' | ||
}, { | ||
'id' : 3, | ||
'name' : 'Conre', | ||
'email' : 'lconre2@ezinearticles.com' | ||
} ]; | ||
|
||
const messages = [ { | ||
text : 'butter property president flow nodded degree where keep', | ||
sender : 2 | ||
}, { | ||
text : 'cheese tried dig interior watch tone time train living', | ||
sender : 1 | ||
} ]; | ||
|
||
const server = jsonServer.create(); | ||
const router = jsonServer.router({ users, messages }); | ||
|
||
server.use(router); | ||
|
||
if (!process.env.TEST) { | ||
server.listen(port, () => { | ||
console.log(`Chat server is running on ${port}`); | ||
}); | ||
} | ||
|
||
export default server; | ||
import jsonServer from 'json-server'; | ||
|
||
const port = process.env.PORT || 3001; | ||
const users = [ { | ||
'id' : 1, | ||
'name' : 'Leigh', | ||
'email' : 'helvy0@feedburner.com' | ||
}, { | ||
'id' : 2, | ||
'name' : 'Ancell', | ||
'email' : 'pancell1@gravatar.com' | ||
}, { | ||
'id' : 3, | ||
'name' : 'Conre', | ||
'email' : 'lconre2@ezinearticles.com' | ||
} ]; | ||
|
||
const messages = [ { | ||
text : 'butter property president flow nodded degree where keep', | ||
sender : 2 | ||
}, { | ||
text : 'cheese tried dig interior watch tone time train living', | ||
sender : 1 | ||
} ]; | ||
|
||
const server = jsonServer.create(); | ||
const router = jsonServer.router({ users, messages }); | ||
|
||
server.use(router); | ||
|
||
if (!process.env.TEST) { | ||
server.listen(port, () => { | ||
console.log(`Chat server is running on ${port}`); | ||
}); | ||
} | ||
|
||
export default server; |
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
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
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,54 +1,53 @@ | ||
import chronicle, { supertest } from '../../src'; | ||
import app from './app'; | ||
|
||
const request = supertest(app); | ||
|
||
function contextBuilder({ test }) { | ||
return { | ||
title : test.title, | ||
group : test.parent.title | ||
}; | ||
} | ||
|
||
before(async () => { | ||
chronicle.setContextBuilder(contextBuilder); | ||
}); | ||
|
||
suite('Users'); | ||
test('Positive: show user profile', async function () { | ||
await request | ||
.with(this) | ||
.get('/users/:id') | ||
.params({ id: 1 }) | ||
.expect('Content-Type', /json/) | ||
.expect(200); | ||
}); | ||
|
||
test('Positive: change user name', async function () { | ||
await request | ||
.with(this) | ||
.patch('/users/:id') | ||
.params({ id: 2 }) | ||
.set({ 'AUTH': '5NM2p40Z8' }) | ||
.send({ name: 'McCoy' }) | ||
.expect('Content-Type', /json/) | ||
.expect(200); | ||
}); | ||
|
||
suite('Messages'); | ||
|
||
test('Positive: get list of messages', async function () { | ||
await request | ||
.with(this) | ||
.get('/messages?sender=2&limit=5') | ||
.set({ 'AUTH': '5NM2p40Z8' }) | ||
.send({ name: 'McCoy' }) | ||
.expect('Content-Type', /json/) | ||
.expect(200); | ||
}); | ||
|
||
after(async () => { | ||
await chronicle.save('./documentation/swagger.json', { reporter: 'swagger' }); | ||
await chronicle.save('./documentation/api-blueprint.md', { reporter: 'api-blueprint' }); | ||
chronicle.clear(); | ||
}); | ||
import chronicle, { supertest } from '../../src'; | ||
import app from './app'; | ||
|
||
const request = supertest(app); | ||
|
||
function contextBuilder({ test }) { | ||
return { | ||
title : test.title, | ||
group : test.parent.title | ||
}; | ||
} | ||
|
||
before(async () => { | ||
chronicle.setContextBuilder(contextBuilder); | ||
}); | ||
|
||
suite('Users'); | ||
test('Positive: show user profile', async function () { | ||
await request | ||
.with(this) | ||
.get('/users/:id') | ||
.params({ id: 1 }) | ||
.expect('Content-Type', /json/) | ||
.expect(200); | ||
}); | ||
|
||
test('Positive: change user name', async function () { | ||
await request | ||
.with(this) | ||
.patch('/users/:id') | ||
.params({ id: 2 }) | ||
.set({ 'AUTH': '5NM2p40Z8' }) | ||
.send({ name: 'McCoy' }) | ||
.expect('Content-Type', /json/) | ||
.expect(200); | ||
}); | ||
|
||
suite('Messages'); | ||
|
||
test('Positive: get list of messages', async function () { | ||
await request | ||
.with(this) | ||
.get('/messages?sender=2&limit=5') | ||
.set({ 'AUTH': '5NM2p40Z8' }) | ||
.expect('Content-Type', /json/) | ||
.expect(200); | ||
}); | ||
|
||
after(async () => { | ||
await chronicle.save('./documentation/swagger.json', { reporter: 'swagger' }); | ||
await chronicle.save('./documentation/api-blueprint.md', { reporter: 'api-blueprint' }); | ||
chronicle.clear(); | ||
}); |
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
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
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
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
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
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
Oops, something went wrong.