65 lines
1.8 KiB
CoffeeScript
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()
|
|
)
|
|
)
|
|
)
|
|
)
|
|
)
|