Skip to content
Myr

utils.js

This file

Path

test/support/utils.js

58 lines · 1.2 KiB · JavaScript

Last changed by

tests: add express.static test suiteDouglas Christopher Wilsonbefore adoption6f7a830

History of this file

Take it

The walk stopped after 200 commits: lines older than fa272ed point at it.

docs: fix typo in jsdoc commentHrvoje Šimićbefore adoptionfa272ed

lines 1–5why, one step back
1
2/**3 * Module dependencies.4 * @private5 */

tests: add express.static test suiteDouglas Christopher Wilsonbefore adoption6f7a830

line 6why, one step back
6

docs: fix typo in jsdoc commentHrvoje Šimićbefore adoptionfa272ed

line 7why, one step back
7var assert = require('assert');

tests: add express.static test suiteDouglas Christopher Wilsonbefore adoption6f7a830

line 8why, one step back
8var Buffer = require('safe-buffer').Buffer

docs: fix typo in jsdoc commentHrvoje Šimićbefore adoptionfa272ed

lines 9–13why, one step back
9
10/**11 * Module exports.12 * @public13 */

tests: add express.static test suiteDouglas Christopher Wilsonbefore adoption6f7a830

lines 14–16why, one step back
14
15exports.shouldHaveBody = shouldHaveBody16exports.shouldNotHaveBody = shouldNotHaveBody

docs: fix typo in jsdoc commentHrvoje Šimićbefore adoptionfa272ed

line 17why, one step back
17exports.shouldNotHaveHeader = shouldNotHaveHeader;

tests: add express.static test suiteDouglas Christopher Wilsonbefore adoption6f7a830

lines 18–46why, one step back
18
19/**20 * Assert that a supertest response has a specific body.21 *22 * @param {Buffer} buf23 * @returns {function}24 */2526function shouldHaveBody (buf) {27 return function (res) {28 var body = !Buffer.isBuffer(res.body)29 ? Buffer.from(res.text)30 : res.body31 assert.ok(body, 'response has body')32 assert.strictEqual(body.toString('hex'), buf.toString('hex'))33 }34}3536/**37 * Assert that a supertest response does not have a body.38 *39 * @returns {function}40 */4142function shouldNotHaveBody () {43 return function (res) {44 assert.ok(res.text === '' || res.text === undefined)45 }46}

docs: fix typo in jsdoc commentHrvoje Šimićbefore adoptionfa272ed

lines 47–58why, one step back
47
48/**49 * Assert that a supertest response does not have a header.50 *51 * @param {string} header Header name to check52 * @returns {function}53 */54function shouldNotHaveHeader(header) {55 return function (res) {56 assert.ok(!(header.toLowerCase() in res.headers), 'should not have header ' + header);57 };58}