Last active
          June 29, 2019 14:43 
        
      - 
      
 - 
        
Save josherich/6070af07372776b9c00e40c89307816a to your computer and use it in GitHub Desktop.  
    test utils
  
        
  
    
      This file contains hidden or 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
    
  
  
    
  | // https://github.com/sindresorhus/query-string/blob/master/test/extract.js | |
| import test from 'ava'; | |
| import queryString from '..'; | |
| test('handles strings not containing query string', t => { | |
| t.is(queryString.extract('https://foo.bar'), ''); | |
| t.is(queryString.extract('https://foo.bar#top'), ''); | |
| t.is(queryString.extract(''), ''); | |
| }); | |
| test('throws for invalid values', t => { | |
| t.throws(() => { | |
| queryString.extract(null); | |
| }, TypeError); | |
| t.throws(() => { | |
| queryString.extract(undefined); | |
| }, TypeError); | |
| }); | 
  
    
      This file contains hidden or 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
    
  
  
    
  | const supertest = require('supertest'); | |
| let server; | |
| beforeAll(() => {}) | |
| afterAll(() => {}) | |
| beforeEach(() => {}) | |
| afterEach(() => {}) | |
| expect(response.status).toBe(403); | |
| expect(await some_parser.parseString("")).toMatchObject({ key: value }); | |
| describe('suite', () => { | |
| it(`test case`, async () => { | |
| server = require('../../lib/index').server; | |
| const request = supertest(server); | |
| const response = await request.get('/test/1'); | |
| // check using expect | |
| }) | |
| }); | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment