Check leaks in Mocha

This commit is contained in:
Evan Hahn 2021-01-11 14:17:09 -06:00 committed by GitHub
parent 7543d8b60d
commit dc918aea1d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 3 additions and 38 deletions

3
.mocharc.json Normal file
View File

@ -0,0 +1,3 @@
{
"checkLeaks": true
}

View File

@ -7,9 +7,6 @@ import sinon from 'sinon';
import { EmojiCompletion } from '../../../quill/emoji/completion';
import { EmojiData } from '../../../components/emoji/lib';
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const globalAsAny = global as any;
describe('emojiCompletion', () => {
let emojiCompletion: EmojiCompletion;
const mockOnPickEmoji = sinon.spy();
@ -18,14 +15,6 @@ describe('emojiCompletion', () => {
let mockQuill: any;
beforeEach(function beforeEach() {
this.oldDocument = globalAsAny.document;
globalAsAny.document = {
body: {
appendChild: () => null,
},
createElement: () => null,
};
mockQuill = {
getLeaf: sinon.stub(),
getSelection: sinon.stub(),
@ -55,12 +44,6 @@ describe('emojiCompletion', () => {
mockOnPickEmoji.resetHistory();
mockSetEmojiPickerElement.resetHistory();
(emojiCompletion.render as sinon.SinonStub).resetHistory();
if (this.oldDocument === undefined) {
delete globalAsAny.document;
} else {
globalAsAny.document = this.oldDocument;
}
});
describe('getCurrentLeafTextPartitions', () => {

View File

@ -52,20 +52,6 @@ const members: Array<ConversationType> = [
me,
];
declare global {
// eslint-disable-next-line @typescript-eslint/no-namespace
namespace NodeJS {
interface Global {
document: {
body: {
appendChild: unknown;
};
createElement: unknown;
};
}
}
}
describe('MentionCompletion', () => {
const mockSetMentionPickerElement = sinon.spy();
@ -78,13 +64,6 @@ describe('MentionCompletion', () => {
let mentionCompletion: MentionCompletion;
beforeEach(function beforeEach() {
global.document = {
body: {
appendChild: sinon.spy(),
},
createElement: sinon.spy(),
};
const memberRepositoryRef: MutableRefObject<MemberRepository> = {
current: new MemberRepository(members),
};