Skip to content

Commit e452566

Browse files
committed
Fix tests
1 parent cf1faa9 commit e452566

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

projects/core/src/lib/components/edit/edit-dialog/edit-dialog.component.spec.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { render, screen } from '@testing-library/angular';
22
import { EditDialogComponent } from './edit-dialog.component';
33
import { provideMockStore } from '@ngrx/store/testing';
4-
import { SharedModule } from '@tailormap-viewer/shared';
4+
import { LoadingStateEnum, SharedModule } from '@tailormap-viewer/shared';
55
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
66
import { AttributeType, getAppLayerModel, getFeatureModel, UniqueValuesService } from '@tailormap-viewer/api';
77
import { MatIconTestingModule } from '@angular/material/icon/testing';
@@ -15,6 +15,8 @@ import { of } from 'rxjs';
1515
import { ViewerLayoutService } from '../../../services/viewer-layout/viewer-layout.service';
1616
import { CoreSharedModule } from '../../../shared';
1717
import { getMapServiceMock } from '../../../test-helpers/map-service.mock.spec';
18+
import { EditMapToolService } from '../services/edit-map-tool.service';
19+
import { coreStateKey, initialCoreState, selectViewerLoadingState, ViewerState } from '../../../state';
1820

1921
const getFeatureInfo = (): FeatureWithMetadataModel => {
2022
return {
@@ -42,9 +44,13 @@ const setup = async (getLayerDetails = false, selectors: any[] = []) => {
4244
},
4345
{ provide: EditFeatureService, useValue: {} },
4446
getMapServiceMock().provider,
45-
provideMockStore({ initialState: { [editStateKey]: { ...initialEditState } }, selectors }),
47+
provideMockStore({ initialState: {
48+
[editStateKey]: { ...initialEditState },
49+
[coreStateKey]: { ...initialCoreState, viewer: { components: [] } as ViewerState },
50+
}, selectors }),
4651
{ provide: UniqueValuesService, useValue: { clearCaches: jest.fn() } },
4752
{ provide: ViewerLayoutService, useValue: { setLeftPadding: jest.fn(), setRightPadding: jest.fn() } },
53+
{ provide: EditMapToolService, useValue: { allEditGeometry$: of() } },
4854
],
4955
schemas: [CUSTOM_ELEMENTS_SCHEMA],
5056
});
@@ -63,7 +69,7 @@ describe('EditDialogComponent', () => {
6369
{ selector: selectSelectedEditFeature, value: getFeatureInfo() },
6470
{ selector: selectEditDialogVisible, value: true },
6571
]);
66-
expect(await screen.findByText('Edit')).toBeInTheDocument();
72+
expect(await screen.findByText('Edit feature')).toBeInTheDocument();
6773
expect(await screen.findByText('Close')).toBeInTheDocument();
6874
expect(await screen.findByText('Save')).toBeInTheDocument();
6975
expect(await screen.findByText('Delete')).toBeInTheDocument();

projects/core/src/lib/components/edit/edit/edit.component.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,14 @@ import { selectEditActive, selectSelectedEditLayer } from "../state/edit.selecto
88
import { SharedModule } from "@tailormap-viewer/shared";
99
import { MatIconTestingModule } from "@angular/material/icon/testing";
1010
import { AuthenticatedUserTestHelper } from '../../../test-helpers/authenticated-user-test.helper';
11+
import { HttpXsrfTokenExtractor } from '@angular/common/http';
1112

1213
const setup = async (hasLayers: boolean, authenticated: boolean) => {
1314
await render(EditComponent, {
1415
imports: [ SharedModule, MatIconTestingModule ],
1516
schemas: [CUSTOM_ELEMENTS_SCHEMA],
1617
providers: [
18+
{ provide: HttpXsrfTokenExtractor, useValue: {} as HttpXsrfTokenExtractor },
1719
{ provide: TAILORMAP_API_V1_SERVICE, useClass: TailormapApiV1MockService },
1820
AuthenticatedUserTestHelper.provideAuthenticatedUserService(authenticated, []),
1921
provideMockStore({
@@ -35,8 +37,6 @@ describe('EditComponent', () => {
3537
const buttons = screen.getAllByRole('button');
3638
expect(buttons[0]).toBeVisible();
3739
expect(buttons[0]).not.toHaveClass("disabled");
38-
expect(buttons[1]).toBeVisible();
39-
expect(buttons[1]).toHaveClass("disabled");
4040
});
4141

4242
test('should be disabled when user is not logged in button', async () => {

0 commit comments

Comments
 (0)