Browse Source

test: use correct jest spy

pull/6059/head
danstarns 1 year ago
parent
commit
68fb248b7d
  1. 8
      test/specs/dom_components/model/ComponentImage.ts
  2. 4
      test/specs/dom_components/view/ComponentTextView.ts

8
test/specs/dom_components/model/ComponentImage.ts

@ -42,12 +42,12 @@ describe('ComponentImage', () => {
});
describe('.getAttrToHTML', () => {
let getSrcResultSpy: ReturnType<typeof spyOn>;
let getSrcResultSpy: ReturnType<typeof jest.spyOn>;
const fakeAttributes = {};
beforeEach(() => {
spyOn(Component.prototype, 'getAttrToHTML').and.returnValue(fakeAttributes);
getSrcResultSpy = spyOn(componentImage, 'getSrcResult');
jest.spyOn(Component.prototype, 'getAttrToHTML').mockReturnValue(fakeAttributes);
getSrcResultSpy = jest.spyOn(componentImage, 'getSrcResult');
});
test('it should fill the `src` property with the result of `getSrcResult` if defined', () => {
@ -56,7 +56,7 @@ describe('ComponentImage', () => {
expect(attributes).toEqual(fakeAttributes);
let fakeSrcResult = 'fakeSrcResult';
getSrcResultSpy.and.returnValue(fakeSrcResult);
getSrcResultSpy.mockReturnValue(fakeSrcResult);
attributes = componentImage.getAttrToHTML();
expect(getSrcResultSpy).toHaveBeenCalledTimes(2);
expect(attributes).toEqual({ src: fakeSrcResult });

4
test/specs/dom_components/view/ComponentTextView.ts

@ -60,7 +60,7 @@ describe('ComponentTextView', () => {
describe('.getContent', () => {
let fakeRte: CustomRTE<any>;
let fakeRteContent = '';
let fakeChildContainer: InnerHTML;
let fakeChildContainer: any;
beforeEach(() => {
fakeRteContent = 'fakeRteContent';
@ -75,7 +75,7 @@ describe('ComponentTextView', () => {
innerHTML: 'fakeChildInnerHTML',
};
spyOn(view, 'getChildrenContainer').and.returnValue(fakeChildContainer);
jest.spyOn(view, 'getChildrenContainer').mockReturnValue(fakeChildContainer);
em.RichTextEditor.customRte = fakeRte;
});

Loading…
Cancel
Save