Skip to content

Instantly share code, notes, and snippets.

@rynkis
Created September 20, 2019 08:05
Show Gist options
  • Select an option

  • Save rynkis/226023c99a170b5828821d69208b3cbe to your computer and use it in GitHub Desktop.

Select an option

Save rynkis/226023c99a170b5828821d69208b3cbe to your computer and use it in GitHub Desktop.

Revisions

  1. rynkis created this gist Sep 20, 2019.
    25 changes: 25 additions & 0 deletions token.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,25 @@
    const should = require('should')
    const request = require('supertest')

    const app = require('/path/to/app').default.app
    const { describe, it } = global

    const username = 'username'
    const password = 'password'

    describe('token api test', () => {
    describe('get token: login', () => {
    it('should without error', async () => {
    const res = await request(app).post(`/token`)
    .set('Accept', 'application/json')
    .send({ username, password })
    .expect(200)
    .expect('Content-Type', /json/)

    should(res.body.code).be.equal(0)
    should(res.body.data).be.a.Object()
    should(res.body.data.token).be.a.String()
    should(res.body.data.refresh_token).be.a.String()
    })
    })
    })