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
532b1413
Commit
532b1413
authored
7 years ago
by
Lotte Hofstede
Browse files
Options
Downloads
Patches
Plain Diff
130: added tests for object-list component
parent
2ea8a561
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/object-list/object-list.component.spec.ts
+151
-0
151 additions, 0 deletions
src/app/object-list/object-list.component.spec.ts
with
151 additions
and
0 deletions
src/app/object-list/object-list.component.spec.ts
0 → 100644
+
151
−
0
View file @
532b1413
import
{
async
,
ComponentFixture
,
fakeAsync
,
TestBed
,
tick
}
from
'
@angular/core/testing
'
;
import
{
ObjectListComponent
}
from
'
./object-list.component
'
;
import
{
ChangeDetectionStrategy
,
NO_ERRORS_SCHEMA
}
from
'
@angular/core
'
;
import
{
By
}
from
'
@angular/platform-browser
'
;
fdescribe
(
'
ObjectListComponent
'
,
()
=>
{
let
comp
:
ObjectListComponent
;
let
fixture
:
ComponentFixture
<
ObjectListComponent
>
;
const
testEvent
=
{
test
:
'
test
'
}
beforeEach
(
async
(()
=>
{
TestBed
.
configureTestingModule
({
imports
:
[],
declarations
:
[
ObjectListComponent
],
schemas
:
[
NO_ERRORS_SCHEMA
]
}).
overrideComponent
(
ObjectListComponent
,
{
set
:
{
changeDetection
:
ChangeDetectionStrategy
.
Default
}
}).
compileComponents
();
}));
beforeEach
(()
=>
{
fixture
=
TestBed
.
createComponent
(
ObjectListComponent
);
comp
=
fixture
.
componentInstance
;
// SearchPageComponent test instance
fixture
.
detectChanges
();
});
describe
(
'
when the pageChange output on the pagination is triggered
'
,
()
=>
{
beforeEach
(()
=>
{
spyOn
(
comp
,
'
onPageChange
'
);
const
paginationEl
=
fixture
.
debugElement
.
query
(
By
.
css
(
'
ds-pagination
'
));
paginationEl
.
triggerEventHandler
(
'
pageChange
'
,
testEvent
);
});
it
(
'
should call onPageChange on the component
'
,
()
=>
{
expect
(
comp
.
onPageChange
).
toHaveBeenCalledWith
(
testEvent
);
});
});
describe
(
'
when the pageSizeChange output on the pagination is triggered
'
,
()
=>
{
beforeEach
(()
=>
{
spyOn
(
comp
,
'
onPageSizeChange
'
);
const
paginationEl
=
fixture
.
debugElement
.
query
(
By
.
css
(
'
ds-pagination
'
));
paginationEl
.
triggerEventHandler
(
'
pageSizeChange
'
,
testEvent
);
});
it
(
'
should call onPageSizeChange on the component
'
,
()
=>
{
expect
(
comp
.
onPageSizeChange
).
toHaveBeenCalledWith
(
testEvent
);
});
});
describe
(
'
when the sortDirectionChange output on the pagination is triggered
'
,
()
=>
{
beforeEach
(()
=>
{
spyOn
(
comp
,
'
onSortDirectionChange
'
);
const
paginationEl
=
fixture
.
debugElement
.
query
(
By
.
css
(
'
ds-pagination
'
));
paginationEl
.
triggerEventHandler
(
'
sortDirectionChange
'
,
testEvent
);
});
it
(
'
should call onSortDirectionChange on the component
'
,
()
=>
{
expect
(
comp
.
onSortDirectionChange
).
toHaveBeenCalledWith
(
testEvent
);
});
});
describe
(
'
when the sortFieldChange output on the pagination is triggered
'
,
()
=>
{
beforeEach
(()
=>
{
spyOn
(
comp
,
'
onSortFieldChange
'
);
const
paginationEl
=
fixture
.
debugElement
.
query
(
By
.
css
(
'
ds-pagination
'
));
paginationEl
.
triggerEventHandler
(
'
sortFieldChange
'
,
testEvent
);
});
it
(
'
should call onSortFieldChange on the component
'
,
()
=>
{
expect
(
comp
.
onSortFieldChange
).
toHaveBeenCalledWith
(
testEvent
);
});
});
describe
(
'
when the paginationChange output on the pagination is triggered
'
,
()
=>
{
beforeEach
(()
=>
{
spyOn
(
comp
,
'
onPaginationChange
'
);
const
paginationEl
=
fixture
.
debugElement
.
query
(
By
.
css
(
'
ds-pagination
'
));
paginationEl
.
triggerEventHandler
(
'
paginationChange
'
,
testEvent
);
});
it
(
'
should call onPaginationChange on the component
'
,
()
=>
{
expect
(
comp
.
onPaginationChange
).
toHaveBeenCalledWith
(
testEvent
);
});
});
describe
(
'
when onPageChange is triggered with an event
'
,
()
=>
{
beforeEach
(()
=>
{
spyOn
(
comp
.
pageChange
,
'
emit
'
);
comp
.
onPageChange
(
testEvent
);
});
it
(
'
should emit the value from the pageChange EventEmitter
'
,
fakeAsync
(()
=>
{
tick
(
1
);
expect
(
comp
.
pageChange
.
emit
).
toHaveBeenCalled
();
expect
(
comp
.
pageChange
.
emit
).
toHaveBeenCalledWith
(
testEvent
);
}));
});
describe
(
'
when onPageSizeChange is triggered with an event
'
,
()
=>
{
beforeEach
(()
=>
{
spyOn
(
comp
.
pageSizeChange
,
'
emit
'
);
comp
.
onPageSizeChange
(
testEvent
);
});
it
(
'
should emit the value from the pageSizeChange EventEmitter
'
,
fakeAsync
(()
=>
{
tick
(
1
);
expect
(
comp
.
pageSizeChange
.
emit
).
toHaveBeenCalled
();
expect
(
comp
.
pageSizeChange
.
emit
).
toHaveBeenCalledWith
(
testEvent
);
}));
});
describe
(
'
when onSortDirectionChange is triggered with an event
'
,
()
=>
{
beforeEach
(()
=>
{
spyOn
(
comp
.
sortDirectionChange
,
'
emit
'
);
comp
.
onSortDirectionChange
(
testEvent
);
});
it
(
'
should emit the value from the sortDirectionChange EventEmitter
'
,
fakeAsync
(()
=>
{
tick
(
1
);
expect
(
comp
.
sortDirectionChange
.
emit
).
toHaveBeenCalled
();
expect
(
comp
.
sortDirectionChange
.
emit
).
toHaveBeenCalledWith
(
testEvent
);
}));
});
describe
(
'
when onSortFieldChange is triggered with an event
'
,
()
=>
{
beforeEach
(()
=>
{
spyOn
(
comp
.
sortFieldChange
,
'
emit
'
);
comp
.
onSortFieldChange
(
testEvent
);
});
it
(
'
should emit the value from the sortFieldChange EventEmitter
'
,
fakeAsync
(()
=>
{
tick
(
1
);
expect
(
comp
.
sortFieldChange
.
emit
).
toHaveBeenCalled
();
expect
(
comp
.
sortFieldChange
.
emit
).
toHaveBeenCalledWith
(
testEvent
);
}));
});
describe
(
'
when onPaginationChange is triggered with an event
'
,
()
=>
{
beforeEach
(()
=>
{
spyOn
(
comp
.
paginationChange
,
'
emit
'
);
comp
.
onPaginationChange
(
testEvent
);
});
it
(
'
should emit the value from the paginationChange EventEmitter
'
,
fakeAsync
(()
=>
{
tick
(
1
);
expect
(
comp
.
paginationChange
.
emit
).
toHaveBeenCalled
();
expect
(
comp
.
paginationChange
.
emit
).
toHaveBeenCalledWith
(
testEvent
);
}));
});
});
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