Add failing test for power redistribution via subsequent support
This commit is contained in:
parent
329af5c640
commit
721718ac13
|
@ -12,9 +12,10 @@
|
|||
<li>
|
||||
Forum
|
||||
<ul>
|
||||
<li><a href="./tests/forum1.test.html">1</a></li>
|
||||
<li><a href="./tests/forum2.test.html">2</a></li>
|
||||
<li><a href="./tests/forum3.test.html">3</a></li>
|
||||
<li><a href="./tests/forum1.test.html">Negative citation of a negative citation with max strength</a></li>
|
||||
<li><a href="./tests/forum2.test.html">Negative citation of a weaker negative citation</a></li>
|
||||
<li><a href="./tests/forum3.test.html">Redistribute power</a></li>
|
||||
<li><a href="./tests/forum4.test.html">Redistribute power through subsequent support</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
<!DOCTYPE html>
|
||||
<head>
|
||||
<title>Forum test 4</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>
|
||||
<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/forum4.test.js"></script>
|
||||
<script defer class="mocha-init">
|
||||
mocha.setup({
|
||||
ui: 'bdd',
|
||||
globals: ['scene', 'bench', 'forum', 'experts', 'posts', '__REACT_DEVTOOLS_*'],
|
||||
});
|
||||
mocha.checkLeaks();
|
||||
chai.should();
|
||||
</script>
|
||||
<script defer class="mocha-exec">
|
||||
// TODO: Weird race condition -- resolve this in a better way
|
||||
setTimeout(() => mocha.run(), 1000);
|
||||
</script>
|
|
@ -0,0 +1,53 @@
|
|||
import { ForumTest } from './forum.test-util.js';
|
||||
|
||||
describe('Forum', () => {
|
||||
const forumTest = new ForumTest();
|
||||
|
||||
before(async () => {
|
||||
await forumTest.setup();
|
||||
});
|
||||
|
||||
context('Redistribute power through subsequent support', async () => {
|
||||
it('Post1', async () => {
|
||||
const { forum, experts, posts } = forumTest;
|
||||
await forumTest.addPost(experts[0], 10);
|
||||
forum.getPost(posts[0]).value.should.equal(10);
|
||||
});
|
||||
|
||||
it('Post2', async () => {
|
||||
const { forum, experts, posts } = forumTest;
|
||||
await forumTest.addPost(experts[0], 10);
|
||||
forum.getPost(posts[0]).value.should.equal(10);
|
||||
forum.getPost(posts[1]).value.should.equal(10);
|
||||
});
|
||||
|
||||
it('Post3 cites Post2 and negatively cites Post1', async () => {
|
||||
const { forum, experts, posts } = forumTest;
|
||||
await forumTest.addPost(experts[0], 0, [
|
||||
{ postId: posts[0], weight: -0.5 },
|
||||
{ postId: posts[1], weight: 0.5 },
|
||||
]);
|
||||
forum.getPost(posts[0]).value.should.equal(10);
|
||||
forum.getPost(posts[1]).value.should.equal(10);
|
||||
forum.getPost(posts[2]).value.should.equal(0);
|
||||
});
|
||||
|
||||
it('Post4 cites Post3 to strengthen its effect', async () => {
|
||||
const { forum, experts, posts } = forumTest;
|
||||
await forumTest.addPost(experts[0], 20, [
|
||||
{ postId: posts[2], weight: 1 },
|
||||
]);
|
||||
forum.getPost(posts[0]).value.should.equal(0);
|
||||
forum.getPost(posts[1]).value.should.equal(20);
|
||||
forum.getPost(posts[2]).value.should.equal(20);
|
||||
forum.getPost(posts[3]).value.should.equal(0);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// await addPost(experts[0], 10);
|
||||
// await addPost(experts[0], 10, [{ postId: posts[3], weight: -1 }]);
|
||||
// await addPost(experts[0], 10, [{ postId: posts[4], weight: -1 }]);
|
||||
|
||||
// await addPost(expert3, 'Post 4', 100, [{ postId: postId2, weight: -1 }]);
|
||||
// await addPost(expert1, 'Post 5', 100, [{ postId: postId3, weight: -1 }]);
|
Loading…
Reference in New Issue