2016-06-17 23:43:10 +02:00
|
|
|
describe '/user/login' do
|
|
|
|
it 'should fail if title is too short' do
|
|
|
|
result = request('/ticket/create',{
|
|
|
|
title: 'GG'
|
|
|
|
})
|
2016-06-22 01:16:43 +02:00
|
|
|
|
2016-06-17 23:43:10 +02:00
|
|
|
(result['status']).should.equal('fail')
|
2016-06-22 01:16:43 +02:00
|
|
|
(result['message']).should.equal('Title is too short')
|
2016-06-17 23:43:10 +02:00
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'should fail if title is very long' do
|
|
|
|
result = request('/ticket/create',{
|
|
|
|
title: 'I WISH I WAS THE MONSTER YOU THINK I AM. -Tyrion'
|
|
|
|
})
|
2016-06-22 01:16:43 +02:00
|
|
|
|
2016-06-17 23:43:10 +02:00
|
|
|
(result['status']).should.equal('fail')
|
2016-06-22 01:16:43 +02:00
|
|
|
(result['message']).should.equal('Title is very long')
|
2016-06-17 23:43:10 +02:00
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'should fail if content is too short' do
|
|
|
|
result = request('/ticket/create',{
|
|
|
|
title: 'Winter is coming',
|
|
|
|
content: 'Test'
|
|
|
|
})
|
2016-06-22 01:16:43 +02:00
|
|
|
|
2016-06-17 23:43:10 +02:00
|
|
|
(result['status']).should.equal('fail')
|
2016-06-22 01:16:43 +02:00
|
|
|
(result['message']).should.equal('Content is too short')
|
2016-06-17 23:43:10 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'should fail if content is very long' do
|
|
|
|
long_text = ''
|
|
|
|
600.times {long_text << 'a'}
|
|
|
|
|
|
|
|
result = request('/ticket/create',{
|
|
|
|
title: 'Winter is coming',
|
|
|
|
content: long_text
|
|
|
|
})
|
2016-06-22 01:16:43 +02:00
|
|
|
|
2016-06-17 23:43:10 +02:00
|
|
|
(result['status']).should.equal('fail')
|
2016-06-22 01:16:43 +02:00
|
|
|
(result['message']).should.equal('Content is very long')
|
2016-06-17 23:43:10 +02:00
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'should create ticket if pass data is valid' do
|
|
|
|
result = request('/ticket/create',{
|
|
|
|
title: 'Winter is coming',
|
|
|
|
content: 'The north remembers'
|
|
|
|
})
|
2016-06-22 01:16:43 +02:00
|
|
|
|
2016-06-17 23:43:10 +02:00
|
|
|
(result['status']).should.equal('success')
|
|
|
|
ticket = $database.getRow('tickets','Winter is coming','title')
|
|
|
|
(ticket['content']).should.equal('The north remembers')
|
|
|
|
end
|
|
|
|
end
|