Chart resyncing (#5372)

* wip

* Add test

* Fix test

* Insert moderation log

* Add todo
This commit is contained in:
syuilo 2019-09-02 04:41:26 +09:00 committed by GitHub
parent 84730a071a
commit 96b2267cb8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 97 additions and 2 deletions

View file

@ -320,4 +320,60 @@ describe('Chart', () => {
});
}));
});
describe('Resync', () => {
it('Can resync', async(async () => {
testChart.total = 1;
await testChart.resync();
const chartHours = await testChart.getChart('hour', 3);
const chartDays = await testChart.getChart('day', 3);
assert.deepStrictEqual(chartHours, {
foo: {
dec: [0, 0, 0],
inc: [0, 0, 0],
total: [1, 0, 0]
},
});
assert.deepStrictEqual(chartDays, {
foo: {
dec: [0, 0, 0],
inc: [0, 0, 0],
total: [1, 0, 0]
},
});
}));
it('Can resync (2)', async(async () => {
await testChart.increment();
clock.tick('01:00:00');
testChart.total = 100;
await testChart.resync();
const chartHours = await testChart.getChart('hour', 3);
const chartDays = await testChart.getChart('day', 3);
assert.deepStrictEqual(chartHours, {
foo: {
dec: [0, 0, 0],
inc: [0, 1, 0],
total: [100, 1, 0]
},
});
assert.deepStrictEqual(chartDays, {
foo: {
dec: [0, 0, 0],
inc: [1, 0, 0],
total: [100, 0, 0]
},
});
}));
});
});