Skip to content

Commit

Permalink
rollback test
Browse files Browse the repository at this point in the history
  • Loading branch information
oidacra committed Dec 8, 2023
1 parent 28ec67e commit f86a0cc
Showing 1 changed file with 23 additions and 16 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import { byTestId, createComponentFactory, mockProvider, Spectator } from '@ngneat/spectator/jest';
import { of } from 'rxjs';
import { byTestId, createComponentFactory, Spectator } from '@ngneat/spectator/jest';

import { HttpClient } from '@angular/common/http';
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { Validators } from '@angular/forms';

import { TabView } from 'primeng/tabview';

import { DotMessageService } from '@dotcms/data-access';
import { MockDotMessageService } from '@dotcms/utils-testing';

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

Expand All @@ -21,26 +20,31 @@ import {
} from '../../utils/mocks';
import { DotEditContentFieldComponent } from '../dot-edit-content-field/dot-edit-content-field.component';

// TODO: Find a way to mock the DotMessageService
const dotMessageServiceMock = {
init: jest.fn(),
get: jest.fn().mockReturnValue('Mocked Response')
};

// TODO: Find a way to mock the HttpClient
const httpClientMock = {
get: jest.fn().mockReturnValue(of({}))
};
// // TODO: Find a way to mock the DotMessageService
// const dotMessageServiceMock = {
// init: jest.fn(),
// get: jest.fn().mockReturnValue('Mocked Response')
// };
//
// // TODO: Find a way to mock the HttpClient
// const httpClientMock = {
// get: jest.fn().mockReturnValue(of({}))
// };

describe('DotFormComponent', () => {
let spectator: Spectator<DotEditContentFormComponent>;

let dotMessageService: DotMessageService;
const createComponent = createComponentFactory({
component: DotEditContentFormComponent,
imports: [HttpClientTestingModule],
providers: [
mockProvider(HttpClient, httpClientMock),
{ provide: DotMessageService, useValue: dotMessageServiceMock }
{
provide: DotMessageService,
useValue: new MockDotMessageService({
Save: 'Save',
Content: 'content'
})
}
]
});

Expand Down Expand Up @@ -137,13 +141,16 @@ describe('DotFormComponent', () => {
}
}
});
dotMessageService = spectator.inject(DotMessageService, true);
});

it('should have a p-tabView', () => {
jest.spyOn(dotMessageService, 'get');
spectator.detectChanges();
const tabViewComponent = spectator.query(TabView);
expect(tabViewComponent.scrollable).toBeTruthy();
expect(tabViewComponent).toExist();
expect(dotMessageService.get).toHaveBeenCalled();
});
});
});

0 comments on commit f86a0cc

Please sign in to comment.