CSR-735 | Unit test for text-block-widget
This commit is contained in:
parent
9e58652694
commit
27e06a4add
1 changed files with 60 additions and 1 deletions
|
|
@ -1 +1,60 @@
|
|||
test.todo("some test to be written in the future");
|
||||
import { shallowMount } from "@vue/test-utils";
|
||||
import TextBlock from "./text-block";
|
||||
|
||||
|
||||
describe("modal.vue", () => {
|
||||
it("Should display 'Text' when 'Text' is defined in the CMS", async () => {
|
||||
// Act
|
||||
const wrapper = shallowMount(TextBlock, {
|
||||
mixins: [mockMixin]
|
||||
});
|
||||
expect(wrapper.html()).toEqual(expect.stringContaining(mockCmsContent['Text']));
|
||||
});
|
||||
|
||||
it("Should contain the typeStyle class as defined by the prop", async () => {
|
||||
// Act
|
||||
const wrapper = shallowMount(TextBlock, {
|
||||
mixins: [mockMixin],
|
||||
propsData: mockProps,
|
||||
});
|
||||
expect(wrapper.html()).toEqual(expect.stringContaining(mockProps['typeStyle']));
|
||||
});
|
||||
it("Should contain the justifyText class as defined by the prop", async () => {
|
||||
// Act
|
||||
const wrapper = shallowMount(TextBlock, {
|
||||
mixins: [mockMixin],
|
||||
propsData: mockProps,
|
||||
});
|
||||
expect(wrapper.html()).toEqual(expect.stringContaining(mockProps['justifyText']));
|
||||
});
|
||||
it("Should contain the fontWeight class as defined by the prop", async () => {
|
||||
// Act
|
||||
const wrapper = shallowMount(TextBlock, {
|
||||
mixins: [mockMixin],
|
||||
propsData: mockProps,
|
||||
});
|
||||
expect(wrapper.html()).toEqual(expect.stringContaining(mockProps['fontWeight']));
|
||||
});
|
||||
});
|
||||
|
||||
///////////////
|
||||
// Constants //
|
||||
///////////////
|
||||
|
||||
const mockMixin = {
|
||||
methods: {
|
||||
getCmsContent: jest.fn((widgetName, cmsFieldName) => {
|
||||
return mockCmsContent[cmsFieldName];
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
const mockProps = {
|
||||
fontWeight: 'mockFontWeight',
|
||||
typeStyle: 'mockTypeStyle',
|
||||
justifyText: 'mockJustifyText'
|
||||
}
|
||||
|
||||
const mockCmsContent = {
|
||||
'Text': "Sample text here.",
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue