1
0
Fork 0
mirror of https://github.com/codex-team/codex.docs.git synced 2025-07-18 20:59:42 +02:00
codex.docs/src/test/rest/aliases.ts
Nikita Melnikov 34514761f5
Typescript rewrite (#147)
* Updated highlight.js

* Update .codexdocsrc.sample

remove undefined page for a fresh new install

* backend rewritten in TS

* test -> TS, .added dockerignore, bug fixed

* Removed compiled js files, eslint codex/ts added

* fixed jsdocs warning, leaving editor confirmation

* use path.resolve for DB paths

* db drives updated + fixed User model

* redundant cleared + style fixed

* explicit type fixing

* fixing testing code

* added body block type

* compiled JS files -> dist, fixed compiling errors

* fixed compiling error, re-organized ts source code

* updated Dockerfile

* fixed link to parent page

* up nodejs version

* fix package name

* fix deps

Co-authored-by: nvc8996 <nvc.8996@gmail.com>
Co-authored-by: Taly <vitalik7tv@yandex.ru>
2022-03-05 22:57:23 +04:00

60 lines
1.2 KiB
TypeScript

import fs from 'fs';
import path from 'path';
import config from 'config';
import chai from 'chai';
import chaiHTTP from 'chai-http';
import server from '../../bin/server';
const {expect} = chai;
const app = server.app;
chai.use(chaiHTTP);
describe('Aliases REST: ', () => {
let agent: ChaiHttp.Agent;
before(async () => {
agent = chai.request.agent(app);
});
after(async () => {
const pathToDB = path.resolve(__dirname, '../../', config.get('database'), './pages.db');
if (fs.existsSync(pathToDB)) {
fs.unlinkSync(pathToDB);
}
const pathToAliasDB = path.resolve(__dirname, '../../', config.get('database'), './aliases.db');
if (fs.existsSync(pathToAliasDB)) {
fs.unlinkSync(pathToAliasDB);
}
});
it('Finding page with alias', async () => {
const body = {
time: 1548375408533,
blocks: [
{
type: 'header',
data: {
text: 'Test header'
}
}
]
};
const put = await agent
.put('/api/page')
.send({body});
expect(put).to.have.status(200);
expect(put).to.be.json;
const {result: {uri}} = put.body;
const get = await agent.get('/' + uri);
expect(get).to.have.status(200);
});
});