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 Monday, March 24th
Show more breadcrumbs
vtechworks
Dspace7 Angular
Commits
a1bed634
Commit
a1bed634
authored
6 years ago
by
Kristof De Langhe
Browse files
Options
Downloads
Patches
Plain Diff
59695: Added BrowseBy tests
parent
0bdd4789
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/app/shared/browse-by/browse-by.component.html
+4
-4
4 additions, 4 deletions
src/app/shared/browse-by/browse-by.component.html
src/app/shared/browse-by/browse-by.component.spec.ts
+113
-9
113 additions, 9 deletions
src/app/shared/browse-by/browse-by.component.spec.ts
with
117 additions
and
13 deletions
src/app/shared/browse-by/browse-by.component.html
+
4
−
4
View file @
a1bed634
...
...
@@ -16,9 +16,9 @@
<button
class=
"btn btn-outline-primary"
id=
"paginationControls"
ngbDropdownToggle
><i
class=
"fas fa-cog"
aria-hidden=
"true"
></i></button>
<div
id=
"paginationControlsDropdownMenu"
aria-labelledby=
"paginationControls"
ngbDropdownMenu
>
<h6
class=
"dropdown-header"
>
{{ 'pagination.results-per-page' | translate}}
</h6>
<button
class=
"dropdown-item"
*ngFor=
"let item of paginationConfig?.pageSizeOptions"
(click)=
"doPageSizeChange(item)"
><i
[ngClass]=
"{'invisible': item != paginationConfig?.pageSize}"
class=
"fas fa-check"
aria-hidden=
"true"
></i>
{{item}}
</button>
<button
class=
"dropdown-item
page-size-change
"
*ngFor=
"let item of paginationConfig?.pageSizeOptions"
(click)=
"doPageSizeChange(item)"
><i
[ngClass]=
"{'invisible': item != paginationConfig?.pageSize}"
class=
"fas fa-check"
aria-hidden=
"true"
></i>
{{item}}
</button>
<h6
class=
"dropdown-header"
>
{{ 'pagination.sort-direction' | translate}}
</h6>
<button
class=
"dropdown-item"
*ngFor=
"let direction of (sortDirections | dsKeys)"
(click)=
"doSortDirectionChange(direction.value)"
><i
[ngClass]=
"{'invisible': direction.value !== sortConfig?.direction}"
class=
"fas fa-check"
aria-hidden=
"true"
></i>
{{'sorting.' + direction.key | translate}}
</button>
<button
class=
"dropdown-item
sort-direction-change
"
*ngFor=
"let direction of (sortDirections | dsKeys)"
(click)=
"doSortDirectionChange(direction.value)"
><i
[ngClass]=
"{'invisible': direction.value !== sortConfig?.direction}"
class=
"fas fa-check"
aria-hidden=
"true"
></i>
{{'sorting.' + direction.key | translate}}
</button>
</div>
</div>
</div>
...
...
@@ -29,8 +29,8 @@
</li>
</ul>
<div>
<button
type=
"button"
class=
"btn btn-outline-secondary float-left"
(click)=
"goPrev()"
[disabled]=
"objects?.payload?.currentPage <= 1"
><
<</
button
>
<button
type=
"button"
class=
"btn btn-outline-secondary float-right"
(click)=
"goNext()"
[disabled]=
"objects?.payload?.currentPage >= objects?.payload?.totalPages"
>
>>
</button>
<button
id=
"nav-prev"
type=
"button"
class=
"btn btn-outline-secondary float-left"
(click)=
"goPrev()"
[disabled]=
"objects?.payload?.currentPage <= 1"
><
<</
button
>
<button
id=
"nav-next"
type=
"button"
class=
"btn btn-outline-secondary float-right"
(click)=
"goNext()"
[disabled]=
"objects?.payload?.currentPage >= objects?.payload?.totalPages"
>
>>
</button>
</div>
</div>
</div>
...
...
This diff is collapsed.
Click to expand it.
src/app/shared/browse-by/browse-by.component.spec.ts
+
113
−
9
View file @
a1bed634
import
{
BrowseByComponent
}
from
'
./browse-by.component
'
;
import
{
async
,
ComponentFixture
,
TestBed
}
from
'
@angular/core/testing
'
;
import
{
TranslateModule
}
from
'
@ngx-translate/core
'
;
import
{
TranslateLoader
,
TranslateModule
}
from
'
@ngx-translate/core
'
;
import
{
By
}
from
'
@angular/platform-browser
'
;
import
{
NO_ERRORS_SCHEMA
}
from
'
@angular/core
'
;
import
{
of
as
observableOf
}
from
'
rxjs
'
;
import
{
SharedModule
}
from
'
../shared.module
'
;
import
{
CommonModule
}
from
'
@angular/common
'
;
import
{
ActivatedRoute
,
Router
}
from
'
@angular/router
'
;
import
{
ActivatedRouteStub
}
from
'
../testing/active-router-stub
'
;
import
{
MockRouter
}
from
'
../mocks/mock-router
'
;
import
{
Item
}
from
'
../../core/shared/item.model
'
;
import
{
RemoteData
}
from
'
../../core/data/remote-data
'
;
import
{
PaginatedList
}
from
'
../../core/data/paginated-list
'
;
import
{
PageInfo
}
from
'
../../core/shared/page-info.model
'
;
import
{
NgbModule
}
from
'
@ng-bootstrap/ng-bootstrap
'
;
import
{
StoreModule
}
from
'
@ngrx/store
'
;
import
{
MockTranslateLoader
}
from
'
../mocks/mock-translate-loader
'
;
import
{
RouterTestingModule
}
from
'
@angular/router/testing
'
;
import
{
BrowserAnimationsModule
}
from
'
@angular/platform-browser/animations
'
;
import
{
PaginationComponentOptions
}
from
'
../pagination/pagination-component-options.model
'
;
import
{
SortDirection
,
SortOptions
}
from
'
../../core/cache/models/sort-options.model
'
;
describe
(
'
BrowseByComponent
'
,
()
=>
{
let
comp
:
BrowseByComponent
;
let
fixture
:
ComponentFixture
<
BrowseByComponent
>
;
const
mockItems
=
[
Object
.
assign
(
new
Item
(),
{
id
:
'
fakeId-1
'
,
metadata
:
[
{
key
:
'
dc.title
'
,
value
:
'
First Fake Title
'
}
]
}),
Object
.
assign
(
new
Item
(),
{
id
:
'
fakeId-2
'
,
metadata
:
[
{
key
:
'
dc.title
'
,
value
:
'
Second Fake Title
'
}
]
})
];
const
mockItemsRD$
=
observableOf
(
new
RemoteData
(
false
,
false
,
true
,
null
,
new
PaginatedList
(
new
PageInfo
(),
mockItems
)));
beforeEach
(
async
(()
=>
{
TestBed
.
configureTestingModule
({
imports
:
[
CommonModule
,
TranslateModule
.
forRoot
(),
SharedModule
],
declarations
:
[],
providers
:
[
{
provide
:
ActivatedRoute
,
useValue
:
new
ActivatedRouteStub
()
},
{
provide
:
Router
,
useValue
:
new
MockRouter
()
}
imports
:
[
CommonModule
,
TranslateModule
.
forRoot
(),
SharedModule
,
NgbModule
.
forRoot
(),
StoreModule
.
forRoot
({}),
TranslateModule
.
forRoot
({
loader
:
{
provide
:
TranslateLoader
,
useClass
:
MockTranslateLoader
}
}),
RouterTestingModule
,
BrowserAnimationsModule
],
declarations
:
[],
providers
:
[],
schemas
:
[
NO_ERRORS_SCHEMA
]
}).
compileComponents
();
}));
...
...
@@ -49,4 +90,67 @@ describe('BrowseByComponent', () => {
expect
(
fixture
.
debugElement
.
query
(
By
.
css
(
'
ds-viewable-collection
'
))).
toBeDefined
();
});
describe
(
'
when enableArrows is true and objects are defined
'
,
()
=>
{
beforeEach
(()
=>
{
comp
.
enableArrows
=
true
;
comp
.
objects$
=
mockItemsRD$
;
comp
.
paginationConfig
=
Object
.
assign
(
new
PaginationComponentOptions
(),
{
id
:
'
test-pagination
'
,
currentPage
:
1
,
pageSizeOptions
:
[
5
,
10
,
15
,
20
],
pageSize
:
15
});
comp
.
sortConfig
=
Object
.
assign
(
new
SortOptions
(
'
dc.title
'
,
SortDirection
.
ASC
));
fixture
.
detectChanges
();
});
describe
(
'
when clicking the previous arrow button
'
,
()
=>
{
beforeEach
(()
=>
{
spyOn
(
comp
.
prev
,
'
emit
'
);
fixture
.
debugElement
.
query
(
By
.
css
(
'
#nav-prev
'
)).
triggerEventHandler
(
'
click
'
,
null
);
fixture
.
detectChanges
();
});
it
(
'
should emit a signal to the EventEmitter
'
,()
=>
{
expect
(
comp
.
prev
.
emit
).
toHaveBeenCalled
();
});
});
describe
(
'
when clicking the next arrow button
'
,
()
=>
{
beforeEach
(()
=>
{
spyOn
(
comp
.
next
,
'
emit
'
);
fixture
.
debugElement
.
query
(
By
.
css
(
'
#nav-next
'
)).
triggerEventHandler
(
'
click
'
,
null
);
fixture
.
detectChanges
();
});
it
(
'
should emit a signal to the EventEmitter
'
,()
=>
{
expect
(
comp
.
next
.
emit
).
toHaveBeenCalled
();
});
});
describe
(
'
when clicking a different page size
'
,
()
=>
{
beforeEach
(()
=>
{
spyOn
(
comp
.
pageSizeChange
,
'
emit
'
);
fixture
.
debugElement
.
query
(
By
.
css
(
'
.page-size-change
'
)).
triggerEventHandler
(
'
click
'
,
null
);
fixture
.
detectChanges
();
});
it
(
'
should emit a signal to the EventEmitter
'
,()
=>
{
expect
(
comp
.
pageSizeChange
.
emit
).
toHaveBeenCalled
();
});
});
describe
(
'
when clicking a different sort direction
'
,
()
=>
{
beforeEach
(()
=>
{
spyOn
(
comp
.
sortDirectionChange
,
'
emit
'
);
fixture
.
debugElement
.
query
(
By
.
css
(
'
.sort-direction-change
'
)).
triggerEventHandler
(
'
click
'
,
null
);
fixture
.
detectChanges
();
});
it
(
'
should emit a signal to the EventEmitter
'
,()
=>
{
expect
(
comp
.
sortDirectionChange
.
emit
).
toHaveBeenCalled
();
});
});
});
});
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