mirror of
https://github.com/abrendan/MicDropMessages.git
synced 2025-08-25 22:12:02 +02:00
Initial commit
This commit is contained in:
19
node_modules/server/plugins/static/index.js
generated
vendored
Normal file
19
node_modules/server/plugins/static/index.js
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
const modern = require('../../src/modern');
|
||||
|
||||
module.exports = {
|
||||
name: 'static',
|
||||
options: {
|
||||
__root: 'public',
|
||||
public: {
|
||||
type: String,
|
||||
inherit: 'public',
|
||||
env: false
|
||||
}
|
||||
},
|
||||
init: ctx => {
|
||||
if (!ctx.options.static.public) return;
|
||||
module.exports.before = [
|
||||
modern(ctx.express.static(ctx.options.static.public))
|
||||
];
|
||||
}
|
||||
};
|
45
node_modules/server/plugins/static/unit.test.js
generated
vendored
Normal file
45
node_modules/server/plugins/static/unit.test.js
generated
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
const run = require('server/test/run');
|
||||
const stat = require('./');
|
||||
|
||||
const storeLog = out => ({ report: { write: log => { out.log = log; } } });
|
||||
|
||||
describe('static plugin', () => {
|
||||
it('exists', () => {
|
||||
expect(stat).toBeDefined();
|
||||
expect(stat.name).toBe('static');
|
||||
expect(stat.options).toBeDefined();
|
||||
});
|
||||
|
||||
it('static', async () => {
|
||||
const res = await run({ public: 'test' }).get('/logo.png');
|
||||
expect(res.statusCode).toBe(200);
|
||||
expect(res.headers['content-type']).toBe('image/png');
|
||||
});
|
||||
|
||||
it('non-existing static', async () => {
|
||||
let out = {};
|
||||
const log = storeLog(out);
|
||||
const res = await run({ public: 'xxxx', log }).get('/non-existing.png');
|
||||
|
||||
expect(res.statusCode).toBe(404);
|
||||
expect(out.log).toMatch(/did not return anything/);
|
||||
});
|
||||
|
||||
it('does not serve if set to false', async () => {
|
||||
let out = {};
|
||||
const log = storeLog(out);
|
||||
const res = await run({ public: false, log }).get('/logo.png');
|
||||
|
||||
expect(res.statusCode).toBe(404);
|
||||
expect(out.log).toMatch(/did not return anything/);
|
||||
});
|
||||
|
||||
it('does not serve if set to empty string', async () => {
|
||||
let out = {};
|
||||
const log = storeLog(out);
|
||||
const res = await run({ public: '', log }).get('/logo.png');
|
||||
|
||||
expect(res.statusCode).toBe(404);
|
||||
expect(out.log).toMatch(/did not return anything/);
|
||||
});
|
||||
});
|
Reference in New Issue
Block a user