Skip to content
Snippets Groups Projects
Commit 4d8d1019 authored by Tifenn Guillas's avatar Tifenn Guillas
Browse files

WIP: Tests en documentation components

parent 273f48cb
No related branches found
No related tags found
2 merge requests!29Develop,!4Resolve "Add tests for instance documentation module"
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`DatasetCardDocComponent should information in HTML file 1`] = `
<app-dataset-card-doc
dataset={[Function Object]}
instanceSelected={[Function String]}
router={[Function Router]}
survey={[Function Object]}
>
<div
class="card border-0"
>
<div
class="card-body py-2"
>
<div
class="row"
>
<div
class="col"
>
<div
class="row"
>
<p
class="lead m-0 d-inline"
>
my dataset
</p>
</div>
<div
class="row"
>
<p
class="my-3"
>
This is my dataset
</p>
</div>
<div
class="row"
>
<button
class="btn btn-link p-0"
placement="bottom"
triggers="mouseenter:mouseleave"
>
<small>
More about my Survey survey
<span
class="fas fa-question-circle"
/>
</small>
</button>
</div>
</div>
<div
class="col-auto"
>
<button
class="btn btn-outline-secondary"
>
Select
</button>
</div>
</div>
</div>
</div>
</app-dataset-card-doc>
`;
import { TestBed, waitForAsync, ComponentFixture } from '@angular/core/testing';
import { RouterTestingModule } from '@angular/router/testing';
import { PopoverModule } from 'ngx-bootstrap/popover';
import { DatasetCardDocComponent } from './dataset-card-doc.component';
import { Dataset, Survey } from '../../../metamodel/models';
const SURVEY: Survey = {
name: 'mySurvey',
label: 'my Survey',
description: 'This is my survey',
link: 'http://my-survey.com',
manager: 'me',
id_database: 1,
nb_datasets: 2
};
const DATASET: Dataset = {
name: 'myDataset',
table_ref: 'table',
label: 'my dataset',
description: 'This is my dataset',
display: 1,
data_path: 'path',
survey_name: 'mySurvey',
id_dataset_family: 1,
public: true,
config: {
images: ['image1'],
cone_search: {
cone_search_enabled: true,
cone_search_opened: true,
cone_search_column_ra: 1,
cone_search_column_dec: 2,
cone_search_plot_enabled: true,
cone_search_sdss_enabled: true,
cone_search_sdss_display: 1,
cone_search_background: [{ id: 1, enabled: true, display: 1 }]
},
download: {
download_enabled: true,
download_opened: true,
download_csv: true,
download_ascii: true,
download_vo: true,
download_archive: true
},
summary: {
summary_enabled: true,
summary_opened: true
},
server_link: {
server_link_enabled: true,
server_link_opened: true
},
samp: {
samp_enabled: true,
samp_opened: true
},
datatable: {
datatable_enabled: true,
datatable_opened: true,
datatable_selectable_rows: true
}
}
};
describe('DatasetCardDocComponent', () => {
let component: DatasetCardDocComponent;
let fixture: ComponentFixture<DatasetCardDocComponent>;
let router: RouterTestingModule;
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
imports: [
RouterTestingModule,
PopoverModule.forRoot()
],
declarations: [DatasetCardDocComponent],
}).compileComponents();
fixture = TestBed.createComponent(DatasetCardDocComponent);
component = fixture.componentInstance;
router = TestBed.inject(RouterTestingModule);
component.survey = SURVEY;
component.dataset = DATASET;
component.instanceSelected = 'myInstance';
}));
it('should create the component', () => {
expect(component).toBeDefined();
});
// it('#selectDataset() should navigate to the right page', () => {
// const spy = jest.spyOn(router, 'navigate');
// component.selectDataset('myDataset');
// expect(spy).toHaveBeenCalledTimes(1);
// expect(spy).toHaveBeenCalledWith(['/instance/myInstance/documentation/myDataset']);
// });
it('should display information in HTML file', () => {
fixture.detectChanges();
expect(fixture).toMatchSnapshot();
});
});
...@@ -28,7 +28,12 @@ export class DatasetCardDocComponent { ...@@ -28,7 +28,12 @@ export class DatasetCardDocComponent {
constructor(private router: Router) { } constructor(private router: Router) { }
selectDataset(datasetName: string) { /**
* Navigates to the documentation page for the given dataset.
*
* @param {string} datasetName - The dataset name.
*/
selectDataset(datasetName: string): void {
this.router.routeReuseStrategy.shouldReuseRoute = () => false; this.router.routeReuseStrategy.shouldReuseRoute = () => false;
this.router.navigate([`/instance/${this.instanceSelected}/documentation/${datasetName}`]); this.router.navigate([`/instance/${this.instanceSelected}/documentation/${datasetName}`]);
} }
......
...@@ -52,7 +52,7 @@ describe('OutputListComponent', () => { ...@@ -52,7 +52,7 @@ describe('OutputListComponent', () => {
expect(component).toBeDefined(); expect(component).toBeDefined();
}); });
it('should information in HTML file', () => { it('should display information in HTML file', () => {
component.datasetSelected = 'myTestDataset'; component.datasetSelected = 'myTestDataset';
component.attributeList = ATTRIBUTE_LIST; component.attributeList = ATTRIBUTE_LIST;
fixture.detectChanges(); fixture.detectChanges();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment