Skip to content

Commit

Permalink
feat(edit-content) fix test #28831
Browse files Browse the repository at this point in the history
  • Loading branch information
oidacra committed Jun 26, 2024
1 parent 8a515ea commit ff96063
Showing 1 changed file with 11 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,10 @@ describe('TemplateBuilderBoxComponent', () => {

beforeEach(() => {
spectator = createHost(
`<dotcms-template-builder-box [width]="width" [items]="items" [containerMap]="containerMap"> </dotcms-template-builder-box>`,
`<dotcms-template-builder-box [width]="width" [actions]="actions" [items]="items" [containerMap]="containerMap"> </dotcms-template-builder-box>`,
{
hostProps: {
actions: ['add', 'delete', 'edit'],
width: 10,
items: CONTAINERS_DATA_MOCK,
containerMap: CONTAINER_MAP_MOCK,
Expand All @@ -80,23 +81,23 @@ describe('TemplateBuilderBoxComponent', () => {
});

it('should render with medium variant and update the class', () => {
spectator.setInput('width', 3);
spectator.setHostInput('width', 3);
spectator.detectComponentChanges();
expect(spectator.query(byTestId('template-builder-box')).classList).toContain(
'template-builder-box--medium'
);
});

it('should render with small variant and update the class', () => {
spectator.setInput('width', 1);
spectator.setHostInput('width', 1);
spectator.detectComponentChanges();
expect(spectator.query(byTestId('template-builder-box-small')).classList).toContain(
'template-builder-box--small'
);
});

it('should render the first ng-template for large and medium variants', () => {
spectator.setInput('width', 10);
spectator.setHostInput('width', 10);
spectator.detectComponentChanges();
const firstTemplate = spectator.query(byTestId('template-builder-box'));
const secondTemplate = spectator.query(byTestId('template-builder-box-small'));
Expand All @@ -105,16 +106,16 @@ describe('TemplateBuilderBoxComponent', () => {
});

it('should only show the specified actions on actions input', () => {
spectator.setInput('actions', ['add', 'delete']); // Here we hide the edit button
spectator.detectComponentChanges();
spectator.setHostInput('actions', ['add', 'delete']); // Here we hide the edit button
spectator.detectChanges();

const paletteButton = spectator.query(byTestId('box-style-class-button'));

expect(paletteButton).toBeFalsy();
});

it('should show all buttons for small variant', () => {
spectator.setInput('width', 1);
spectator.setHostInput('width', 1);
spectator.detectComponentChanges();

const addButton = spectator.query(byTestId('btn-plus-small'));
Expand Down Expand Up @@ -249,7 +250,7 @@ describe('TemplateBuilderBoxComponent', () => {

describe('Dialog', () => {
it('should open dialog when click on edit button', () => {
spectator.setInput('width', 1);
spectator.setHostInput('width', 1);
spectator.detectComponentChanges();

const templateBuilderSmallBox = spectator.query(byTestId('template-builder-box-small'));
Expand All @@ -276,7 +277,8 @@ describe('TemplateBuilderBoxComponent', () => {

it('should not open dialog when the size is large', () => {
// Make sure the current tampalte-builder-box component is the small one
spectator.setInput('width', 5);
spectator.setHostInput('width', 5);

spectator.detectComponentChanges();

const plusButton = spectator.query(byTestId('btn-plus'));
Expand Down

0 comments on commit ff96063

Please sign in to comment.