// to get rid of "[ts] could not find module ..." in vs code realod the window: f1 -> type "reload window" // official issue for this: https://github.com/Microsoft/TypeScript/issues/10346 import {expect} from "chai"; import * as express from "express"; import { buildSchema } from "graphql"; import { GameServer } from "./GameServer"; import { CreateLabyrinthMiddleware, schemaDefinition } from "./LabyrinthMiddleware"; import { createSampleMaps } from "./SampleMaps"; // import { describe, it } from "mocha"; describe("Scenario: building the GraphQL schema", function(){ it("should not break", function(){ const notBreakingFunction = () => { buildSchema(schemaDefinition); }; expect(notBreakingFunction).to.not.throw; }); }); describe("Scenario: Creating middleware.", function(){ describe("Given the sample maps", function(){ const games = new GameServer(); const maps = createSampleMaps(); maps.forEach(m => games.addMap(m)); describe("When the middleware is created with graphiql", function(){ const graphiql = true; const notBreakingFunction = () => { CreateLabyrinthMiddleware(graphiql, games); }; it("then it should not break", function(){ expect(notBreakingFunction).to.not.throw; }); }); describe("When the middleware is created without graphiql", function(){ const graphiql = false; const notBreakingFunction = () => { CreateLabyrinthMiddleware(graphiql, games); }; it("then it should not break", function(){ expect(notBreakingFunction).to.not.throw; }); }); }); }); describe("Scenario: Starting an express server", function(){ describe("Given the sample maps, an express server and labyrinth middleware", function(){ const games = new GameServer(); const maps = createSampleMaps(); maps.forEach(m => games.addMap(m)); const app = express(); const middleware = CreateLabyrinthMiddleware(false, games); app.use("/", middleware); describe("When the server is started", function(){ it("then it should not break", function(done:Mocha.Done){ // not sure, if this is such a good construct const notBreakingFunction = () => { const server = app.listen(8081, () => { server.close(); }); }; expect(notBreakingFunction).to.not.throw; done(); }); }); }); });