70 lines
2.2 KiB
JavaScript
70 lines
2.2 KiB
JavaScript
const expect = require('chai').expect;
|
|
const sinon = require("sinon");
|
|
const ChatMessages = require('../dist/build');
|
|
|
|
const rsClient = {
|
|
declareType: function() {},
|
|
getObject: function() {},
|
|
getListing: function() {},
|
|
storeObject: function() {},
|
|
remove: function() {}
|
|
}
|
|
|
|
|
|
describe('ChatMessages', function () {
|
|
|
|
describe('constructor', function () {
|
|
let chatMessages;
|
|
|
|
before(function() {
|
|
chatMessages = new ChatMessages.builder(rsClient, rsClient);
|
|
});
|
|
|
|
it('behaves like a remoteStorage module', function () {
|
|
expect(chatMessages).to.be.an('object');
|
|
expect(chatMessages.exports).to.be.an('object');
|
|
});
|
|
|
|
it('exports the desired functionality', function () {
|
|
expect(chatMessages.exports.DailyArchive).to.be.a('function');
|
|
});
|
|
});
|
|
|
|
describe('DailyArchive', function () {
|
|
let archive;
|
|
|
|
before(function() {
|
|
chatMessages = (new ChatMessages.builder(rsClient, rsClient)).exports;
|
|
|
|
archive = new chatMessages.DailyArchive({
|
|
service: { protocol: 'IRC', domain: 'irc.libera.chat' },
|
|
channelName: '#kosmos',
|
|
date: new Date('2022-08-11')
|
|
});
|
|
});
|
|
|
|
describe('constructor', function () {
|
|
it('creates an archive instance with the desired properties', function () {
|
|
expect(archive).to.be.an('object');
|
|
expect(archive.service.protocol).to.eq('IRC');
|
|
expect(archive.service.domain).to.eq('irc.libera.chat');
|
|
expect(archive.channelName).to.eq('#kosmos');
|
|
expect(archive.channelType).to.eq('room');
|
|
expect(archive.date).to.be.a('date');
|
|
expect(archive.parsedDate.year).to.eq(2022);
|
|
expect(archive.parsedDate.month).to.eq('08');
|
|
expect(archive.parsedDate.day).to.eq('11');
|
|
expect(archive.dateId).to.eq('2022/08/11');
|
|
expect(archive.isPublic).to.eq(false);
|
|
expect(archive.channelPath).to.eq('irc.libera.chat/channels/kosmos');
|
|
expect(archive.path).to.eq('irc.libera.chat/channels/kosmos/2022/08/11');
|
|
expect(archive.metaPath).to.eq('irc.libera.chat/channels/kosmos/meta');
|
|
expect(archive.client).to.eq(rsClient);
|
|
expect(archive.previous).to.be.an('undefined');
|
|
expect(archive.next).to.be.an('undefined');
|
|
});
|
|
});
|
|
});
|
|
|
|
});
|