Fix failing image and login tests
This commit is contained in:
parent
0910b16e1e
commit
3091c6dff6
2 changed files with 25 additions and 12 deletions
|
@ -1,4 +1,5 @@
|
||||||
import assert from 'assert';
|
import assert from 'assert';
|
||||||
|
import gm from 'gm';
|
||||||
import { agent } from 'supertest';
|
import { agent } from 'supertest';
|
||||||
import app from '../../app';
|
import app from '../../app';
|
||||||
|
|
||||||
|
@ -45,7 +46,9 @@ describe('hostr-web file', function() {
|
||||||
.expect(200)
|
.expect(200)
|
||||||
.expect('Content-type', 'image/jpeg')
|
.expect('Content-type', 'image/jpeg')
|
||||||
.expect(function(response) {
|
.expect(function(response) {
|
||||||
assert(response.body.length === 3658);
|
gm(response.body).size((err, size) => {
|
||||||
|
assert(size.width === 150);
|
||||||
|
});
|
||||||
})
|
})
|
||||||
.end(done);
|
.end(done);
|
||||||
});
|
});
|
||||||
|
@ -58,7 +61,9 @@ describe('hostr-web file', function() {
|
||||||
.expect(200)
|
.expect(200)
|
||||||
.expect('Content-type', 'image/jpeg')
|
.expect('Content-type', 'image/jpeg')
|
||||||
.expect(function(response) {
|
.expect(function(response) {
|
||||||
assert(response.body.length === 79091);
|
gm(response.body).size((err, size) => {
|
||||||
|
assert(size.width === 970);
|
||||||
|
});
|
||||||
})
|
})
|
||||||
.end(done);
|
.end(done);
|
||||||
});
|
});
|
||||||
|
|
|
@ -6,21 +6,29 @@ const request = agent(app.listen());
|
||||||
describe('hostr-web user', function() {
|
describe('hostr-web user', function() {
|
||||||
describe('when POST /signin with invalid credentials', function() {
|
describe('when POST /signin with invalid credentials', function() {
|
||||||
it('should not redirect to /', function(done) {
|
it('should not redirect to /', function(done) {
|
||||||
request
|
request.get('/signin').end(function(err, response) {
|
||||||
.post('/signin')
|
const match = response.text.match(/name="_csrf" value="([^"]+)"/);
|
||||||
.send({'email': 'test@hostr.co', 'password': 'test-passworddeded'})
|
const csrf = match[1];
|
||||||
.expect(200, done);
|
request
|
||||||
|
.post('/signin')
|
||||||
|
.send({'email': 'test@hostr.co', 'password': 'test-passworddeded', '_csrf': csrf})
|
||||||
|
.expect(200, done);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('when POST /signin with valid credentials', function() {
|
describe('when POST /signin with valid credentials', function() {
|
||||||
it('should redirect to /', function(done) {
|
it('should redirect to /', function(done) {
|
||||||
request
|
request.get('/signin').end(function(err, response) {
|
||||||
.post('/signin')
|
const match = response.text.match(/name="_csrf" value="([^"]+)"/);
|
||||||
.send({'email': 'test@hostr.co', 'password': 'test-password'})
|
const csrf = match[1];
|
||||||
.expect(302)
|
request
|
||||||
.expect('Location', '/')
|
.post('/signin')
|
||||||
.end(done);
|
.send({'email': 'test@hostr.co', 'password': 'test-password', '_csrf': csrf})
|
||||||
|
.expect(302)
|
||||||
|
.expect('Location', '/')
|
||||||
|
.end(done);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue