-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Testing #92
base: master
Are you sure you want to change the base?
Testing #92
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,154 @@ | ||
/* eslint no-unused-vars: 'off' */ | ||
// const assert = require('assert'); | ||
let chai = require('chai'); | ||
let chaiHttp = require('chai-http'); | ||
let should = chai.should(); | ||
let server = require('../../app'); | ||
chai.use(chaiHttp); | ||
|
||
const dataWithBadRepeat = { | ||
password: 'pass', | ||
name: 'Super Name', | ||
email: '[email protected]', | ||
passwordRepeat: 'password' | ||
}; | ||
const dataBadSpaces = { | ||
password: ' ', | ||
name: ' ', | ||
email: ' ', | ||
passwordRepeat: ' ' | ||
}; | ||
const repeatData = { | ||
password: '1', | ||
name: 'Name', | ||
email: '[email protected]', | ||
passwordRepeat: '1' | ||
}; | ||
const dataWithInvalidEmail = { | ||
password: '1', | ||
name: 'Name', | ||
email: 'bugiMail', | ||
passwordRepeat: '1' | ||
}; | ||
|
||
describe('Sign Up', () => { | ||
it('Разные пароли', function (done) { | ||
this.timeout(4000); | ||
chai.request(server) | ||
.post('/signup') | ||
.set('Content-Type', 'application/json') | ||
.set('Accept', 'application/json') | ||
.send(dataWithBadRepeat) | ||
.end((err, res) => { | ||
res.should.have.status(409); | ||
res.body.should.be.a('object'); | ||
res.body.should.have.property('message').eql('Пароли не совпадают'); | ||
done(); | ||
}); | ||
}); | ||
|
||
it('Строки состящие из пробелов', function (done) { | ||
this.timeout(4000); | ||
chai.request(server) | ||
.post('/signup') | ||
.set('Content-Type', 'application/json') | ||
.set('Accept', 'application/json') | ||
.send(dataBadSpaces) | ||
.end((err, res) => { | ||
res.should.have.status(409); | ||
res.body.should.be.a('object'); | ||
res.body.should.have.property('message').not.eql('Пользователь с таким email уже зарегестрирован'); | ||
done(); | ||
}); | ||
}); | ||
|
||
it('Почта, которая уже существует', function (done) { | ||
this.timeout(4000); | ||
chai.request(server) | ||
.post('/signup') | ||
.set('Content-Type', 'application/json') | ||
.set('Accept', 'application/json') | ||
.send(repeatData) | ||
.end((err, res) => { | ||
res.should.have.status(409); | ||
res.body.should.be.a('object'); | ||
res.body.should.have.property('message').eql('Пользователь с таким email уже зарегестрирован'); | ||
done(); | ||
}); | ||
}); | ||
|
||
it('Невалидная почта', function (done) { | ||
this.timeout(4000); | ||
chai.request(server) | ||
.post('/signup') | ||
.set('Content-Type', 'application/json') | ||
.set('Accept', 'application/json') | ||
.send(dataWithInvalidEmail) | ||
.end((err, res) => { | ||
res.should.have.status(409); | ||
res.body.should.be.a('object'); | ||
res.body.should.have.property('message').not.eql('Пользователь с таким email уже зарегестрирован'); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
|
||
const validData = { | ||
password: '1', | ||
email: 'bugiMail' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. email не валидный There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. просто он в базе лежит, а я других паролей не помню) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. погоди, а ты прям к реальной базе подключаешься? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. честно... сам не понял. почему то только 2 прошли туда There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. по сути нужно замокать БД, это как то через proxy делается There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. тут и паспорт надо заменять получается... дикость) будет сложна))) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ага :D |
||
}; | ||
const invalidDataPass = { | ||
password: '2', | ||
email: 'bugiMail' | ||
}; | ||
const invalidDataMail = { | ||
password: '1', | ||
email: '[email protected]' | ||
}; | ||
|
||
describe('Sign In', () => { | ||
it('Валидные данные', function (done) { | ||
this.timeout(4000); | ||
chai.request(server) | ||
.post('/signin') | ||
.set('Content-Type', 'application/json') | ||
.set('Accept', 'application/json') | ||
.send(validData) | ||
.end((err, res) => { | ||
res.should.have.status(200); | ||
es.body.should.be.a('object'); | ||
res.body.should.have.property('message').eql('OK'); | ||
done(); | ||
}); | ||
}); | ||
|
||
it('Не валидный пароль', function (done) { | ||
this.timeout(4000); | ||
chai.request(server) | ||
.post('/signin') | ||
.set('Content-Type', 'application/json') | ||
.set('Accept', 'application/json') | ||
.send(invalidDataPass) | ||
.end((err, res) => { | ||
res.should.have.status(403); | ||
res.body.should.be.a('object'); | ||
res.body.should.have.property('message').eql('Неверный пароль'); | ||
done(); | ||
}); | ||
}); | ||
|
||
it('Не валидный email', function (done) { | ||
this.timeout(4000); | ||
chai.request(server) | ||
.post('/signin') | ||
.set('Content-Type', 'application/json') | ||
.set('Accept', 'application/json') | ||
.send(invalidDataMail) | ||
.end((err, res) => { | ||
res.should.have.status(403); | ||
res.body.should.be.a('object'); | ||
res.body.should.have.property('message').eql('Юзера с данным email не существует'); | ||
done(); | ||
}); | ||
}); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
зачем?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
эт случайно. ща уберу