|
|
|
@ -39,4 +39,38 @@ describe('ComponentTextView', () => { |
|
|
|
fixtures.appendChild(view.render().el); |
|
|
|
expect(view.el.innerHTML).toEqual('test'); |
|
|
|
}); |
|
|
|
|
|
|
|
describe('.getContent', () => { |
|
|
|
let fakeRte, fakeRteContent, fakeChildContainer; |
|
|
|
|
|
|
|
beforeEach(() => { |
|
|
|
fakeRteContent = 'fakeRteContent'; |
|
|
|
|
|
|
|
fakeRte = { |
|
|
|
getContent: jest.fn(() => fakeRteContent) |
|
|
|
}; |
|
|
|
|
|
|
|
fakeChildContainer = { |
|
|
|
innerHTML: 'fakeChildInnerHTML' |
|
|
|
}; |
|
|
|
|
|
|
|
spyOn(view, 'getChildrenContainer').and.returnValue(fakeChildContainer); |
|
|
|
}); |
|
|
|
|
|
|
|
it('should get content from active RTE if available', () => { |
|
|
|
view.activeRte = fakeRte; |
|
|
|
expect(view.getContent()).toEqual(fakeRteContent); |
|
|
|
expect(fakeRte.getContent).toHaveBeenCalled(); |
|
|
|
}); |
|
|
|
|
|
|
|
it("should get child container's `innerHTML` if active RTE is not available or if it has no `getContent` function", () => { |
|
|
|
expect(view.getContent()).toEqual(fakeChildContainer.innerHTML); |
|
|
|
|
|
|
|
fakeRte.getContent = null; |
|
|
|
view.activeRte = fakeRte; |
|
|
|
expect(view.getContent()).toEqual(fakeChildContainer.innerHTML); |
|
|
|
|
|
|
|
expect(view.getChildrenContainer).toHaveBeenCalledTimes(2); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|