Skip to content

Commit

Permalink
feat(editor-content): apply format #29871
Browse files Browse the repository at this point in the history
  • Loading branch information
nicobytes committed Sep 18, 2024
1 parent 7ac1bad commit 1fd3ddb
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,17 @@ import { provideHttpClient } from '@angular/common/http';
import { ControlContainer } from '@angular/forms';

import { DotMessageService } from '@dotcms/data-access';
import {
DotDropZoneComponent,
} from '@dotcms/ui';
import { DotDropZoneComponent } from '@dotcms/ui';

import { DotEditContentFileFieldComponent } from './dot-edit-content-file-field.component';
import { FileFieldStore } from './store/file-field.store';

import { BINARY_FIELD_MOCK, createFormGroupDirectiveMock, FILE_FIELD_MOCK, IMAGE_FIELD_MOCK } from '../../utils/mocks';

import {
BINARY_FIELD_MOCK,
createFormGroupDirectiveMock,
FILE_FIELD_MOCK,
IMAGE_FIELD_MOCK
} from '../../utils/mocks';

describe('DotEditContentFileFieldComponent', () => {
let spectator: Spectator<DotEditContentFileFieldComponent>;
Expand All @@ -23,15 +25,18 @@ describe('DotEditContentFileFieldComponent', () => {
providers: [provideHttpClient(), mockProvider(DotMessageService)],
componentViewProviders: [
{ provide: ControlContainer, useValue: createFormGroupDirectiveMock() }
],
]
});

describe('FileField', () => {
beforeEach(() => (spectator = createComponent({
props: {
field: FILE_FIELD_MOCK
} as unknown
})));
beforeEach(
() =>
(spectator = createComponent({
props: {
field: FILE_FIELD_MOCK
} as unknown
}))
);

it('should be created', () => {
expect(spectator.component).toBeTruthy();
Expand All @@ -54,11 +59,14 @@ describe('DotEditContentFileFieldComponent', () => {
});

describe('ImageField', () => {
beforeEach(() => (spectator = createComponent({
props: {
field: IMAGE_FIELD_MOCK
} as unknown
})));
beforeEach(
() =>
(spectator = createComponent({
props: {
field: IMAGE_FIELD_MOCK
} as unknown
}))
);

it('should be created', () => {
expect(spectator.component).toBeTruthy();
Expand All @@ -81,11 +89,14 @@ describe('DotEditContentFileFieldComponent', () => {
});

describe('BinaryField', () => {
beforeEach(() => (spectator = createComponent({
props: {
field: BINARY_FIELD_MOCK
} as unknown
})));
beforeEach(
() =>
(spectator = createComponent({
props: {
field: BINARY_FIELD_MOCK
} as unknown
}))
);

it('should be created', () => {
expect(spectator.component).toBeTruthy();
Expand All @@ -106,6 +117,4 @@ describe('DotEditContentFileFieldComponent', () => {
expect(spectator.query(byTestId('action-generate-with-ai'))).toBeTruthy();
});
});


});
Original file line number Diff line number Diff line change
@@ -1,25 +1,28 @@
import { moduleMetadata, StoryObj, Meta, applicationConfig, argsToTemplate } from '@storybook/angular';
import {
moduleMetadata,
StoryObj,
Meta,
applicationConfig,
argsToTemplate
} from '@storybook/angular';

import { provideHttpClient } from '@angular/common/http';
import { FormsModule } from '@angular/forms';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';


import { DotMessageService } from '@dotcms/data-access';
import { DotCMSContentTypeField } from '@dotcms/dotcms-models';

import { DotEditContentFileFieldComponent } from './dot-edit-content-file-field.component';
import { FileFieldStore } from './store/file-field.store';
import { MessageServiceMock } from './utils/mocks';

import {
FILE_FIELD_MOCK, IMAGE_FIELD_MOCK, BINARY_FIELD_MOCK
} from '../../utils/mocks';
import { FILE_FIELD_MOCK, IMAGE_FIELD_MOCK, BINARY_FIELD_MOCK } from '../../utils/mocks';

type Args = DotEditContentFileFieldComponent & {
field: DotCMSContentTypeField;
value: string;
}
};

const meta: Meta<Args> = {
title: 'Library / Edit Content / File Field',
Expand All @@ -30,18 +33,13 @@ const meta: Meta<Args> = {
provideHttpClient(),
{
provide: DotMessageService,
useValue : MessageServiceMock
useValue: MessageServiceMock
}
]
}),
moduleMetadata({
imports: [
BrowserAnimationsModule,
FormsModule,
],
providers: [
FileFieldStore
]
imports: [BrowserAnimationsModule, FormsModule],
providers: [FileFieldStore]
})
],
render: (args) => ({
Expand All @@ -59,20 +57,20 @@ type Story = StoryObj<Args>;
export const FileField: Story = {
args: {
value: '',
field: {...FILE_FIELD_MOCK}
field: { ...FILE_FIELD_MOCK }
}
};

export const ImageField: Story = {
args: {
value: '',
field: {...IMAGE_FIELD_MOCK}
field: { ...IMAGE_FIELD_MOCK }
}
};

export const BinaryField: Story = {
args: {
value: '',
field: {...BINARY_FIELD_MOCK}
field: { ...BINARY_FIELD_MOCK }
}
};
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { MockDotMessageService } from "@dotcms/utils-testing";
import { MockDotMessageService } from '@dotcms/utils-testing';

const MESSAGES_MOCK = {
'dot.file.field.action.choose.file': 'Choose File',
Expand Down Expand Up @@ -36,7 +36,7 @@ const MESSAGES_MOCK = {
'dot.common.import': 'Import',
'dot.common.remove': 'Remove',
'dot.common.save': 'Save',
'error.form.validator.required': 'This field is required',
'error.form.validator.required': 'This field is required'
};

export const MessageServiceMock = new MockDotMessageService(MESSAGES_MOCK);
export const MessageServiceMock = new MockDotMessageService(MESSAGES_MOCK);

0 comments on commit 1fd3ddb

Please sign in to comment.