-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: more integration tests for Get /wallet, initialize Post /wallet…
… test
- Loading branch information
Showing
2 changed files
with
91 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
require('dotenv').config(); | ||
const request = require('supertest'); | ||
const {expect} = require('chai'); | ||
const sinon = require('sinon'); | ||
const chai = require('chai'); | ||
const server = require('../server/app'); | ||
const seed = require('./seed'); | ||
chai.use(require('chai-uuid')); | ||
|
||
const {apiKey} = seed; | ||
|
||
describe('Wallet: Get wallets of an account', () => { | ||
let bearerTokenA; | ||
let bearerTokenB; | ||
|
||
before(async () => { | ||
await seed.clear(); | ||
await seed.seed(); | ||
|
||
{ | ||
// Authorizes before each of the follow tests | ||
const res = await request(server) | ||
.post('/auth') | ||
.set('treetracker-api-key', apiKey) | ||
.send({ | ||
wallet: seed.wallet.name, | ||
password: seed.wallet.password, | ||
}); | ||
|
||
expect(res).to.have.property('statusCode', 200); | ||
bearerTokenA = res.body.token; | ||
expect(bearerTokenA).to.match(/\S+/); | ||
} | ||
|
||
{ | ||
// Authorizes before each of the follow tests | ||
const res = await request(server) | ||
.post('/auth') | ||
.set('treetracker-api-key', apiKey) | ||
.send({ | ||
wallet: seed.walletB.name, | ||
password: seed.walletB.password, | ||
}); | ||
expect(res).to.have.property('statusCode', 200); | ||
bearerTokenB = res.body.token; | ||
expect(bearerTokenB).to.match(/\S+/); | ||
} | ||
}); | ||
|
||
|
||
beforeEach(async () => { | ||
sinon.restore(); | ||
}); | ||
|
||
|
||
}) |