Skip to content
Snippets Groups Projects
dataset-by-family.component.spec.ts 5.25 KiB
Newer Older
  • Learn to ignore specific revisions
  • import { TestBed, waitForAsync, ComponentFixture  } from '@angular/core/testing';
    import { Component, Input } from '@angular/core';
    
    import { AccordionModule } from 'ngx-bootstrap/accordion';
    
    import { DatasetByFamilyComponent } from './dataset-by-family.component';
    import { sharedPipes } from 'src/app/shared/pipes'
    import { Dataset, DatasetFamily, Survey } from '../../../metamodel/models';
    
    const DATASET_LIST: Dataset[] = [
        {
            name: 'myDataset1',
            table_ref: 'table1',
            label: 'my dataset one',
            description: 'This is my dataset one',
            display: 1,
            data_path: 'path1',
            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
                }
            }
        },
        {
            name: 'myDataset2',
            table_ref: 'table2',
            label: 'my dataset two',
            description: 'This is my dataset two',
            display: 2,
            data_path: 'path2',
            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
                }
            }
        }
    ];
    const DATASET_FAMILY_LIST: DatasetFamily[] = [
        {
            id: 1,
            label: 'datasetFamily1',
            display: 1,
            opened: true
        },
        {
            id: 2,
            label: 'datasetFamily2',
            display: 2,
            opened: true
        }
    ];
    const SURVEY_LIST: Survey[] = [
        {
            name: 'survey1',
            label: 'Survey one',
            description: 'This is survey one',
            link: 'http://survey1.com',
            manager: 'me',
            id_database: 1,
            nb_datasets: 2
        },
        {
            name: 'survey2',
            label: 'Survey two',
            description: 'This is survey two',
            link: 'http://survey2.com',
            manager: 'me',
            id_database: 1,
            nb_datasets: 2
        }
    ];
    
    describe('DatasetByFamilyComponent', () => {
        @Component({ selector: '<app-dataset-card-doc', template: '' })
        class DatasetCardDocStubComponent {
            @Input() survey: Survey;
            @Input() dataset: Dataset;
            @Input() instanceSelected: string;
        }
    
        let component: DatasetByFamilyComponent;
        let fixture: ComponentFixture<DatasetByFamilyComponent>;
    
        beforeEach(waitForAsync(() => {
            TestBed.configureTestingModule({
                imports: [AccordionModule.forRoot()],
                declarations: [
                    DatasetByFamilyComponent,
                    DatasetCardDocStubComponent,
                    sharedPipes
                ]
    
            }).compileComponents();
            fixture = TestBed.createComponent(DatasetByFamilyComponent);
            component = fixture.componentInstance;
    
            component.datasetList = DATASET_LIST;
            component.datasetFamilyList = DATASET_FAMILY_LIST;
            component.surveyList = SURVEY_LIST;
            component.instanceSelected = 'myInstance';
        }));
    
        it('should create the component', () => {
            expect(component).toBeDefined();
        });
    });