Skip to content

Commit

Permalink
feat(edit-content) remove comments and add more test
Browse files Browse the repository at this point in the history
  • Loading branch information
oidacra committed Oct 17, 2024
1 parent 6825f46 commit 81969ab
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ import {
Spectator,
SpyObject
} from '@ngneat/spectator/jest';
import { of } from 'rxjs';

import { Validators } from '@angular/forms';
import { ActivatedRoute, Router } from '@angular/router';

import { TabPanel, TabView } from 'primeng/tabview';

import {
DotContentTypeService,
Expand All @@ -14,15 +20,11 @@ import {
DotWorkflowActionsFireService,
DotWorkflowsActionsService
} from '@dotcms/data-access';
import { DotWorkflowActionsComponent } from '@dotcms/ui';
import { DotFormatDateServiceMock } from '@dotcms/utils-testing';

import { DotEditContentFormComponent } from './dot-edit-content-form.component';

import { Validators } from '@angular/forms';
import { ActivatedRoute, Router } from '@angular/router';
import { DotWorkflowActionsComponent } from '@dotcms/ui';
import { TabPanel, TabView } from 'primeng/tabview';
import { of } from 'rxjs';
import { DotEditContentStore } from '../../feature/edit-content/store/edit-content.store';
import { CONTENT_SEARCH_ROUTE } from '../../models/dot-edit-content-field.constant';
import { DotEditContentService } from '../../services/dot-edit-content.service';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ export class DotEditContentFormComponent implements OnInit {
if (!contentType || !contentType.fields) {
return [];
}

return contentType.fields.filter((field) => isFilteredType(field));
});

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import { byTestId, createComponentFactory, Spectator } from '@ngneat/spectator/jest';

import { Component } from '@angular/core';
import { fakeAsync, tick } from '@angular/core/testing';
import { byTestId, createComponentFactory, Spectator } from '@ngneat/spectator/jest';

import { TabViewModule } from 'primeng/tabview';
import { MockResizeObserver } from '../../utils/mocks';

import { TabViewInsertDirective } from './tab-view-insert.directive';

import { MockResizeObserver } from '../../utils/mocks';

// Mock component
@Component({
template: `
Expand Down Expand Up @@ -39,9 +43,8 @@ describe('TabViewInsertDirective', () => {
window.ResizeObserver = MockResizeObserver;
spectator = createComponent();
});

afterEach(() => {
delete (window as any).ResizeObserver;
delete window.ResizeObserver;
});

it('should prepend content', fakeAsync(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import { CONTENT_TYPE_MOCK } from '../../utils/mocks';

describe('EditContentLayoutComponent', () => {
let spectator: Spectator<EditContentLayoutComponent>;
let component: EditContentLayoutComponent;

let store: SpyObject<InstanceType<typeof DotEditContentStore>>;
let dotContentTypeService: SpyObject<DotContentTypeService>;
let workflowActionsService: SpyObject<DotWorkflowsActionsService>;
Expand Down Expand Up @@ -87,7 +87,6 @@ describe('EditContentLayoutComponent', () => {
detectChanges: false
});

component = spectator.component;
spectator.detectChanges();

store = spectator.inject(DotEditContentStore, true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -645,7 +645,6 @@ describe('Utils Functions', () => {
describe('isFilteredType', () => {
it('should correctly identify filtered and non-filtered field types', () => {
const allFields = MOCK_CONTENTTYPE_2_TABS.fields;
const formControlFieldTypes = MOCK_FORM_CONTROL_FIELDS.map((field) => field.fieldType);
const nonFormControlFieldTypes = Object.values(NON_FORM_CONTROL_FIELD_TYPES);

// Verify that none of the form control fields are filtered types
Expand Down
13 changes: 10 additions & 3 deletions core-web/libs/edit-content/src/lib/utils/mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1095,6 +1095,7 @@ export const CONTENT_FORM_DATA_MOCK: DotFormData = {
},
tabs: []
};

export const TABS_MOCK = [
{
title: 'Content',
Expand Down Expand Up @@ -1276,9 +1277,15 @@ export const CONTENT_TYPE_MOCK: DotCMSContentType = {
* Mock for ResizeObserver
*/
export class MockResizeObserver {
observe() {}
unobserve() {}
disconnect() {}
observe() {
//
}
unobserve() {
//
}
disconnect() {
//
}
}

export const TREE_SELECT_SITES_MOCK: TreeNodeItem[] = [
Expand Down

0 comments on commit 81969ab

Please sign in to comment.