describe '/user/login' do it 'should fail if title is too short' do result = request('/ticket/create',{ title: 'GG' }) (result['status']).should.equal('fail') (result['message']).should.equal('title is too short') 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' }) (result['status']).should.equal('fail') (result['message']).should.equal('title is very long') end it 'should fail if content is too short' do result = request('/ticket/create',{ title: 'Winter is coming', content: 'Test' }) (result['status']).should.equal('fail') (result['message']).should.equal('content is too short') 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 }) (result['status']).should.equal('fail') (result['message']).should.equal('content is very long') end it 'should create ticket if pass data is valid' do result = request('/ticket/create',{ title: 'Winter is coming', content: 'The north remembers' }) (result['status']).should.equal('success') ticket = $database.getRow('tickets','Winter is coming','title') (ticket['content']).should.equal('The north remembers') end end