mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
core: add unit test for model.user
This commit is contained in:
1 parent
b9fdf3bca9
commit
92229c1ee0
6 files changed
+81
-10
No files matched your search
@@ -4,6 +4,7 @@ import { connect, dispose } from './db';
|
||||
const DOMAIN_ID = 'system';
|
||||
const TITLE = 'dummy_title';
|
||||
const CONTENT = 'dummy_content';
|
||||
const CONTENT_1 = 'another_dummy_content';
|
||||
const UID = 22;
|
||||
const PNAME = 'aaa';
|
||||
|
||||
@@ -18,7 +19,7 @@ describe('Model.Problem', () => {
|
||||
test('add_get', async () => {
|
||||
const pid = await problem.add(DOMAIN_ID, PNAME, TITLE, CONTENT, UID);
|
||||
expect(pid).toBeTruthy();
|
||||
let pdoc = await problem.get(DOMAIN_ID, PNAME);
|
||||
const pdoc = await problem.get(DOMAIN_ID, PNAME);
|
||||
expect(pdoc.domainId).toStrictEqual(DOMAIN_ID);
|
||||
expect(pdoc.title).toStrictEqual(TITLE);
|
||||
expect(pdoc.content).toStrictEqual(CONTENT);
|
||||
@@ -33,5 +34,22 @@ describe('Model.Problem', () => {
|
||||
expect(pdocs[0].title).toStrictEqual(TITLE);
|
||||
});
|
||||
|
||||
test('edit', async () => {
|
||||
const pid = await problem.add(DOMAIN_ID, PNAME, TITLE, CONTENT, UID);
|
||||
const pdoc = await problem.edit(DOMAIN_ID, pid, { content: CONTENT_1 });
|
||||
expect(pdoc.content).toStrictEqual(CONTENT_1);
|
||||
});
|
||||
|
||||
/* FIXME doesn't work as storage isn't mocked yet
|
||||
test('del', async () => {
|
||||
const pid = await problem.add(DOMAIN_ID, PNAME, TITLE, CONTENT, UID);
|
||||
let pdocs = await problem.getMulti(DOMAIN_ID, {}).toArray();
|
||||
let count = pdocs.length;
|
||||
await problem.del(DOMAIN_ID, pid);
|
||||
pdocs = await problem.getMulti(DOMAIN_ID, {}).toArray();
|
||||
expect(pdocs.length).toStrictEqual(count - 1);
|
||||
})
|
||||
*/
|
||||
|
||||
afterAll(dispose);
|
||||
})
|
||||
});
|
||||
Reference in new issue
Block a user