Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
Dspace7 Angular
Manage
Activity
Members
Labels
Plan
Issues
42
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Admin message
code.vt.edu will be down for maintenance from 0530-0630 EDT Wednesday, March 26th
Show more breadcrumbs
vtechworks
Dspace7 Angular
Commits
56d69652
Commit
56d69652
authored
5 years ago
by
Antoine Snyers
Browse files
Options
Downloads
Patches
Plain Diff
Update the search-settings component specs
parent
78a29a87
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/app/+search-page/search-settings/search-settings.component.spec.ts
+75
-63
75 additions, 63 deletions
...ch-page/search-settings/search-settings.component.spec.ts
with
75 additions
and
63 deletions
src/app/+search-page/search-settings/search-settings.component.spec.ts
+
75
−
63
View file @
56d69652
...
...
@@ -12,79 +12,87 @@ import { NO_ERRORS_SCHEMA } from '@angular/core';
import
{
EnumKeysPipe
}
from
'
../../shared/utils/enum-keys-pipe
'
;
import
{
By
}
from
'
@angular/platform-browser
'
;
import
{
SearchFilterService
}
from
'
../search-filters/search-filter/search-filter.service
'
;
import
{
hot
}
from
'
jasmine-marbles
'
;
import
{
VarDirective
}
from
'
../../shared/utils/var.directive
'
;
import
{
first
}
from
'
rxjs/operators
'
;
import
{
take
}
from
'
rxjs/operators
'
;
import
{
SEARCH_CONFIG_SERVICE
}
from
'
../../+my-dspace-page/my-dspace-page.component
'
;
describe
(
'
SearchSettingsComponent
'
,
()
=>
{
let
comp
:
SearchSettingsComponent
;
let
fixture
:
ComponentFixture
<
SearchSettingsComponent
>
;
let
searchServiceObject
:
SearchService
;
const
pagination
:
PaginationComponentOptions
=
new
PaginationComponentOptions
();
pagination
.
id
=
'
search-results-pagination
'
;
pagination
.
currentPage
=
1
;
pagination
.
pageSize
=
10
;
const
sort
:
SortOptions
=
new
SortOptions
(
'
score
'
,
SortDirection
.
DESC
);
const
mockResults
=
[
'
test
'
,
'
data
'
];
const
searchServiceStub
=
{
searchOptions
:
{
pagination
:
pagination
,
sort
:
sort
},
search
:
()
=>
mockResults
};
const
queryParam
=
'
test query
'
;
const
scopeParam
=
'
7669c72a-3f2a-451f-a3b9-9210e7a4c02f
'
;
const
paginatedSearchOptions
=
{
query
:
queryParam
,
scope
:
scopeParam
,
pagination
,
sort
};
const
activatedRouteStub
=
{
queryParams
:
observableOf
({
query
:
queryParam
,
scope
:
scopeParam
})
};
let
comp
:
SearchSettingsComponent
;
let
fixture
:
ComponentFixture
<
SearchSettingsComponent
>
;
let
searchServiceObject
:
SearchService
;
let
pagination
:
PaginationComponentOptions
;
let
sort
:
SortOptions
;
let
mockResults
;
let
searchServiceStub
;
let
queryParam
;
let
scopeParam
;
let
paginatedSearchOptions
;
const
sidebarService
=
{
isCollapsed
:
observableOf
(
true
),
collapse
:
()
=>
this
.
isCollapsed
=
observableOf
(
true
),
expand
:
()
=>
this
.
isCollapsed
=
observableOf
(
false
)
};
let
activatedRouteStub
;
let
sidebarService
;
beforeEach
(
async
(()
=>
{
pagination
=
new
PaginationComponentOptions
();
pagination
.
id
=
'
search-results-pagination
'
;
pagination
.
currentPage
=
1
;
pagination
.
pageSize
=
10
;
sort
=
new
SortOptions
(
'
score
'
,
SortDirection
.
DESC
);
mockResults
=
[
'
test
'
,
'
data
'
];
searchServiceStub
=
{
searchOptions
:
{
pagination
:
pagination
,
sort
:
sort
},
search
:
()
=>
mockResults
,
};
queryParam
=
'
test query
'
;
scopeParam
=
'
7669c72a-3f2a-451f-a3b9-9210e7a4c02f
'
;
paginatedSearchOptions
=
{
query
:
queryParam
,
scope
:
scopeParam
,
pagination
,
sort
,
};
activatedRouteStub
=
{
queryParams
:
observableOf
({
query
:
queryParam
,
scope
:
scopeParam
,
}),
};
sidebarService
=
{
isCollapsed
:
observableOf
(
true
),
collapse
:
()
=>
this
.
isCollapsed
=
observableOf
(
true
),
expand
:
()
=>
this
.
isCollapsed
=
observableOf
(
false
),
};
TestBed
.
configureTestingModule
({
imports
:
[
TranslateModule
.
forRoot
(),
RouterTestingModule
.
withRoutes
([])],
declarations
:
[
SearchSettingsComponent
,
EnumKeysPipe
,
VarDirective
],
providers
:
[
{
provide
:
SearchService
,
useValue
:
searchServiceStub
},
{
provide
:
SearchService
,
useValue
:
searchServiceStub
},
{
provide
:
ActivatedRoute
,
useValue
:
activatedRouteStub
},
{
provide
:
ActivatedRoute
,
useValue
:
activatedRouteStub
},
{
provide
:
SidebarService
,
useValue
:
sidebarService
useValue
:
sidebarService
,
},
{
provide
:
SearchFilterService
,
useValue
:
{}
useValue
:
{}
,
},
{
provide
:
SEARCH_CONFIG_SERVICE
,
useValue
:
{
paginatedSearchOptions
:
hot
(
'
a
'
,
{
a
:
paginatedSearchOptions
}),
getCurrentScope
:
hot
(
'
a
'
,
{
a
:
'
test-id
'
}),
}
paginatedSearchOptions
:
observableOf
(
paginatedSearchOptions
),
getCurrentScope
:
observableOf
(
'
test-id
'
),
},
},
],
schemas
:
[
NO_ERRORS_SCHEMA
]
schemas
:
[
NO_ERRORS_SCHEMA
]
,
}).
compileComponents
();
}));
...
...
@@ -101,42 +109,46 @@ describe('SearchSettingsComponent', () => {
});
it
(
'
it should show the order settings with the respective selectable options
'
,
()
=>
{
(
comp
as
any
).
searchOptions$
.
pipe
(
first
(
)).
subscribe
((
options
)
=>
{
it
(
'
it should show the order settings with the respective selectable options
'
,
(
done
)
=>
{
(
comp
as
any
).
searchOptions$
.
pipe
(
take
(
1
)).
subscribe
((
options
)
=>
{
fixture
.
detectChanges
();
const
orderSetting
=
fixture
.
debugElement
.
query
(
By
.
css
(
'
div.result-order-settings
'
));
expect
(
orderSetting
).
toBeDefined
();
const
childElements
=
orderSetting
.
query
(
By
.
css
(
'
.form-control
'
)).
children
;
const
childElements
=
orderSetting
.
query
All
(
By
.
css
(
'
option
'
))
;
expect
(
childElements
.
length
).
toEqual
(
comp
.
searchOptionPossibilities
.
length
);
done
();
});
});
it
(
'
it should show the size settings with the respective selectable options
'
,
()
=>
{
(
comp
as
any
).
searchOptions$
.
pipe
(
first
(
)).
subscribe
((
options
)
=>
{
it
(
'
it should show the size settings with the respective selectable options
'
,
(
done
)
=>
{
(
comp
as
any
).
searchOptions$
.
pipe
(
take
(
1
)).
subscribe
((
options
)
=>
{
fixture
.
detectChanges
();
const
pageSizeSetting
=
fixture
.
debugElement
.
query
(
By
.
css
(
'
div.page-size-settings
'
));
expect
(
pageSizeSetting
).
toBeDefined
();
const
childElements
=
pageSizeSetting
.
query
(
By
.
css
(
'
.form-control
'
)).
children
;
const
childElements
=
pageSizeSetting
.
query
All
(
By
.
css
(
'
option
'
))
;
expect
(
childElements
.
length
).
toEqual
(
options
.
pagination
.
pageSizeOptions
.
length
);
}
)
done
();
},
);
});
it
(
'
should have the proper order value selected by default
'
,
()
=>
{
(
comp
as
any
).
searchOptions$
.
pipe
(
first
(
)).
subscribe
((
options
)
=>
{
it
(
'
should have the proper order value selected by default
'
,
(
done
)
=>
{
(
comp
as
any
).
searchOptions$
.
pipe
(
take
(
1
)).
subscribe
((
options
)
=>
{
fixture
.
detectChanges
();
const
orderSetting
=
fixture
.
debugElement
.
query
(
By
.
css
(
'
div.result-order-settings
'
));
const
childElementToBeSelected
=
orderSetting
.
query
(
By
.
css
(
'
.form-control
option[value="0"][selected="selected"]
'
));
const
childElementToBeSelected
=
orderSetting
.
query
(
By
.
css
(
'
option[value="0"][selected="selected"]
'
));
expect
(
childElementToBeSelected
).
toBeDefined
();
done
();
});
});
it
(
'
should have the proper rpp value selected by default
'
,
()
=>
{
(
comp
as
any
).
searchOptions$
.
pipe
(
first
(
)).
subscribe
((
options
)
=>
{
it
(
'
should have the proper rpp value selected by default
'
,
(
done
)
=>
{
(
comp
as
any
).
searchOptions$
.
pipe
(
take
(
1
)).
subscribe
((
options
)
=>
{
fixture
.
detectChanges
();
const
pageSizeSetting
=
fixture
.
debugElement
.
query
(
By
.
css
(
'
div.page-size-settings
'
));
const
childElementToBeSelected
=
pageSizeSetting
.
query
(
By
.
css
(
'
.form-control
option[value="10"][selected="selected"]
'
));
const
childElementToBeSelected
=
pageSizeSetting
.
query
(
By
.
css
(
'
option[value="10"][selected="selected"]
'
));
expect
(
childElementToBeSelected
).
toBeDefined
();
done
();
});
});
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment