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
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
vtechworks
Dspace7 Angular
Commits
49f37e8a
Commit
49f37e8a
authored
6 years ago
by
Giuseppe
Browse files
Options
Downloads
Patches
Plain Diff
Added more tests
parent
2786dbd8
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/app/submission/sections/container/section-container.component.spec.ts
+146
-0
146 additions, 0 deletions
...on/sections/container/section-container.component.spec.ts
with
146 additions
and
0 deletions
src/app/submission/sections/container/section-container.component.spec.ts
0 → 100644
+
146
−
0
View file @
49f37e8a
// Load the implementations that should be tested
import
{
ChangeDetectorRef
,
Component
,
CUSTOM_ELEMENTS_SCHEMA
}
from
'
@angular/core
'
;
import
{
async
,
ComponentFixture
,
fakeAsync
,
inject
,
TestBed
,
tick
,
}
from
'
@angular/core/testing
'
;
import
{
BrowserModule
,
By
}
from
'
@angular/platform-browser
'
;
import
{
Observable
}
from
'
rxjs/Observable
'
;
import
'
rxjs/add/observable/of
'
;
import
{
SectionContainerComponent
}
from
'
./section-container.component
'
;
import
{
NgbModule
}
from
'
@ng-bootstrap/ng-bootstrap
'
;
import
{
createTestComponent
}
from
'
../../../shared/testing/utils
'
;
import
{
SectionsType
}
from
'
../sections-type
'
;
import
{
CommonModule
}
from
'
@angular/common
'
;
import
{
TranslateModule
}
from
'
@ngx-translate/core
'
;
import
{
SectionsDirective
}
from
'
../sections.directive
'
;
import
{
ActionsSubject
,
Store
}
from
'
@ngrx/store
'
;
import
{
SubmissionState
}
from
'
../../submission.reducers
'
;
import
{
SubmissionService
}
from
'
../../submission.service
'
;
import
{
GLOBAL_CONFIG
}
from
'
../../../../config
'
;
import
{
SubmissionRestService
}
from
'
../../submission-rest.service
'
;
import
{
SubmissionRestServiceStub
}
from
'
../../../shared/testing/submission-rest-service-stub
'
;
import
{
ActivatedRoute
,
Router
}
from
'
@angular/router
'
;
import
{
MockRouter
}
from
'
../../../shared/mocks/mock-router
'
;
import
{
RouteService
}
from
'
../../../shared/services/route.service
'
;
import
{
MockActivatedRoute
}
from
'
../../../shared/mocks/mock-active-router
'
;
import
{
SectionsService
}
from
'
../sections.service
'
;
import
{
NotificationsService
}
from
'
../../../shared/notifications/notifications.service
'
;
import
{
ScrollToService
}
from
'
@nicky-lenaers/ngx-scroll-to
'
;
describe
(
'
SectionContainerComponent test suite
'
,
()
=>
{
let
testComp
:
TestComponent
;
let
sectionContainerComponent
:
SectionContainerComponent
;
let
testFixture
:
ComponentFixture
<
TestComponent
>
;
let
sectionContainerComponentComponentFixture
:
ComponentFixture
<
SectionContainerComponent
>
;
let
html
;
const
config
=
{
autosave
:
{
metadata
:
[
'
dc.title
'
,
'
dc.identifier.doi
'
,
'
dc.identifier.pmid
'
,
'
dc.identifier.arxiv
'
],
timer
:
5
},
metadata
:
{
icons
:
[
{
name
:
'
dc.contributor.author
'
,
config
:
{
withAuthority
:{
style
:
'
fa-user
'
}
}
},
{
name
:
'
local.contributor.affiliation
'
,
config
:
{
withAuthority
:{
style
:
'
fa-university
'
},
withoutAuthority
:{
style
:
'
fa-university text-muted
'
}
}
},
{
name
:
'
default
'
,
config
:
{}
}
]
}
}
as
any
;
const
restService
=
new
SubmissionRestServiceStub
();
const
router
=
new
MockRouter
();
const
store
=
new
Store
<
SubmissionState
>
(
Observable
.
of
({}),
new
ActionsSubject
(),
undefined
);
// async beforeEach
beforeEach
(
async
(()
=>
{
TestBed
.
configureTestingModule
({
imports
:
[
BrowserModule
,
CommonModule
,
NgbModule
.
forRoot
(),
TranslateModule
.
forRoot
()
],
declarations
:
[
SectionContainerComponent
,
SectionsDirective
,
TestComponent
,
],
// declare the test component
providers
:
[
ChangeDetectorRef
,
NotificationsService
,
RouteService
,
ScrollToService
,
SectionContainerComponent
,
SectionsService
,
SubmissionService
,
{
provide
:
ActivatedRoute
,
useValue
:
new
MockActivatedRoute
()
},
{
provide
:
Router
,
useValue
:
router
},
{
provide
:
SubmissionRestService
,
useValue
:
restService
},
{
provide
:
GLOBAL_CONFIG
,
useValue
:
config
},
{
provide
:
Store
,
useValue
:
store
}
],
schemas
:
[
CUSTOM_ELEMENTS_SCHEMA
]
});
}));
describe
(
''
,
()
=>
{
// synchronous beforeEach
beforeEach
(()
=>
{
html
=
`
<ds-submission-form-section-container [collectionId]="collectionId"
[submissionId]="submissionId"
[sectionData]="object"></ds-submission-form-section-container>`
;
testFixture
=
createTestComponent
(
html
,
TestComponent
)
as
ComponentFixture
<
TestComponent
>
;
testComp
=
testFixture
.
componentInstance
;
});
it
(
'
should create Chips Component
'
,
inject
([
SectionContainerComponent
],
(
app
:
SectionContainerComponent
)
=>
{
expect
(
app
).
toBeDefined
();
}));
});
});
// declare a test component
@
Component
({
selector
:
'
ds-test-cmp
'
,
template
:
``
})
class
TestComponent
{
public
collectionId
=
'
1c11f3f1-ba1f-4f36-908a-3f1ea9a557eb
'
;
public
submissionId
=
1
;
public
object
=
{
config
:
'
https://dspace7.4science.it/or2018/api/config/submissionforms/traditionalpageone
'
,
mandatory
:
true
,
data
:
{},
errors
:
[],
header
:
'
submit.progressbar.describe.stepone
'
,
id
:
'
traditionalpageone
'
,
sectionType
:
SectionsType
.
SubmissionForm
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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