mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 02:35:49 +00:00
test(static) /cloudcmd.js
This commit is contained in:
parent
02bac76d1a
commit
e2950fbdef
2 changed files with 59 additions and 0 deletions
|
|
@ -8,6 +8,8 @@ const io = require('socket.io');
|
|||
const writejson = require('writejson');
|
||||
const readjson = require('readjson');
|
||||
|
||||
process.env.NODE_ENV = 'development';
|
||||
|
||||
const cloudcmd = require('../server/cloudcmd');
|
||||
const {assign} = Object;
|
||||
|
||||
|
|
|
|||
|
|
@ -52,3 +52,60 @@ test('cloudcmd: static: not found', (t) => {
|
|||
});
|
||||
});
|
||||
|
||||
test('cloudcmd: prefix: wrong', (t) => {
|
||||
const prefix = '/hello';
|
||||
const config = {prefix};
|
||||
|
||||
before({config}, (port, after) => {
|
||||
const name = Math.random();
|
||||
|
||||
get(`http://localhost:${port}/${name}`)
|
||||
.then((res) => {
|
||||
res.on('response', ({statusCode}) => {
|
||||
t.equal(statusCode, 404, 'should return 404');
|
||||
});
|
||||
res.on('end', () => {
|
||||
t.end();
|
||||
after();
|
||||
});
|
||||
})
|
||||
.catch(console.error);
|
||||
});
|
||||
});
|
||||
|
||||
test('cloudcmd: /cloudcmd.js', (t) => {
|
||||
before({}, (port, after) => {
|
||||
const name = 'cloudcmd.js';
|
||||
|
||||
get(`http://localhost:${port}/${name}`)
|
||||
.then((res) => {
|
||||
res.on('response', ({statusCode}) => {
|
||||
t.equal(statusCode, 200, 'should return OK');
|
||||
});
|
||||
res.on('end', () => {
|
||||
t.end();
|
||||
after();
|
||||
});
|
||||
})
|
||||
.catch(console.error);
|
||||
});
|
||||
});
|
||||
|
||||
test('cloudcmd: /logout', (t) => {
|
||||
before({}, (port, after) => {
|
||||
const name = 'logout';
|
||||
|
||||
get(`http://localhost:${port}/${name}`)
|
||||
.then((res) => {
|
||||
res.on('response', ({statusCode}) => {
|
||||
t.equal(statusCode, 401, 'should return 401');
|
||||
});
|
||||
res.on('end', () => {
|
||||
t.end();
|
||||
after();
|
||||
});
|
||||
})
|
||||
.catch(console.error);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue