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
480d4198
Commit
480d4198
authored
Oct 21, 2020
by
Tifenn Guillas
Browse files
Fix tests
parent
44d5ee6e
Changes
5
Hide whitespace changes
Inline
Side-by-side
src/app/core/components/nav.component.spec.ts
View file @
480d4198
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
}
};
...
...
src/app/core/components/nav.component.ts
View file @
480d4198
...
...
@@ -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
;
}
...
...
src/app/metamodel/action/instance.action.spec.ts
View file @
480d4198
import
*
as
instanceActions
from
'
./instance.action
'
;
import
{
I
nstance
}
from
'
../
model
'
;
import
{
I
NSTANCE
}
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
'
,
()
=>
{
...
...
src/app/metamodel/reducers/instance.reducer.spec.ts
View file @
480d4198
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
);
...
...
src/settings/test-data/instance.ts
0 → 100644
View file @
480d4198
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
}
};
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