sum7/warehost-frontend
sum7
/
warehost-frontend
Archived
1
0
Fork 0
This repository has been archived on 2020-09-27. You can view files and clone it, but cannot push or open issues or pull requests.
warehost-frontend/tests/modul/web.coffee

65 lines
1.8 KiB
CoffeeScript

expect = require("chai").expect
request = require('request')
lib = require('../lib')
config = require('../config')
module.exports = ()->
describe('web',->
describe('involve',->
it('-> not logged in',(done)->
request({method: 'GET',uri:config.ADDRESS+"/web/involve"},(err,res,body)->
expect(err).to.be.null
expect(res.statusCode).to.be.equal(200)
if(typeof body == "string")
body = JSON.parse(body)
expect(body.error).to.not.be.undefined
expect(body.data).to.be.false
done()
)
)
it('-> validate',(done)->
lib.login({username:'test_used',password:'test'},(j,login)->
request({method: 'GET',uri:config.ADDRESS+"/web/involve",jar:j},(err,res,body)->
expect(err).to.be.null
expect(res.statusCode).to.be.equal(200)
if(typeof body == "string")
body = JSON.parse(body)
expect(body.error).to.be.undefined
expect(body.data).to.be.a("array")
done()
)
)
)
)
describe('add website',->
it('-> not logged in',(done)->
request({method: 'POST',uri:config.ADDRESS+"/web/website"},(err,res,body)->
expect(err).to.be.null
expect(res.statusCode).to.be.equal(200)
if(typeof body == "string")
body = JSON.parse(body)
expect(body.error).to.not.be.undefined
expect(body.data).to.be.false
done()
)
)
it('-> validate',(done)->
lib.login({username:'test_used',password:'test'},(j,login)->
request({method: 'POST',uri:config.ADDRESS+"/web/website",json:{
name: "FireSystem"
},jar:j},(err,res,body)->
expect(err).to.be.null
expect(res.statusCode).to.be.equal(200)
if(typeof body == "string")
body = JSON.parse(body)
expect(body.error).to.be.undefined
expect(body.data).to.be.true
done()
)
)
)
)
)