2017-06-13 23:00:21 +00:00
|
|
|
const describe = require('mocha').describe
|
|
|
|
const it = require('mocha').it
|
2017-06-13 22:27:24 +00:00
|
|
|
const request = require('supertest')
|
|
|
|
const assert = require('assert')
|
|
|
|
const sharp = require('sharp')
|
|
|
|
|
|
|
|
const app = require('../server')
|
|
|
|
|
|
|
|
const testUID = 4125370
|
|
|
|
|
|
|
|
describe('Foxy-moxy', () => {
|
2017-06-13 23:00:21 +00:00
|
|
|
describe('fox generation', () => {
|
|
|
|
it('should respect widths < 400', (done) => {
|
|
|
|
const width = 158
|
|
|
|
request(app)
|
2017-06-13 22:27:24 +00:00
|
|
|
.get(`/${width}/${testUID}`)
|
|
|
|
.expect('Content-Type', 'image/png')
|
|
|
|
.expect(200)
|
2017-06-13 23:00:21 +00:00
|
|
|
.end(function (err, res) {
|
|
|
|
assert(!err, String(err))
|
|
|
|
sharp(res.body).metadata((err, metadata) => {
|
2017-06-13 22:27:24 +00:00
|
|
|
assert(!err, String(err))
|
2017-06-13 23:00:21 +00:00
|
|
|
assert.equal(metadata.format, 'png')
|
|
|
|
assert.equal(metadata.height, width)
|
|
|
|
assert.equal(metadata.width, width)
|
|
|
|
done()
|
|
|
|
})
|
2017-06-13 22:27:24 +00:00
|
|
|
})
|
2017-06-13 23:00:21 +00:00
|
|
|
})
|
2017-06-13 22:27:24 +00:00
|
|
|
|
2017-06-13 23:00:21 +00:00
|
|
|
it('should allow max width of 400', (done) => {
|
|
|
|
const width = 510
|
|
|
|
request(app)
|
2017-06-13 22:27:24 +00:00
|
|
|
.get(`/${width}/${testUID}`)
|
|
|
|
.expect('Content-Type', 'image/png')
|
|
|
|
.expect(200)
|
2017-06-13 23:00:21 +00:00
|
|
|
.end(function (err, res) {
|
|
|
|
assert(!err, String(err))
|
|
|
|
sharp(res.body).metadata((err, metadata) => {
|
2017-06-13 22:27:24 +00:00
|
|
|
assert(!err, String(err))
|
2017-06-13 23:00:21 +00:00
|
|
|
assert.equal(metadata.format, 'png')
|
|
|
|
assert.equal(metadata.height, 400)
|
|
|
|
assert.equal(metadata.width, 400)
|
|
|
|
done()
|
|
|
|
})
|
2017-06-13 22:27:24 +00:00
|
|
|
})
|
|
|
|
})
|
2017-06-13 23:00:21 +00:00
|
|
|
})
|
2017-06-13 22:27:24 +00:00
|
|
|
})
|