Browse Source

test: use correct jest spy

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

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

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

Loading…
Cancel
Save