mirror of
https://git.sleeping.town/mirrors/foxy-moxy
synced 2024-11-24 04:57:42 +00:00
two tests
This commit is contained in:
parent
f2975db70f
commit
37590f21fb
2 changed files with 51 additions and 1 deletions
|
@ -4,7 +4,7 @@
|
|||
"description": "Makes Fox Faces",
|
||||
"main": "server.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
"test": "mocha"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
@ -21,9 +21,12 @@
|
|||
"chance": "^1.0.4",
|
||||
"express": "^4.14.0",
|
||||
"express-cluster": "0.0.4",
|
||||
"mocha": "^3.4.2",
|
||||
"newrelic": "^1.35.1",
|
||||
"node-gyp": "^3.4.0",
|
||||
"sanitize-filename": "^1.6.1",
|
||||
"sharp": "^0.18.1",
|
||||
"supertest": "^3.0.0",
|
||||
"uuid": "^3.0.1"
|
||||
}
|
||||
}
|
||||
|
|
47
test/test.js
Normal file
47
test/test.js
Normal file
|
@ -0,0 +1,47 @@
|
|||
const request = require('supertest')
|
||||
const assert = require('assert')
|
||||
const sharp = require('sharp')
|
||||
|
||||
const app = require('../server')
|
||||
|
||||
const testUID = 4125370
|
||||
|
||||
describe('Foxy-moxy', () => {
|
||||
describe('fox generation', () => {
|
||||
it('should respect widths < 400', (done) => {
|
||||
const width = 158
|
||||
request(app)
|
||||
.get(`/${width}/${testUID}`)
|
||||
.expect('Content-Type', 'image/png')
|
||||
.expect(200)
|
||||
.end(function(err, res) {
|
||||
assert(!err, String(err))
|
||||
sharp(res.body).metadata((err, metadata) => {
|
||||
assert(!err, String(err))
|
||||
assert.equal(metadata.format, 'png')
|
||||
assert.equal(metadata.height, width)
|
||||
assert.equal(metadata.width, width)
|
||||
done()
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
it('should allow max width of 400', (done) => {
|
||||
const width = 510
|
||||
request(app)
|
||||
.get(`/${width}/${testUID}`)
|
||||
.expect('Content-Type', 'image/png')
|
||||
.expect(200)
|
||||
.end(function(err, res) {
|
||||
assert(!err, String(err))
|
||||
sharp(res.body).metadata((err, metadata) => {
|
||||
assert(!err, String(err))
|
||||
assert.equal(metadata.format, 'png')
|
||||
assert.equal(metadata.height, 400)
|
||||
assert.equal(metadata.width, 400)
|
||||
done()
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
Loading…
Reference in a new issue