Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
anis
anis-client
Commits
6510eeab
Commit
6510eeab
authored
Oct 21, 2020
by
Tifenn Guillas
Browse files
Tests => DONE
parent
dc0c6ea6
Changes
7
Hide whitespace changes
Inline
Side-by-side
src/app/detail/components/default-object.component.spec.ts
0 → 100644
View file @
6510eeab
import
{
async
,
ComponentFixture
,
TestBed
}
from
'
@angular/core/testing
'
;
import
{
Component
,
Input
}
from
'
@angular/core
'
;
import
{
DefaultObjectComponent
}
from
'
./default-object.component
'
;
import
{
Attribute
,
Category
,
Family
}
from
'
../../metamodel/model
'
;
describe
(
'
[Detail] Component: DefaultObjectComponent
'
,
()
=>
{
@
Component
({
selector
:
'
app-object-data
'
,
template
:
''
})
class
ObjectDataStubComponent
{
@
Input
()
datasetName
:
string
;
@
Input
()
outputFamilyList
:
Family
[];
@
Input
()
categoryList
:
Category
[];
@
Input
()
attributeList
:
Attribute
[];
@
Input
()
object
:
any
;
}
let
component
:
DefaultObjectComponent
;
let
fixture
:
ComponentFixture
<
DefaultObjectComponent
>
;
beforeEach
(
async
(()
=>
{
TestBed
.
configureTestingModule
({
declarations
:
[
DefaultObjectComponent
,
ObjectDataStubComponent
]
});
fixture
=
TestBed
.
createComponent
(
DefaultObjectComponent
);
component
=
fixture
.
componentInstance
;
}));
it
(
'
should create the component
'
,
()
=>
{
expect
(
component
).
toBeTruthy
();
});
});
src/app/detail/components/object-data.component.spec.ts
0 → 100644
View file @
6510eeab
import
{
async
,
ComponentFixture
,
TestBed
}
from
'
@angular/core/testing
'
;
import
{
AccordionModule
}
from
'
ngx-bootstrap/accordion
'
;
import
{
ObjectDataComponent
}
from
'
./object-data.component
'
;
import
{
ATTRIBUTE_LIST
,
CATEGORY_LIST
}
from
'
../../../settings/test-data
'
;
describe
(
'
[Detail] Component: ObjectDataComponent
'
,
()
=>
{
let
component
:
ObjectDataComponent
;
let
fixture
:
ComponentFixture
<
ObjectDataComponent
>
;
beforeEach
(
async
(()
=>
{
TestBed
.
configureTestingModule
({
declarations
:
[
ObjectDataComponent
],
imports
:
[
AccordionModule
.
forRoot
()]
});
fixture
=
TestBed
.
createComponent
(
ObjectDataComponent
);
component
=
fixture
.
componentInstance
;
}));
it
(
'
should create the component
'
,
()
=>
{
expect
(
component
).
toBeTruthy
();
});
it
(
'
#getCategoryByFamilySortedByDisplay() should return sorted categories for the given family
'
,
()
=>
{
component
.
categoryList
=
CATEGORY_LIST
;
expect
(
component
.
getCategoryByFamilySortedByDisplay
(
1
).
length
).
toEqual
(
2
);
});
it
(
'
#getAttributesVisibleByCategory() should return visible attributes for the given category
'
,
()
=>
{
component
.
attributeList
=
ATTRIBUTE_LIST
;
expect
(
component
.
getAttributesVisibleByCategory
(
1
).
length
).
toEqual
(
1
);
expect
(
component
.
getAttributesVisibleByCategory
(
1
)[
0
].
id
).
toEqual
(
1
);
});
it
(
'
#getAttributesVisible() should return visible attributes
'
,
()
=>
{
component
.
attributeList
=
ATTRIBUTE_LIST
;
expect
(
component
.
getAttributesVisible
().
length
).
toEqual
(
2
);
});
it
(
'
#getAttributeBySearchFlag() should return attribute for the given search_flag
'
,
()
=>
{
component
.
attributeList
=
ATTRIBUTE_LIST
;
expect
(
component
.
getAttributeBySearchFlag
(
'
ID
'
).
name
).
toEqual
(
'
name_one
'
);
});
});
src/app/detail/components/object-data.component.ts
View file @
6510eeab
import
{
Component
,
Input
,
ChangeDetectionStrategy
}
from
'
@angular/core
'
;
import
{
Attribute
,
Category
,
Family
}
from
'
../../metamodel/model
'
;
import
{
getHost
}
from
'
../../shared/utils
'
;
@
Component
({
selector
:
'
app-object-data
'
,
...
...
src/app/detail/components/spectra/spectra-object.component.spec.ts
View file @
6510eeab
// import { ComponentFixture, TestBed } from '@angular/core/testing';
//
// import { AccordionModule } from 'ngx-bootstrap/accordion';
//
// import { ObjectDisplayComponent } from './spectra-object.component';
// import { Attribute } from '../../../metamodel/model';
// import { ATTRIBUTE_LIST, CATEGORY_LIST, OBJECT_DETAIL } from '../../../../settings/test-data';
//
// describe('[Detail] Component: ObjectDisplayComponent', () => {
// let component: ObjectDisplayComponent;
// let fixture: ComponentFixture<ObjectDisplayComponent>;
//
// beforeEach(() => {
// TestBed.configureTestingModule({
// declarations: [ObjectDisplayComponent],
// imports: [AccordionModule.forRoot()]
// });
// fixture = TestBed.createComponent(ObjectDisplayComponent);
// component = fixture.componentInstance;
// });
//
// it('should create the component', () => {
// expect(component).toBeTruthy();
// });
//
// it('#ngOnInit() should emit getSpectraCSV event if an attribute have spectra_graph renderer_detail', () => {
// component.attributeList = ATTRIBUTE_LIST;
// component.object = OBJECT_DETAIL;
// component.getSpectraCSV.subscribe((event: string) => expect(event).toEqual('spec1d'));
// component.ngOnInit();
// // To prevent `Spec has no expectation' bug
// expect(true).toBeTruthy();
// });
//
// it('#getSpectra() should return url to download spectra', () => {
// component.datasetName = 'dname';
// component.attributeList = ATTRIBUTE_LIST;
// component.object = OBJECT_DETAIL;
// expect(component.getSpectra()).toEqual('http://localhost:8080/download-file/dname/spec1d');
// });
//
// it('#getCategoryByFamilySortedByDisplay() should return sorted categories for the given family', () => {
// component.categoryList = CATEGORY_LIST;
// expect(component.getCategoryByFamilySortedByDisplay(1).length).toEqual(2);
// });
//
// it('#getAttributesVisibleByCategory() should return visible attributes for the given category', () => {
// component.attributeList = ATTRIBUTE_LIST;
// expect(component.getAttributesVisibleByCategory(1).length).toEqual(1);
// expect(component.getAttributesVisibleByCategory(1)[0].id).toEqual(1);
// });
//
// it('#getAttributesVisible() should return visible attributes', () => {
// component.attributeList = ATTRIBUTE_LIST;
// expect(component.getAttributesVisible().length).toEqual(2);
// });
//
// it('#getAttributeBySearchFlag() should return attribute for the given search_flag', () => {
// component.attributeList = ATTRIBUTE_LIST;
// expect(component.getAttributeBySearchFlag('ID').name).toEqual('name_one');
// });
//
// it('#getAttributeSpectraGraph() should return attribute for the spectra_graph renderer_detail', () => {
// component.attributeList = ATTRIBUTE_LIST;
// expect(component.getAttributeSpectraGraph().name).toEqual('name_two');
// });
//
// it('#getZ() should return Z value', () => {
// component.attributeList = ATTRIBUTE_LIST;
// component.object = OBJECT_DETAIL;
// expect(component.getZ()).toEqual(0);
// const attributeZ: Attribute = {
// id: 3,
// name: 'name_three',
// table_name: 'table_2',
// label: 'label_three',
// form_label: 'form_label_three',
// description: 'description_three',
// output_display: 1,
// criteria_display: 1,
// search_flag: 'Z',
// search_type: 'field',
// operator: '=',
// type: '',
// min: null,
// max: null,
// placeholder_min: '',
// placeholder_max: '',
// renderer: '',
// renderer_config: null,
// display_detail: 1,
// selected: true,
// order_by: true,
// order_display: 1,
// detail: true,
// renderer_detail: '',
// options: null,
// vo_utype: '',
// vo_ucd: '',
// vo_unit: '',
// vo_description: '',
// vo_datatype: '',
// vo_size: 1,
// id_criteria_family: 2,
// id_output_category: 2
// };
// component.attributeList = [...ATTRIBUTE_LIST, attributeZ];
// expect(component.getZ()).toEqual(4);
// });
// });
import
{
ComponentFixture
,
TestBed
}
from
'
@angular/core/testing
'
;
import
{
Component
,
Input
}
from
'
@angular/core
'
;
import
{
SpectraObjectComponent
}
from
'
./spectra-object.component
'
;
import
{
Attribute
,
Category
,
Family
}
from
'
../../../metamodel/model
'
;
import
{
ATTRIBUTE_LIST
,
OBJECT_DETAIL
}
from
'
../../../../settings/test-data
'
;
describe
(
'
[Detail][Spectra] Component: SpectraObjectComponent
'
,
()
=>
{
@
Component
({
selector
:
'
app-object-data
'
,
template
:
''
})
class
ObjectDataStubComponent
{
@
Input
()
datasetName
:
string
;
@
Input
()
outputFamilyList
:
Family
[];
@
Input
()
categoryList
:
Category
[];
@
Input
()
attributeList
:
Attribute
[];
@
Input
()
object
:
any
;
}
let
component
:
SpectraObjectComponent
;
let
fixture
:
ComponentFixture
<
SpectraObjectComponent
>
;
beforeEach
(()
=>
{
TestBed
.
configureTestingModule
({
declarations
:
[
SpectraObjectComponent
,
ObjectDataStubComponent
]
});
fixture
=
TestBed
.
createComponent
(
SpectraObjectComponent
);
component
=
fixture
.
componentInstance
;
});
it
(
'
should create the component
'
,
()
=>
{
expect
(
component
).
toBeTruthy
();
});
it
(
'
#ngOnInit() should emit getSpectraCSV event if an attribute have spectra_graph renderer_detail
'
,
()
=>
{
component
.
attributeList
=
ATTRIBUTE_LIST
;
component
.
object
=
OBJECT_DETAIL
;
component
.
getSpectraCSV
.
subscribe
((
event
:
string
)
=>
expect
(
event
).
toEqual
(
'
spec1d
'
));
component
.
ngOnInit
();
// To prevent `Spec has no expectation' bug
expect
(
true
).
toBeTruthy
();
});
it
(
'
#getSpectra() should return url to download spectra
'
,
()
=>
{
component
.
datasetName
=
'
dname
'
;
component
.
attributeList
=
ATTRIBUTE_LIST
;
component
.
object
=
OBJECT_DETAIL
;
expect
(
component
.
getSpectra
()).
toEqual
(
'
http://localhost:8080/download-file/dname/spec1d
'
);
});
it
(
'
#getAttributeSpectraGraph() should return attribute for the spectra_graph renderer_detail
'
,
()
=>
{
component
.
attributeList
=
ATTRIBUTE_LIST
;
expect
(
component
.
getAttributeSpectraGraph
().
name
).
toEqual
(
'
name_two
'
);
});
it
(
'
#getZ() should return Z value
'
,
()
=>
{
component
.
attributeList
=
ATTRIBUTE_LIST
;
component
.
object
=
OBJECT_DETAIL
;
expect
(
component
.
getZ
()).
toEqual
(
0
);
const
attributeZ
:
Attribute
=
{
id
:
3
,
name
:
'
name_three
'
,
table_name
:
'
table_2
'
,
label
:
'
label_three
'
,
form_label
:
'
form_label_three
'
,
description
:
'
description_three
'
,
output_display
:
1
,
criteria_display
:
1
,
search_flag
:
'
Z
'
,
search_type
:
'
field
'
,
operator
:
'
=
'
,
type
:
''
,
min
:
null
,
max
:
null
,
placeholder_min
:
''
,
placeholder_max
:
''
,
renderer
:
''
,
renderer_config
:
null
,
display_detail
:
1
,
selected
:
true
,
order_by
:
true
,
order_display
:
1
,
detail
:
true
,
renderer_detail
:
''
,
options
:
null
,
vo_utype
:
''
,
vo_ucd
:
''
,
vo_unit
:
''
,
vo_description
:
''
,
vo_datatype
:
''
,
vo_size
:
1
,
id_criteria_family
:
2
,
id_output_category
:
2
};
component
.
attributeList
=
[...
ATTRIBUTE_LIST
,
attributeZ
];
expect
(
component
.
getZ
()).
toEqual
(
4
);
});
});
src/app/detail/containers/detail.component.html
View file @
6510eeab
...
...
@@ -10,7 +10,7 @@
<span
class=
"fas fa-circle-notch fa-spin fa-3x"
></span>
<span
class=
"sr-only"
>
Loading...
</span>
</div>
<div
*ngIf=
"objectIsLoaded | async"
[ngSwitch]=
"
o
bjectType(attributeList | async)"
>
<div
*ngIf=
"objectIsLoaded | async"
[ngSwitch]=
"
getO
bjectType(attributeList | async)"
>
<app-spectra-object
*ngSwitchCase=
"'spectra'"
[datasetName]=
"datasetName | async"
[outputFamilyList]=
"outputFamilyList | async"
...
...
src/app/detail/containers/detail.component.spec.ts
View file @
6510eeab
...
...
@@ -9,6 +9,7 @@ import { DetailComponent } from './detail.component';
import
*
as
fromDetail
from
'
../store/detail.reducer
'
;
import
*
as
detailActions
from
'
../store/detail.action
'
;
import
{
Attribute
,
Family
,
Category
}
from
'
../../metamodel/model
'
;
import
{
ATTRIBUTE_LIST
}
from
'
../../../settings/test-data
'
;
describe
(
'
[Detail] Container: DetailComponent
'
,
()
=>
{
@
Component
({
selector
:
'
app-object-display
'
,
template
:
''
})
...
...
@@ -63,6 +64,12 @@ describe('[Detail] Container: DetailComponent', () => {
});
});
it
(
'
#getObjectType() should return object type
'
,
()
=>
{
expect
(
component
.
getObjectType
(
ATTRIBUTE_LIST
)).
toEqual
(
'
spectra
'
);
const
defaultAttributeList
=
ATTRIBUTE_LIST
.
filter
(
a
=>
a
.
search_flag
!==
'
SPECTRUM_1D
'
);
expect
(
component
.
getObjectType
(
defaultAttributeList
)).
toEqual
(
'
default
'
);
});
it
(
'
#goBackToResult() should go to the previous location
'
,
inject
([
LOCATION_TOKEN
],
(
location
:
Location
)
=>
{
spyOn
(
location
,
'
back
'
);
component
.
goBackToResult
();
...
...
src/app/detail/containers/detail.component.ts
View file @
6510eeab
...
...
@@ -55,7 +55,7 @@ export class DetailComponent implements OnInit, OnDestroy {
});
}
o
bjectType
(
attributeList
:
Attribute
[]):
string
{
getO
bjectType
(
attributeList
:
Attribute
[]):
string
{
const
spectrumAttribute
:
Attribute
=
attributeList
.
filter
(
a
=>
a
.
detail
)
.
find
(
attribute
=>
attribute
.
search_flag
===
'
SPECTRUM_1D
'
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment