Add spec for updating meta document
This commit is contained in:
parent
f48933751d
commit
e663a46242
@ -1,5 +1,5 @@
|
|||||||
const expect = require('chai').expect;
|
const expect = require('chai').expect;
|
||||||
const sinon = require("sinon");
|
const sandbox = require("sinon").createSandbox();
|
||||||
const ChatMessages = require('../dist/build');
|
const ChatMessages = require('../dist/build');
|
||||||
|
|
||||||
const rsClient = {
|
const rsClient = {
|
||||||
@ -64,6 +64,46 @@ describe('ChatMessages', function () {
|
|||||||
expect(archive.next).to.be.an('undefined');
|
expect(archive.next).to.be.an('undefined');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('#_updateArchiveMetaDocument', function () {
|
||||||
|
describe('meta up to date', function () {
|
||||||
|
before(function() {
|
||||||
|
sandbox.stub(archive.client, 'getObject').withArgs(archive.metaPath)
|
||||||
|
.returns({
|
||||||
|
'@id': `chat-messages/irc.libera.chat/channels/kosmos/meta`,
|
||||||
|
'@type': 'ChatChannelMeta',
|
||||||
|
first: '2021/01/01', last: '2022/08/11'
|
||||||
|
})
|
||||||
|
sandbox.stub(archive.client, 'storeObject');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('does not store a new archive', async function () {
|
||||||
|
await archive._updateArchiveMetaDocument();
|
||||||
|
sandbox.assert.notCalled(archive.client.storeObject);
|
||||||
|
});
|
||||||
|
|
||||||
|
after(function() { sandbox.restore() });
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('meta needs updating', function () {
|
||||||
|
before(function() {
|
||||||
|
sandbox.stub(archive.client, 'getObject').withArgs(archive.metaPath)
|
||||||
|
.returns({
|
||||||
|
'@id': `chat-messages/irc.libera.chat/channels/kosmos/meta`,
|
||||||
|
'@type': 'ChatChannelMeta',
|
||||||
|
first: '2021/01/01', last: '2022/08/10'
|
||||||
|
})
|
||||||
|
sandbox.stub(archive.client, 'storeObject');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('stores a new archive', async function () {
|
||||||
|
await archive._updateArchiveMetaDocument();
|
||||||
|
sandbox.assert.calledOnce(archive.client.storeObject);
|
||||||
|
});
|
||||||
|
|
||||||
|
after(function() { sandbox.restore() });
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user