Simplify stubs in Quill tests

This commit is contained in:
Evan Hahn 2021-01-04 12:28:32 -06:00 committed by Scott Nonnenberg
parent 55a89699ab
commit 1b5e229f95
2 changed files with 3 additions and 15 deletions

View file

@ -9,8 +9,6 @@ import { EmojiData } from '../../../components/emoji/lib';
describe('emojiCompletion', () => { describe('emojiCompletion', () => {
let emojiCompletion: EmojiCompletion; let emojiCompletion: EmojiCompletion;
const mockOnPickEmoji = sinon.spy();
const mockSetEmojiPickerElement = sinon.spy();
// eslint-disable-next-line @typescript-eslint/no-explicit-any // eslint-disable-next-line @typescript-eslint/no-explicit-any
let mockQuill: any; let mockQuill: any;
@ -26,10 +24,8 @@ describe('emojiCompletion', () => {
updateContents: sinon.stub(), updateContents: sinon.stub(),
}; };
const options = { const options = {
// eslint-disable-next-line @typescript-eslint/no-explicit-any onPickEmoji: sinon.stub(),
onPickEmoji: mockOnPickEmoji as any, setEmojiPickerElement: sinon.stub(),
// eslint-disable-next-line @typescript-eslint/no-explicit-any
setEmojiPickerElement: mockSetEmojiPickerElement as any,
skinTone: 0, skinTone: 0,
}; };
@ -40,12 +36,6 @@ describe('emojiCompletion', () => {
emojiCompletion.render = sinon.stub(); emojiCompletion.render = sinon.stub();
}); });
afterEach(function afterEach() {
mockOnPickEmoji.resetHistory();
mockSetEmojiPickerElement.resetHistory();
(emojiCompletion.render as sinon.SinonStub).resetHistory();
});
describe('getCurrentLeafTextPartitions', () => { describe('getCurrentLeafTextPartitions', () => {
it('returns left and right text', () => { it('returns left and right text', () => {
mockQuill.getSelection.returns({ index: 0, length: 0 }); mockQuill.getSelection.returns({ index: 0, length: 0 });

View file

@ -53,8 +53,6 @@ const members: Array<ConversationType> = [
]; ];
describe('MentionCompletion', () => { describe('MentionCompletion', () => {
const mockSetMentionPickerElement = sinon.spy();
let mockQuill: Omit< let mockQuill: Omit<
Partial<{ [K in keyof Quill]: SinonStub }>, Partial<{ [K in keyof Quill]: SinonStub }>,
'keyboard' 'keyboard'
@ -72,7 +70,7 @@ describe('MentionCompletion', () => {
i18n: sinon.stub(), i18n: sinon.stub(),
me, me,
memberRepositoryRef, memberRepositoryRef,
setMentionPickerElement: mockSetMentionPickerElement, setMentionPickerElement: sinon.stub(),
}; };
mockQuill = { mockQuill = {