Commit 480d4198 authored by Tifenn Guillas's avatar Tifenn Guillas
Browse files

Fix tests

parent 44d5ee6e
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { NavComponent } from './nav.component';
import { INSTANCE } from '../../../settings/test-data/instance';
describe('[Core] Component: NavComponent', () => {
let component: NavComponent;
......@@ -52,18 +53,7 @@ describe('[Core] Component: NavComponent', () => {
});
it('should display search, search multiple and documentation links if instance config allows it', () => {
component.instance = {
name: 'toto',
label: 'Toto',
client_url: '',
nb_dataset_families: 1,
nb_datasets: 1,
config: {
search: true,
search_multiple: true,
documentation: true
}
};
component.instance = INSTANCE;
fixture.detectChanges();
const template = fixture.nativeElement;
expect(template.querySelector('#search_link')).toBeTruthy();
......@@ -80,7 +70,10 @@ describe('[Core] Component: NavComponent', () => {
nb_datasets: 1,
config: {
search: false,
search_multiple: false,
search_multiple: {
allowed: false,
all_datasets_selected: false
},
documentation: false
} };
fixture.detectChanges();
......@@ -99,7 +92,10 @@ describe('[Core] Component: NavComponent', () => {
nb_datasets: 1,
config: {
search: true,
search_multiple: false,
search_multiple: {
allowed: false,
all_datasets_selected: false
},
documentation: false
}
};
......@@ -112,7 +108,10 @@ describe('[Core] Component: NavComponent', () => {
nb_datasets: 1,
config: {
search: false,
search_multiple: false,
search_multiple: {
allowed: false,
all_datasets_selected: false
},
documentation: false
} };
expect(component.isSearchAllowed()).toBeFalsy();
......@@ -127,7 +126,10 @@ describe('[Core] Component: NavComponent', () => {
nb_datasets: 1,
config: {
search: true,
search_multiple: true,
search_multiple: {
allowed: true,
all_datasets_selected: false
},
documentation: false
}
};
......@@ -140,7 +142,10 @@ describe('[Core] Component: NavComponent', () => {
nb_datasets: 1,
config: {
search: true,
search_multiple: false,
search_multiple: {
allowed: false,
all_datasets_selected: false
},
documentation: false
}
};
......@@ -156,7 +161,10 @@ describe('[Core] Component: NavComponent', () => {
nb_datasets: 1,
config: {
search: true,
search_multiple: true,
search_multiple: {
allowed: true,
all_datasets_selected: false
},
documentation: true
}
};
......@@ -169,7 +177,10 @@ describe('[Core] Component: NavComponent', () => {
nb_datasets: 1,
config: {
search: true,
search_multiple: true,
search_multiple: {
allowed: true,
all_datasets_selected: false
},
documentation: false
}
};
......
......@@ -26,7 +26,7 @@ export class NavComponent {
isSearchMultipleAllowed(): boolean {
if (this.instance && this.instance.config.search_multiple) {
return this.instance.config.search_multiple;
return this.instance.config.search_multiple.allowed;
}
return false;
}
......
import * as instanceActions from './instance.action';
import { Instance } from '../model';
import { INSTANCE } from '../../../settings/test-data/instance';
describe('[Metamodel] Instance action', () => {
it('should create LoadInstanceMetaAction', () => {
......@@ -8,21 +8,9 @@ describe('[Metamodel] Instance action', () => {
});
it('should create LoadDatasetSearchMetaSuccessAction', () => {
const payload: Instance = {
name: 'toto',
label: 'Toto',
client_url: '',
nb_dataset_families: 1,
nb_datasets: 1,
config: {
search: true,
search_multiple: true,
documentation: true
}
};
const action = new instanceActions.LoadInstanceMetaSuccessAction(payload);
const action = new instanceActions.LoadInstanceMetaSuccessAction(INSTANCE);
expect(action.type).toEqual(instanceActions.LOAD_INSTANCE_META_SUCCESS);
expect(action.payload).toEqual(payload);
expect(action.payload).toEqual(INSTANCE);
});
it('should create LoadDatasetSearchMetaFailAction', () => {
......
import * as fromInstance from './instance.reducer';
import * as instanceActions from '../action/instance.action';
import { Instance } from '../model';
import { INSTANCE } from '../../../settings/test-data/instance';
describe('[Metamodel] Instance reducer', () => {
it('should return init state', () => {
......@@ -12,18 +13,7 @@ describe('[Metamodel] Instance reducer', () => {
});
it('should set instance', () => {
const instance: Instance = {
name: 'toto',
label: 'Toto',
client_url: '',
nb_dataset_families: 1,
nb_datasets: 1,
config: {
search: true,
search_multiple: true,
documentation: true
}
};
const instance: Instance = INSTANCE;
const { initialState } = fromInstance;
const action = new instanceActions.LoadInstanceMetaSuccessAction(instance);
const state = fromInstance.reducer(initialState, action);
......
import { Instance } from '../../app/metamodel/model';
export const INSTANCE: Instance = {
name: 'instance',
label: 'Instance',
client_url: 'http://localhost.com',
nb_dataset_families: 2,
nb_datasets: 3,
config: {
search: true,
search_multiple: {
allowed: true,
all_datasets_selected: true,
},
documentation: true
}
};
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment