From a4ebb7f56e391da609d7c8180f92abe99d7632d3 Mon Sep 17 00:00:00 2001 From: barisusakli Date: Wed, 30 Nov 2016 18:21:30 +0300 Subject: [PATCH] test plugin static assets --- test/plugins.js | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/test/plugins.js b/test/plugins.js index 9af8224dee..67709bcf49 100644 --- a/test/plugins.js +++ b/test/plugins.js @@ -4,6 +4,7 @@ var assert = require('assert'); var path = require('path'); var nconf = require('nconf'); +var request = require('request'); var db = require('./mocks/databasemock'); var plugins = require('../src/plugins'); @@ -149,6 +150,35 @@ describe('Plugins', function () { }); }); + describe('static assets', function () { + it('should 404 if resource does not exist', function (done) { + request.get(nconf.get('url') + '/plugins/doesnotexist/should404.tpl', function (err, res, body) { + assert.ifError(err); + assert.equal(res.statusCode, 404); + assert(body); + done(); + }); + }); + + it('should 404 if resource does not exist', function (done) { + request.get(nconf.get('url') + '/plugins/nodebb-plugin-dbsearch/dbsearch/templates/admin/plugins/should404.tpl', function (err, res, body) { + assert.ifError(err); + assert.equal(res.statusCode, 404); + assert(body); + done(); + }); + }); + + it('should get resource', function (done) { + request.get(nconf.get('url') + '/plugins/nodebb-plugin-dbsearch/dbsearch/templates/admin/plugins/dbsearch.tpl', function (err, res, body) { + assert.ifError(err); + assert.equal(res.statusCode, 200); + assert(body); + done(); + }); + }); + }); + });