Permalink
Browse files

Add basic tests about Koa core and middlewares

  • Loading branch information...
1 parent 5a580dd commit 6df354d8096f7a9fda20177c46c0eb6b3242aab1 @loicsaintroch loicsaintroch committed Apr 4, 2016
@@ -0,0 +1,33 @@
+'use strict';
+
+const assert = require('assert');
+
+const strapi = require('../lib/');
+
+/**
+ * No need to test everything about Koa.
+ * We just need need to make sure that everything
+ * is correctly required and loaded inside `strapi`.
+ */
+
+describe('application', function () {
+ it('`strapi.app` should be an object', function () {
+ assert(typeof strapi.app === 'object');
+ });
+
+ it('`strapi.app.use` should be a function', function () {
+ assert(typeof strapi.app.use === 'function');
+ });
+
+ it('`strapi.app.context` should be an object', function () {
+ assert(typeof strapi.app.context === 'object');
+ });
+
+ it('`strapi.app.request` should be an object', function () {
+ assert(typeof strapi.app.request === 'object');
+ });
+
+ it('`strapi.app.response` should be an object', function () {
+ assert(typeof strapi.app.response === 'object');
+ });
+});
@@ -0,0 +1,48 @@
+'use strict';
+
+const assert = require('assert');
+
+const strapi = require('../lib/');
+
+/**
+ * Make sure private functions are correctly
+ * required and loaded.
+ */
+
+describe('core', function () {
+ it('`strapi` should be an object', function () {
+ assert(typeof strapi === 'object');
+ });
+
+ it('`strapi.load` should be a function', function () {
+ assert(typeof strapi.load === 'function');
+ });
+
+ it('`strapi.initialize` should be a function', function () {
+ assert(typeof strapi.initialize === 'function');
+ });
+
+ it('`strapi.exposeGlobals` should be a function', function () {
+ assert(typeof strapi.exposeGlobals === 'function');
+ });
+
+ it('`strapi.isLocalStrapiValid` should be a function', function () {
+ assert(typeof strapi.isLocalStrapiValid === 'function');
+ });
+
+ it('`strapi.isStrapiAppSync` should be a function', function () {
+ assert(typeof strapi.isStrapiAppSync === 'function');
+ });
+
+ it('`strapi.runBootstrap` should be a function', function () {
+ assert(typeof strapi.runBootstrap === 'function');
+ });
+
+ it('`strapi.start` should be a function', function () {
+ assert(typeof strapi.start === 'function');
+ });
+
+ it('`strapi.stop` should be a function', function () {
+ assert(typeof strapi.stop === 'function');
+ });
+});
@@ -0,0 +1,31 @@
+'use strict';
+
+const assert = require('assert');
+
+const strapi = require('../lib/');
+
+/**
+ * Make sure the logger works correctly.
+ */
+
+describe('logger', function () {
+ it('`strapi.log` should be an object', function () {
+ assert(typeof strapi.log === 'object');
+ });
+
+ it('`strapi.log.verbose` should be a function', function () {
+ assert(typeof strapi.log.verbose === 'function');
+ });
+
+ it('`strapi.log.info` should be a function', function () {
+ assert(typeof strapi.log.info === 'function');
+ });
+
+ it('`strapi.log.warn` should be a function', function () {
+ assert(typeof strapi.log.warn === 'function');
+ });
+
+ it('`strapi.log.error` should be a function', function () {
+ assert(typeof strapi.log.error === 'function');
+ });
+});
@@ -0,0 +1,89 @@
+'use strict';
+
+const assert = require('assert');
+
+const strapi = require('../lib/');
+
+/**
+ * No need to test everything about Koa middlewares.
+ * We just need need to make sure that they all are
+ * correctly required and loaded inside `strapi`.
+ */
+
+describe('middlewares', function () {
+ it('`strapi.middlewares` should be an object', function () {
+ assert(typeof strapi.middlewares === 'object');
+ });
+
+ it('`strapi.middlewares.bodyparser` should be a function', function () {
+ assert(typeof strapi.middlewares.bodyparser === 'function');
+ });
+
+ it('`strapi.middlewares.compose` should be a function', function () {
+ assert(typeof strapi.middlewares.compose === 'function');
+ });
+
+ it('`strapi.middlewares.compress` should be a function', function () {
+ assert(typeof strapi.middlewares.compress === 'function');
+ });
+
+ it('`strapi.middlewares.cors` should be a function', function () {
+ assert(typeof strapi.middlewares.cors === 'function');
+ });
+
+ it('`strapi.middlewares.favicon` should be a function', function () {
+ assert(typeof strapi.middlewares.favicon === 'function');
+ });
+
+ it('`strapi.middlewares.graphql` should be a function', function () {
+ assert(typeof strapi.middlewares.graphql === 'function');
+ });
+
+ it('`strapi.middlewares.i18n` should be a function', function () {
+ assert(typeof strapi.middlewares.i18n === 'function');
+ });
+
+ it('`strapi.middlewares.ip` should be a function', function () {
+ assert(typeof strapi.middlewares.ip === 'function');
+ });
+
+ it('`strapi.middlewares.locale` should be a function', function () {
+ assert(typeof strapi.middlewares.locale === 'function');
+ });
+
+ it('`strapi.middlewares.lusca` should be a function', function () {
+ assert(typeof strapi.middlewares.lusca === 'function');
+ });
+
+ it('`strapi.middlewares.mount` should be a function', function () {
+ assert(typeof strapi.middlewares.mount === 'function');
+ });
+
+ it('`strapi.middlewares.proxy` should be a function', function () {
+ assert(typeof strapi.middlewares.proxy === 'function');
+ });
+
+ it('`strapi.middlewares.responseTime` should be a function', function () {
+ assert(typeof strapi.middlewares.responseTime === 'function');
+ });
+
+ it('`strapi.middlewares.router` should be a function', function () {
+ assert(typeof strapi.middlewares.router === 'function');
+ });
+
+ it('`strapi.middlewares.send` should be a function', function () {
+ assert(typeof strapi.middlewares.send === 'function');
+ });
+
+ it('`strapi.middlewares.session` should be a function', function () {
+ assert(typeof strapi.middlewares.session === 'function');
+ });
+
+ it('`strapi.middlewares.static` should be a function', function () {
+ assert(typeof strapi.middlewares.static === 'function');
+ });
+
+ it('`strapi.middlewares.views` should be a function', function () {
+ assert(typeof strapi.middlewares.views === 'function');
+ });
+});
View
@@ -1 +0,0 @@
---reporter dot --ui tdd --timeout 10000

0 comments on commit 6df354d

Please sign in to comment.