2019-05-24 08:48:01 +05:30
|
|
|
const chai = require('chai')
|
|
|
|
const chai_http = require('chai-http')
|
|
|
|
const testScript = require('./index')
|
|
|
|
|
2019-05-27 13:55:22 +05:30
|
|
|
//TESTING ONLY COVERS LS and CAT, /
|
|
|
|
// TODO: /file/mv
|
|
|
|
|
2019-05-24 08:48:01 +05:30
|
|
|
|
|
|
|
chai.use(chai_http)
|
|
|
|
|
|
|
|
let should = require('chai').should()
|
|
|
|
|
|
|
|
describe('Page Status',()=>{
|
|
|
|
it('Get /',(done)=>{
|
|
|
|
chai.request(testScript).get('/').end((err,res)=>{
|
|
|
|
res.should.have.status(200)
|
|
|
|
done()
|
|
|
|
})
|
|
|
|
})
|
|
|
|
it('POST /files/ls the home page',(done)=>{
|
|
|
|
chai.request(testScript).post('/files/ls').send({'loc':'/'}).end((err,res)=>{
|
|
|
|
res.should.have.status(200)
|
2019-05-24 11:25:10 +05:30
|
|
|
res.body.should.have.property('loc').eql('.')
|
|
|
|
|
2019-05-24 11:04:51 +05:30
|
|
|
res.body.should.have.property('back').eql(null)
|
2019-05-24 08:48:01 +05:30
|
|
|
//TODO: MAKE SURE JSON FILE
|
|
|
|
done()
|
|
|
|
})
|
|
|
|
})
|
|
|
|
it('POST ../ and fetch error',done=>{
|
|
|
|
chai.request(testScript).post('/files/ls').send({'loc':'../'}).end((err,res)=>{
|
|
|
|
res.should.have.status(404)
|
|
|
|
done()
|
|
|
|
})
|
|
|
|
})
|
2019-05-24 10:45:06 +05:30
|
|
|
it('POST for some file that does not exist',done=>{
|
|
|
|
chai.request(testScript).post('/files/ls').send({'loc':'\\'}).end((err,res)=>{
|
|
|
|
res.should.have.status(500)
|
|
|
|
done()
|
|
|
|
})
|
|
|
|
})
|
2019-05-26 21:18:35 +05:30
|
|
|
it('POST and try to download a directory',done=>{
|
|
|
|
chai.request(testScript).get('/files/cat').query({loc:'.'}).end((err,res)=>{
|
|
|
|
res.should.have.status(500)
|
|
|
|
done()
|
|
|
|
})
|
|
|
|
})
|
2019-05-24 08:48:01 +05:30
|
|
|
})
|