mirror of
https://github.com/codex-team/codex.docs.git
synced 2025-08-07 14:35:26 +02:00
fixing testing code
This commit is contained in:
parent
6e5af27f8f
commit
28b67c3652
6 changed files with 28 additions and 28 deletions
|
@ -1,9 +1,9 @@
|
|||
import fs from "fs";
|
||||
import config from "config";
|
||||
import { expect } from "chai";
|
||||
import Datastore from "nedb";
|
||||
import fs from 'fs';
|
||||
import config from 'config';
|
||||
import { expect } from 'chai';
|
||||
import Datastore from 'nedb';
|
||||
|
||||
import { Database } from "../src/utils/database";
|
||||
import { Database } from '../src/utils/database';
|
||||
|
||||
interface Document {
|
||||
data?: any;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import chaiHTTP from "chai-http";
|
||||
import chai, { expect } from "chai";
|
||||
import chaiHTTP from 'chai-http';
|
||||
import chai, { expect } from 'chai';
|
||||
|
||||
import server from "../bin/server";
|
||||
import server from '../bin/server';
|
||||
|
||||
const app = server.app;
|
||||
|
||||
|
|
|
@ -103,7 +103,7 @@ describe('File model', () => {
|
|||
expect(savedFile.size).to.equal(initialData.size);
|
||||
expect(savedFile.mimetype).to.equal(initialData.mimetype);
|
||||
|
||||
const insertedFile = await files.findOne({_id: file._id}) as File;
|
||||
const insertedFile = await files.findOne({_id: file._id});
|
||||
|
||||
expect(insertedFile._id).to.equal(file._id);
|
||||
expect(insertedFile.name).to.equal(file.name);
|
||||
|
@ -126,7 +126,7 @@ describe('File model', () => {
|
|||
|
||||
expect(file._id).to.equal(insertedFile._id);
|
||||
|
||||
const updatedFile = await files.findOne({_id: file._id}) as File;
|
||||
const updatedFile = await files.findOne({_id: file._id});
|
||||
|
||||
expect(updatedFile._id).to.equal(savedFile._id);
|
||||
expect(updatedFile.name).to.equal(updateData.name);
|
||||
|
|
|
@ -101,7 +101,7 @@ describe('PageOrder model', () => {
|
|||
expect(pageOrder.data.order).to.be.an('array').that.is.not.empty;
|
||||
if (pageOrder.data.order !== undefined){
|
||||
pageOrder.data.order.forEach((el) => {
|
||||
expect(el).to.be.an('string')
|
||||
expect(el).to.be.an('string');
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
import { expect } from "chai";
|
||||
import fs from "fs";
|
||||
import path from "path";
|
||||
import config from "config";
|
||||
import { expect } from 'chai';
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import config from 'config';
|
||||
import sinon = require('sinon');
|
||||
|
||||
import rcParser from "../src/utils/rcparser";
|
||||
import rcParser from '../src/utils/rcparser';
|
||||
|
||||
const rcPath = path.resolve(process.cwd(), config.get('rcFile'));
|
||||
|
||||
|
@ -28,12 +28,12 @@ describe('RC file parser test', () => {
|
|||
fs.writeFileSync(rcPath, invalidJson, 'utf8');
|
||||
|
||||
const parsedConfig = rcParser.getConfiguration();
|
||||
|
||||
|
||||
expect(spy.calledOnce).to.be.true;
|
||||
expect(spy.calledWith('CodeX Docs rc file should be in JSON format.')).to.be.true;
|
||||
|
||||
expect(parsedConfig).to.be.deep.equal(rcParser.DEFAULTS);
|
||||
spy.restore()
|
||||
spy.restore();
|
||||
});
|
||||
|
||||
it('Normal config', () => {
|
||||
|
@ -95,15 +95,15 @@ describe('RC file parser test', () => {
|
|||
|
||||
fs.writeFileSync(rcPath, JSON.stringify(normalConfig), 'utf8');
|
||||
const spy = sinon.spy(console, 'log');
|
||||
|
||||
|
||||
const parsedConfig = rcParser.getConfiguration();
|
||||
|
||||
|
||||
expect(spy.calledOnce).to.be.true;
|
||||
expect(spy.calledWith('Menu section in the rc file must be an array.')).to.be.true;
|
||||
|
||||
|
||||
expect(parsedConfig.title).to.be.equal(normalConfig.title);
|
||||
expect(parsedConfig.menu).to.be.deep.equal(rcParser.DEFAULTS.menu);
|
||||
spy.restore()
|
||||
spy.restore();
|
||||
});
|
||||
|
||||
it('Menu option is a string', () => {
|
||||
|
@ -155,7 +155,7 @@ describe('RC file parser test', () => {
|
|||
|
||||
expect(parsedConfig.title).to.be.equal(normalConfig.title);
|
||||
expect(parsedConfig.menu).to.be.deep.equal(expectedMenu);
|
||||
spy.restore()
|
||||
spy.restore();
|
||||
});
|
||||
|
||||
it('Menu option title is undefined', () => {
|
||||
|
@ -183,7 +183,7 @@ describe('RC file parser test', () => {
|
|||
|
||||
expect(parsedConfig.title).to.be.equal(normalConfig.title);
|
||||
expect(parsedConfig.menu).to.be.deep.equal(expectedMenu);
|
||||
spy.restore()
|
||||
spy.restore();
|
||||
});
|
||||
|
||||
it('Menu option title is not a string', () => {
|
||||
|
@ -211,7 +211,7 @@ describe('RC file parser test', () => {
|
|||
|
||||
expect(parsedConfig.title).to.be.equal(normalConfig.title);
|
||||
expect(parsedConfig.menu).to.be.deep.equal(expectedMenu);
|
||||
spy.restore()
|
||||
spy.restore();
|
||||
});
|
||||
|
||||
it('Menu option uri is undefined', () => {
|
||||
|
@ -239,7 +239,7 @@ describe('RC file parser test', () => {
|
|||
|
||||
expect(parsedConfig.title).to.be.equal(normalConfig.title);
|
||||
expect(parsedConfig.menu).to.be.deep.equal(expectedMenu);
|
||||
spy.restore()
|
||||
spy.restore();
|
||||
});
|
||||
|
||||
it('Menu option title is not a string', () => {
|
||||
|
@ -267,6 +267,6 @@ describe('RC file parser test', () => {
|
|||
|
||||
expect(parsedConfig.title).to.be.equal(normalConfig.title);
|
||||
expect(parsedConfig.menu).to.be.deep.equal(expectedMenu);
|
||||
spy.restore()
|
||||
spy.restore();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -365,7 +365,7 @@ describe('Pages REST: ', () => {
|
|||
expect(error).to.equal('Page with given id does not exist');
|
||||
});
|
||||
|
||||
async function createPageTree() {
|
||||
async function createPageTree():Promise<string[]> {
|
||||
/**
|
||||
* Creating page tree
|
||||
*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue