Add example: posts with overlapping authors
This commit is contained in:
parent
5b0b87d2d3
commit
e6969fde81
|
@ -25,6 +25,7 @@
|
||||||
<li><a href="./tests/forum8.test.html">Incinerate reputation</a></li>
|
<li><a href="./tests/forum8.test.html">Incinerate reputation</a></li>
|
||||||
<li><a href="./tests/forum9.test.html">Use incineration to achieve more balanced reweighting</a></li>
|
<li><a href="./tests/forum9.test.html">Use incineration to achieve more balanced reweighting</a></li>
|
||||||
<li><a href="./tests/forum10.test.html">Post with multiple authors</a></li>
|
<li><a href="./tests/forum10.test.html">Post with multiple authors</a></li>
|
||||||
|
<li><a href="./tests/forum11.test.html">Multiple posts with overlapping authors</a></li>
|
||||||
</ol>
|
</ol>
|
||||||
</ul>
|
</ul>
|
||||||
<ul>
|
<ul>
|
||||||
|
|
|
@ -37,6 +37,7 @@
|
||||||
<script type="module" src="./scripts/forum/forum8.test.js"></script>
|
<script type="module" src="./scripts/forum/forum8.test.js"></script>
|
||||||
<script type="module" src="./scripts/forum/forum9.test.js"></script>
|
<script type="module" src="./scripts/forum/forum9.test.js"></script>
|
||||||
<script type="module" src="./scripts/forum/forum10.test.js"></script>
|
<script type="module" src="./scripts/forum/forum10.test.js"></script>
|
||||||
|
<script type="module" src="./scripts/forum/forum11.test.js"></script>
|
||||||
<script defer class="mocha-init">
|
<script defer class="mocha-init">
|
||||||
mocha.setup({
|
mocha.setup({
|
||||||
ui: 'bdd',
|
ui: 'bdd',
|
||||||
|
|
|
@ -0,0 +1,26 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<title>Forum test 11</title>
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
|
<link rel="stylesheet" href="https://unpkg.com/mocha/mocha.css" />
|
||||||
|
<link type="text/css" rel="stylesheet" href="../index.css" />
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<h2><a href="../">DGF Tests</a></h2>
|
||||||
|
<div id="mocha"></div>
|
||||||
|
<div id="scene"></div>
|
||||||
|
</body>
|
||||||
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/radash/10.7.0/radash.js"
|
||||||
|
integrity="sha512-S207zKWG3iqXqe6msO7/Mr8X3DzzF4u8meFlokHjGtBPTGUhgzVo0lpcqEy0GoiMUdcoct+H+SqzoLsxXbynzg=="
|
||||||
|
crossorigin="anonymous" referrerpolicy="no-referrer"></script>
|
||||||
|
<script src="https://unpkg.com/mocha/mocha.js"></script>
|
||||||
|
<script src="https://unpkg.com/chai/chai.js"></script>
|
||||||
|
<script type="module" src="./scripts/forum/forum11.test.js"></script>
|
||||||
|
<script defer class="mocha-init">
|
||||||
|
mocha.setup({
|
||||||
|
ui: 'bdd',
|
||||||
|
});
|
||||||
|
chai.should();
|
||||||
|
</script>
|
|
@ -0,0 +1,47 @@
|
||||||
|
import { mochaRun } from '../../../util.js';
|
||||||
|
import { ForumTest } from './forum.test-util.js';
|
||||||
|
|
||||||
|
describe('Forum', function tests() {
|
||||||
|
this.timeout(0);
|
||||||
|
|
||||||
|
const forumTest = new ForumTest();
|
||||||
|
|
||||||
|
before(async () => {
|
||||||
|
await forumTest.setup();
|
||||||
|
});
|
||||||
|
|
||||||
|
context('Multiple posts with overlapping authors', async () => {
|
||||||
|
let forum;
|
||||||
|
let experts;
|
||||||
|
let posts;
|
||||||
|
|
||||||
|
before(async () => {
|
||||||
|
forum = forumTest.forum;
|
||||||
|
experts = forumTest.experts;
|
||||||
|
posts = forumTest.posts;
|
||||||
|
|
||||||
|
await forumTest.newExpert({ announce: true });
|
||||||
|
await forumTest.newExpert({ announce: true });
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Post1 with two authors', async () => {
|
||||||
|
const authors = [
|
||||||
|
{ author: experts[0], weight: 0.5 },
|
||||||
|
{ author: experts[1], weight: 0.5 },
|
||||||
|
];
|
||||||
|
await forumTest.addPost(authors, 10);
|
||||||
|
forum.getPost(posts[0]).value.should.equal(10);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Post2 with two authors, one shared with Post1', async () => {
|
||||||
|
const authors = [
|
||||||
|
{ author: experts[1], weight: 0.5 },
|
||||||
|
{ author: experts[2], weight: 0.5 },
|
||||||
|
];
|
||||||
|
await forumTest.addPost(authors, 10);
|
||||||
|
forum.getPost(posts[0]).value.should.equal(10);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
mochaRun();
|
Loading…
Reference in New Issue