Skip to content
Snippets Groups Projects
Commit 247df324 authored by Angapay Divin's avatar Angapay Divin
Browse files

add test for admin/instance/dataset/components/ detail-page

parent 12436d26
No related branches found
No related tags found
2 merge requests!72Develop,!66Resolve "Tests client: Tester le module dataset de la partie admin->instance"
...@@ -19,8 +19,8 @@ import { ConeSearchConfigComponent } from './cone-search-config.component'; ...@@ -19,8 +19,8 @@ import { ConeSearchConfigComponent } from './cone-search-config.component';
}) })
class ConeSearchConfigFormComponent { class ConeSearchConfigFormComponent {
form = new UntypedFormGroup({}); form = new UntypedFormGroup({});
coneSearchConfig = null;
attributeList = [] attributeList = []
coneSearchConfig: ConeSearchConfig;
} }
describe('[admin][instance][dataset][components][cone-search-config] ConeSearchConfigComponent', () => { describe('[admin][instance][dataset][components][cone-search-config] ConeSearchConfigComponent', () => {
let component: ConeSearchConfigComponent; let component: ConeSearchConfigComponent;
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* For the full copyright and license information, please view the LICENSE * For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code. * file that was distributed with this source code.
*/ */
import { Pipe, PipeTransform } from '@angular/core'; import { Component, Pipe, PipeTransform } from '@angular/core';
import { ComponentFixture, TestBed } from '@angular/core/testing'; import { ComponentFixture, TestBed } from '@angular/core/testing';
import { ReactiveFormsModule } from '@angular/forms'; import { ReactiveFormsModule } from '@angular/forms';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
...@@ -22,6 +22,15 @@ class DatasetListByFamilyPipe implements PipeTransform { ...@@ -22,6 +22,15 @@ class DatasetListByFamilyPipe implements PipeTransform {
} }
} }
@Component({
selector: 'app-edit-dataset-family',
})
export class EditDatasetFamilyComponent { }
@Component({
selector: 'app-delete-btn',
})
export class DeleteBtnComponent { }
describe('[admin][instance][dataset][components][dataset-family] DatasetFamilyCardComponent', () => { describe('[admin][instance][dataset][components][dataset-family] DatasetFamilyCardComponent', () => {
let component: DatasetFamilyCardComponent; let component: DatasetFamilyCardComponent;
let fixture: ComponentFixture<DatasetFamilyCardComponent>; let fixture: ComponentFixture<DatasetFamilyCardComponent>;
...@@ -30,7 +39,9 @@ describe('[admin][instance][dataset][components][dataset-family] DatasetFamilyCa ...@@ -30,7 +39,9 @@ describe('[admin][instance][dataset][components][dataset-family] DatasetFamilyCa
TestBed.configureTestingModule({ TestBed.configureTestingModule({
declarations: [ declarations: [
DatasetFamilyCardComponent, DatasetFamilyCardComponent,
DatasetListByFamilyPipe DatasetListByFamilyPipe,
EditDatasetFamilyComponent,
DeleteBtnComponent
], ],
imports: [ imports: [
BrowserAnimationsModule, BrowserAnimationsModule,
......
...@@ -7,11 +7,16 @@ ...@@ -7,11 +7,16 @@
* file that was distributed with this source code. * file that was distributed with this source code.
*/ */
import { Component } from '@angular/core';
import { ComponentFixture, TestBed } from '@angular/core/testing'; import { ComponentFixture, TestBed } from '@angular/core/testing';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { RouterTestingModule } from '@angular/router/testing';
import { Dataset, Instance } from 'src/app/metamodel/models'; import { Dataset, Instance } from 'src/app/metamodel/models';
import { DatasetCardComponent } from './dataset-card.component'; import { DatasetCardComponent } from './dataset-card.component';
@Component({
selector: 'app-delete-btn',
})
export class DeleteBtnComponent { }
describe('[admin][instance][dataset][components][dataset] DatasetCardComponent', () => { describe('[admin][instance][dataset][components][dataset] DatasetCardComponent', () => {
let component: DatasetCardComponent; let component: DatasetCardComponent;
let fixture: ComponentFixture<DatasetCardComponent>; let fixture: ComponentFixture<DatasetCardComponent>;
...@@ -19,9 +24,13 @@ describe('[admin][instance][dataset][components][dataset] DatasetCardComponent', ...@@ -19,9 +24,13 @@ describe('[admin][instance][dataset][components][dataset] DatasetCardComponent',
TestBed.configureTestingModule({ TestBed.configureTestingModule({
declarations: [ declarations: [
DatasetCardComponent, DatasetCardComponent,
DeleteBtnComponent
], ],
imports: [ imports: [
BrowserAnimationsModule BrowserAnimationsModule,
RouterTestingModule.withRoutes([
{ path: 'test', component: DeleteBtnComponent }
])
], ],
}); });
fixture = TestBed.createComponent(DatasetCardComponent); fixture = TestBed.createComponent(DatasetCardComponent);
......
/**
* This file is part of Anis Client.
*
* @copyright Laboratoire d'Astrophysique de Marseille / CNRS
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
import { Component } from '@angular/core';
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { ReactiveFormsModule, UntypedFormGroup } from '@angular/forms';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { DetailConfigFormComponent } from './detail-config-form.component';
@Component({
selector: 'app-webpage-form-content'
})
class WebpageFormContentComponent {
form: UntypedFormGroup;
}
describe('[admin][instance][dataset][components][detail-page] DetailConfigFormComponent', () => {
let component: DetailConfigFormComponent;
let fixture: ComponentFixture<DetailConfigFormComponent>;
beforeEach(() => {
TestBed.configureTestingModule({
declarations: [
DetailConfigFormComponent,
WebpageFormContentComponent
],
imports: [
BrowserAnimationsModule,
ReactiveFormsModule
],
});
fixture = TestBed.createComponent(DetailConfigFormComponent);
component = fixture.componentInstance;
component.detailConfig = { content: '', id: 1, style_sheet: 'test' };
fixture.detectChanges();
});
it('should create the component', () => {
expect(component).toBeTruthy();
});
it('submit() should emit databaseFamily and form.value', () => {
let spy = jest.spyOn(component.onSubmit, 'emit');
let spyOnForm = jest.spyOn(component.form, 'markAsPristine');
component.submit();
expect(spy).toHaveBeenCalledTimes(1);
expect(spyOnForm).toHaveBeenCalledTimes(1);
expect(spy).toHaveBeenCalledWith({ ...component.form.getRawValue() });
});
});
/**
* This file is part of Anis Client.
*
* @copyright Laboratoire d'Astrophysique de Marseille / CNRS
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
import { Component } from '@angular/core';
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { ReactiveFormsModule, UntypedFormControl, UntypedFormGroup } from '@angular/forms';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations'
import { DetailConfig } from 'src/app/metamodel/models';
import { DetailConfigComponent } from './detail-config.component';
@Component({
selector: 'app-detail-config-form',
templateUrl: 'detail-config-form.component.html',
})
class DetailConfigFormComponent {
form = new UntypedFormGroup({
content: new UntypedFormControl(),
style_sheet: new UntypedFormControl(null)
});
}
describe('[admin][instance][dataset][components][detail-page] DetailConfigComponent', () => {
let component: DetailConfigComponent;
let fixture: ComponentFixture<DetailConfigComponent>;
beforeEach(() => {
TestBed.configureTestingModule({
declarations: [
DetailConfigComponent,
DetailConfigFormComponent
],
imports: [
BrowserAnimationsModule,
ReactiveFormsModule
],
});
fixture = TestBed.createComponent(DetailConfigComponent);
component = fixture.componentInstance;
component.detailConfig = { content: '', id: 1, style_sheet: 'test' };
fixture.detectChanges();
});
it('should create the component', () => {
expect(component).toBeTruthy();
});
it('save(detailConfig) should emit component.detailConfig and detaiConfig', () => {
let spy = jest.spyOn(component.editDetailConfig, 'emit');
let detailConfig: DetailConfig = { content: '', id: 1, style_sheet: 'test2' };
component.save(detailConfig);
expect(spy).toHaveBeenCalledTimes(1);
expect(spy).toHaveBeenCalledWith({ ...component.detailConfig, ...detailConfig });
});
it('save(detailConfig) should emit detaiConfig only', () => {
let spy = jest.spyOn(component.addDetailConfig, 'emit');
let detailConfig: DetailConfig = { content: '', id: 1, style_sheet: 'test2' };
component.detailConfig = null;
component.save(detailConfig);
expect(spy).toHaveBeenCalledTimes(1);
expect(spy).toHaveBeenCalledWith({ ...detailConfig });
});
});
/**
* This file is part of Anis Client.
*
* @copyright Laboratoire d'Astrophysique de Marseille / CNRS
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
import { detailConfigComponents } from './index';
describe('[admin][instance][dataset][components]detail-page] index', () => {
it('should test detail-page index components', () => {
expect(detailConfigComponents.length).toEqual(2);
});
});
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