Add some basic test suites

This commit is contained in:
2019-09-15 13:15:21 +05:30
parent f3842d3901
commit 2e57ebe609
2 changed files with 25 additions and 7 deletions

View File

@@ -7,7 +7,7 @@ const processing = require('./processing')
const busboy = require('connect-busboy') const busboy = require('connect-busboy')
// Import settings // Import settings
let settings = JSON.parse(fs.readFileSync("settings.json")) const settings = JSON.parse(fs.readFileSync("settings.json"))
app = express() app = express()
app.use(bodyParser.urlencoded({extended:false})) app.use(bodyParser.urlencoded({extended:false}))

30
test.js
View File

@@ -1,15 +1,34 @@
const chai = require('chai') const chai = require('chai')
const chai_http = require('chai-http') const chai_http = require('chai-http')
const testScript = require('./index') const fs = require('fs')
//TESTING ONLY COVERS LS and CAT, /
// TODO: /file/mv
chai.use(chai_http) chai.use(chai_http)
let should = require('chai').should() let should = require('chai').should()
//TESTING ONLY COVERS LS and CAT
// TODO: /file/mv
// TODO: /file/upload
describe('Readup and start server',()=>{
it('Have a settings.json',done=>{
fs.existsSync("settings.json").should.be.true;
done()
})
it('Read up required files',done=>{
let settings = JSON.parse(fs.readFileSync("settings.json"))
should.exist(settings.dirname)
done()
})
})
const testScript = require('./index')
describe('Page Status',()=>{ describe('Page Status',()=>{
it('Get /',(done)=>{ it('Get /',(done)=>{
chai.request(testScript).get('/').end((err,res)=>{ chai.request(testScript).get('/').end((err,res)=>{
@@ -21,7 +40,6 @@ describe('Page Status',()=>{
chai.request(testScript).post('/files/ls').send({'loc':'/'}).end((err,res)=>{ chai.request(testScript).post('/files/ls').send({'loc':'/'}).end((err,res)=>{
res.should.have.status(200) res.should.have.status(200)
res.body.should.have.property('loc').eql('.') res.body.should.have.property('loc').eql('.')
res.body.should.have.property('back').eql(null) res.body.should.have.property('back').eql(null)
//TODO: MAKE SURE JSON FILE //TODO: MAKE SURE JSON FILE
done() done()