Skip to content
Snippets Groups Projects
Commit 78ba4edc authored by François Agneray's avatar François Agneray
Browse files

Fixed indent

parent 451d2688
No related branches found
No related tags found
2 merge requests!72Develop,!59Resolve "Tests client: Tester le module database de la partie admin"
......@@ -10,10 +10,10 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { ReactiveFormsModule } from '@angular/forms';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { DatabaseFormComponent } from './database-form.component';
describe('[admin][Database][Component] databaseFormComponent', () => {
let component: DatabaseFormComponent;
let fixture: ComponentFixture<DatabaseFormComponent>;
......@@ -30,24 +30,23 @@ describe('[admin][Database][Component] databaseFormComponent', () => {
});
fixture = TestBed.createComponent(DatabaseFormComponent);
component = fixture.componentInstance;
component.database= {id: 1, dbhost: 'test',dblogin: 'test@test.fr', dbname:'test',dbpassword: 'test',dbport: 808080, dbtype: '',label:''};
component.database= {id: 1, dbhost: 'test', dblogin: 'test@test.fr', dbname:'test', dbpassword: 'test', dbport: 808080, dbtype: '', label:''};
fixture.detectChanges();
spy= jest.spyOn(component.onSubmit, 'emit');
});
it('should create the component', () => {
expect(component).toBeTruthy();
});
it(`should emit database and form values on subumit`, () => {
component.submit();
expect(spy).toHaveBeenCalledTimes(1);
});
it(`should emit database on subumit`, () => {
component.database= null;
component.submit();
expect(spy).toHaveBeenCalledTimes(1);
});
});
......@@ -8,32 +8,29 @@
*/
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { DatabaseTableComponent } from './database-table.component';
describe('[admin][Database][Component] databaseTableComponent', () => {
let component: DatabaseTableComponent;
let fixture: ComponentFixture<DatabaseTableComponent>;
beforeEach(() => {
TestBed.configureTestingModule({
declarations: [
DatabaseTableComponent,
],
imports: [
BrowserAnimationsModule,
]
});
fixture = TestBed.createComponent(DatabaseTableComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create the component', () => {
expect(component).toBeTruthy();
});
});
\ No newline at end of file
describe('[admin][Database][Component] databaseTableComponent', () => {
let component: DatabaseTableComponent;
let fixture: ComponentFixture<DatabaseTableComponent>;
beforeEach(() => {
TestBed.configureTestingModule({
declarations: [
DatabaseTableComponent,
],
imports: [
BrowserAnimationsModule,
]
});
fixture = TestBed.createComponent(DatabaseTableComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create the component', () => {
expect(component).toBeTruthy();
});
});
......@@ -7,16 +7,20 @@
* file that was distributed with this source code.
*/
import { ComponentFixture, TestBed } from "@angular/core/testing";
import { BrowserAnimationsModule } from "@angular/platform-browser/animations";
import { MockStore, provideMockStore } from "@ngrx/store/testing";
import { Database } from "src/app/metamodel/models";
import { DatabaseListComponent } from "./database-list.component"
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { MockStore, provideMockStore } from '@ngrx/store/testing';
import { Database } from 'src/app/metamodel/models';
import * as databaseActions from 'src/app/metamodel/actions/database.actions';
describe('[admin][Database][Containers] DatabaseListComponent', () => {
import { DatabaseListComponent } from './database-list.component';
describe('[admin][Database][Containers] DatabaseListComponent', () => {
let component : DatabaseListComponent;
let fixture : ComponentFixture<DatabaseListComponent>;
let store: MockStore;
beforeEach(() => {
TestBed.configureTestingModule({
declarations: [
......@@ -33,8 +37,8 @@ import * as databaseActions from 'src/app/metamodel/actions/database.actions';
component = fixture.componentInstance;
store = TestBed.inject(MockStore);
fixture.detectChanges();
});
it('should create the component', () => {
expect(component).toBeTruthy();
});
......@@ -46,5 +50,4 @@ import * as databaseActions from 'src/app/metamodel/actions/database.actions';
expect(spy).toHaveBeenCalledTimes(1);
expect(spy).toHaveBeenCalledWith(databaseActions.deleteDatabase({database}));
});
})
\ No newline at end of file
})
......@@ -7,14 +7,16 @@
* file that was distributed with this source code.
*/
import { ComponentFixture, TestBed } from "@angular/core/testing";
import { BrowserAnimationsModule } from "@angular/platform-browser/animations";
import { MockStore, provideMockStore } from "@ngrx/store/testing";
import { EditDatabaseComponent } from "./edit-database.component"
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { MockStore, provideMockStore } from '@ngrx/store/testing';
import * as databaseActions from 'src/app/metamodel/actions/database.actions';
import { Database } from "src/app/metamodel/models";
describe('[admin][Database][Containers] EditDatabaseComponent', () => {
import { Database } from 'src/app/metamodel/models';
import { EditDatabaseComponent } from './edit-database.component';
describe('[admin][Database][Containers] EditDatabaseComponent', () => {
let component: EditDatabaseComponent;
let fixture: ComponentFixture<EditDatabaseComponent>;
let store: MockStore;
......@@ -30,24 +32,22 @@ describe('[admin][Database][Containers] EditDatabaseComponent', () => {
providers: [
provideMockStore({})
]
})
fixture = TestBed.createComponent(EditDatabaseComponent);
component = fixture.componentInstance;
store = TestBed.inject(MockStore);
fixture.detectChanges();
});
it('should create component', () => {
it('should create component', () => {
expect(component).toBeTruthy();
});
it('#editDatabase(database) should dispatch editdatabase action', () => {
const spy = jest.spyOn(store, 'dispatch');
let database : Database = {id: 1, dbhost: 'test',dblogin: 'test@test.fr', dbname:'test',dbpassword: 'test',dbport: 808080, dbtype: '',label:''};
let database : Database = {id: 1, dbhost: 'test', dblogin: 'test@test.fr', dbname: 'test', dbpassword: 'test', dbport: 808080, dbtype: '', label: ''};
component.editDatabase(database);
expect(spy).toHaveBeenCalledTimes(1);
expect(spy).toHaveBeenCalledWith(databaseActions.editDatabase({database}));
});
})
\ No newline at end of file
})
......@@ -7,47 +7,46 @@
* file that was distributed with this source code.
*/
import { ComponentFixture, TestBed } from "@angular/core/testing";
import { BrowserAnimationsModule } from "@angular/platform-browser/animations";
import { MockStore, provideMockStore } from "@ngrx/store/testing";
import { Database } from "src/app/metamodel/models";
import { NewDatabaseComponent } from "./new-database.component";
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { MockStore, provideMockStore } from '@ngrx/store/testing';
import { Database } from 'src/app/metamodel/models';
import * as databaseActions from 'src/app/metamodel/actions/database.actions';
import { NewDatabaseComponent } from './new-database.component';
describe('[admin][Database][Containers] NewDatabaseComponent', () => {
let component: NewDatabaseComponent;
let fixture: ComponentFixture<NewDatabaseComponent>;
let store: MockStore;
beforeEach(() => {
TestBed.configureTestingModule({
declarations: [
NewDatabaseComponent
],
imports: [
BrowserAnimationsModule,
],
providers: [
provideMockStore({})
]
})
fixture = TestBed.createComponent(NewDatabaseComponent);
component = fixture.componentInstance;
store = TestBed.inject(MockStore);
});
it('should create component', () => {
expect(component).toBeTruthy();
});
describe('[admin][Database][Containers] NewDatabaseComponent', () => {
let component: NewDatabaseComponent;
let fixture: ComponentFixture<NewDatabaseComponent>;
let store: MockStore;
beforeEach(() => {
TestBed.configureTestingModule({
declarations: [
NewDatabaseComponent
],
imports: [
BrowserAnimationsModule,
],
providers: [
provideMockStore({})
]
})
fixture = TestBed.createComponent(NewDatabaseComponent);
component = fixture.componentInstance;
store = TestBed.inject(MockStore);
});
it('should create component', () => {
expect(component).toBeTruthy();
});
it('#addNewDatabase(database) should dispatch addDatabase action', () => {
const spy = jest.spyOn(store, 'dispatch');
let database : Database = {id: 1, dbhost: 'test',dblogin: 'test@test.fr', dbname:'test',dbpassword: 'test',dbport: 808080, dbtype: '',label:''};
component.addNewDatabase(database);
expect(spy).toHaveBeenCalledTimes(1);
expect(spy).toHaveBeenCalledWith(databaseActions.addDatabase({database}));
});
})
\ No newline at end of file
it('#addNewDatabase(database) should dispatch addDatabase action', () => {
const spy = jest.spyOn(store, 'dispatch');
let database : Database = {id: 1, dbhost: 'test',dblogin: 'test@test.fr', dbname:'test',dbpassword: 'test',dbport: 808080, dbtype: '',label:''};
component.addNewDatabase(database);
expect(spy).toHaveBeenCalledTimes(1);
expect(spy).toHaveBeenCalledWith(databaseActions.addDatabase({database}));
});
})
......@@ -7,38 +7,31 @@
* file that was distributed with this source code.
*/
import { TestBed } from '@angular/core/testing';
import { TestBed } from '@angular/core/testing';
import { MockStore, provideMockStore } from '@ngrx/store/testing';
import { Observable, of } from 'rxjs';
import { MetamodelModule } from 'src/app/metamodel/metamodel.module';
import { DatabaseTitleResolver } from './database-title.resolver';
import { cold, hot } from 'jasmine-marbles';
import * as databaseActions from 'src/app/metamodel/actions/database.actions';
import * as databaseSelector from 'src/app/metamodel/selectors/database.selector';
import { cold, hot } from 'jasmine-marbles';
import { Database } from 'src/app/metamodel/models';
import { DatabaseTitleResolver } from './database-title.resolver';
describe('[Database] DatabaseTitleResolver', () => {
describe('[Database] DatabaseTitleResolver', () => {
let databaseTitleResolver : DatabaseTitleResolver;
let store: MockStore;
let mockDatabaseSelectorDatabaseListIsLoaded;
let mockDatabaseSelectorDatabaseByRouteId;
let actions = new Observable();
let database : Database = {id: 1, dbhost: 'test',dblogin: 'test@test.fr', dbname:'test',dbpassword: 'test',dbport: 808080, dbtype: '',label:'test'};
beforeEach( () =>{
let database : Database = {id: 1, dbhost: 'test', dblogin: 'test@test.fr', dbname: 'test', dbpassword: 'test', dbport: 808080, dbtype: '', label: 'test'};
beforeEach(() => {
TestBed.configureTestingModule({
imports: [],
providers: [
DatabaseTitleResolver,
provideMockStore({}),
]
})
store = TestBed.inject(MockStore);
......@@ -46,23 +39,19 @@ import { Database } from 'src/app/metamodel/models';
mockDatabaseSelectorDatabaseListIsLoaded = store.overrideSelector(databaseSelector.selectDatabaseListIsLoaded, false);
mockDatabaseSelectorDatabaseByRouteId = store.overrideSelector(databaseSelector.selectDatabaseByRouteId, database);
});
it('should be created', () => {
it('should be created', () => {
expect(databaseTitleResolver).toBeTruthy();
});
it('shou dispatch databaseActions loadDatabaseList action and return databaseListIsLoaded ', () => {
const expected = cold('a', {a: []});
let spy = jest.spyOn(store, 'dispatch');
let result = hot ('a', {a: databaseTitleResolver.resolve(null,null)});
expect(result).toBeObservable(expected);
expect(spy).toHaveBeenCalledTimes(1);
expect(spy).toHaveBeenCalledWith(databaseActions.loadDatabaseList());
});
});
});
\ No newline at end of file
......@@ -7,7 +7,7 @@
* file that was distributed with this source code.
*/
import {DatabaseModule} from './database.module';
import { DatabaseModule } from './database.module';
describe('[Database] DatabaseModule', () => {
it('Test Database module', () => {
......
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