Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
frontend-clients
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
OZG-Cloud
app
frontend-clients
Commits
036655c0
Commit
036655c0
authored
2 years ago
by
OZGCloud
Browse files
Options
Downloads
Patches
Plain Diff
OZG-3560 adjust unittest; tiny code cleanup
parent
27edd490
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
goofy-client/libs/vorgang-shared/src/lib/vorgang.service.spec.ts
+52
-12
52 additions, 12 deletions
...lient/libs/vorgang-shared/src/lib/vorgang.service.spec.ts
goofy-client/libs/vorgang-shared/src/lib/vorgang.service.ts
+10
-8
10 additions, 8 deletions
goofy-client/libs/vorgang-shared/src/lib/vorgang.service.ts
with
62 additions
and
20 deletions
goofy-client/libs/vorgang-shared/src/lib/vorgang.service.spec.ts
+
52
−
12
View file @
036655c0
...
...
@@ -22,13 +22,14 @@
* unter der Lizenz sind dem Lizenztext zu entnehmen.
*/
import
{
faker
}
from
'
@faker-js/faker
'
;
import
{
ApiRootService
}
from
'
@goofy-client/api-root-shared
'
;
import
{
ApiRootResource
,
ApiRootService
}
from
'
@goofy-client/api-root-shared
'
;
import
{
CommandListResource
,
CommandResource
,
CommandService
}
from
'
@goofy-client/command-shared
'
;
import
{
NavigationService
}
from
'
@goofy-client/navigation-shared
'
;
import
{
createEmptyStateResource
,
createStateResource
,
StateResource
}
from
'
@goofy-client/tech-shared
'
;
import
{
StateResource
,
createEmptyStateResource
,
createStateResource
}
from
'
@goofy-client/tech-shared
'
;
import
{
Mock
,
mock
,
useFromMock
}
from
'
@goofy-client/test-utils
'
;
import
{
getUrl
,
ResourceUri
}
from
'
@ngxp/rest
'
;
import
{
cold
}
from
'
jest-marbles
'
;
import
{
ResourceUri
,
getUrl
}
from
'
@ngxp/rest
'
;
import
{
cold
,
hot
}
from
'
jest-marbles
'
;
import
{
createApiRootResource
}
from
'
libs/api-root-shared/test/api-root
'
;
import
{
createBinaryFileListResource
}
from
'
libs/binary-file-shared/test/binary-file
'
;
import
{
CommandLinkRel
}
from
'
libs/command-shared/src/lib/command.linkrel
'
;
import
{
createCommandListResource
,
createCommandResource
}
from
'
libs/command-shared/test/command
'
;
...
...
@@ -61,30 +62,69 @@ describe('VorgangService', () => {
service
=
new
VorgangService
(
useFromMock
(
repository
),
useFromMock
(
navigationService
),
useFromMock
(
commandService
),
useFromMock
(
vorgangFacade
),
useFromMock
(
apiRootService
));
})
describe
(
'
get vorgang with eingang
'
,
()
=>
{
describe
(
'
getVorgangWithEingang
'
,
()
=>
{
const
vorgangWithEingang
:
VorgangWithEingangResource
=
createVorgangWithEingangResource
();
const
url
:
ResourceUri
=
getUrl
(
vorgangWithEingang
);
const
vorgangWithEingangStateResource
:
StateResource
<
VorgangWithEingangResource
>
=
createStateResource
(
vorgangWithEingang
);
const
apiRootStateResource
:
StateResource
<
ApiRootResource
>
=
createStateResource
(
createApiRootResource
());
beforeEach
(()
=>
{
repository
.
getVorgang
.
mockReturnValue
(
of
(
vorgangWithEingang
));
service
.
setStateResourceOnLoading
=
jest
.
fn
();
apiRootService
.
getApiRoot
.
mockReturnValue
(
of
(
apiRootStateResource
));
})
it
(
'
should call service.setVorgangWithEingang
'
,
()
=>
{
const
spy
=
jest
.
spyOn
(
service
,
'
setVorgangWithEingang
'
);
const
resource
=
createStateResource
(
vorgangWithEingang
);
it
(
'
should get vorgangWithEingang
'
,
()
=>
{
service
.
getVorgangAsObservable
=
jest
.
fn
();
service
.
load
VorgangWithEingang
(
url
);
service
.
get
VorgangWithEingang
();
expect
(
s
py
).
toHaveBeenCalledWith
(
resource
);
expect
(
s
ervice
.
getVorgangAsObservable
).
toBeCalled
(
);
})
it
(
'
should
call apiRootService.
getApiRoot
'
,
()
=>
{
it
(
'
should
get
getApiRoot
'
,
()
=>
{
service
.
getVorgangWithEingang
();
expect
(
apiRootService
.
getApiRoot
).
toBeCalled
();
})
describe
(
'
initial
'
,
()
=>
{
beforeEach
(()
=>
{
apiRootService
.
getApiRoot
.
mockReturnValue
(
hot
(
'
-a
'
,
{
a
:
apiRootStateResource
}));
service
.
vorgangWithEingang$
.
next
(
vorgangWithEingangStateResource
);
})
it
(
'
should return value
'
,
()
=>
{
const
vorgangList
=
service
.
getVorgangWithEingang
();
expect
(
vorgangList
).
toBeObservable
(
cold
(
'
ab
'
,
{
a
:
createEmptyStateResource
(
true
),
b
:
vorgangWithEingangStateResource
}));
})
})
describe
(
'
loadVorgangWithEingang
'
,
()
=>
{
beforeEach
(()
=>
{
service
.
loadVorgangWithEingang
=
jest
.
fn
();
})
it
(
'
should be called if loading required
'
,
()
=>
{
service
.
vorgangWithEingang$
.
next
(
createEmptyStateResource
());
service
.
getVorgangWithEingang
().
subscribe
();
expect
(
service
.
loadVorgangWithEingang
).
toHaveBeenCalled
();
})
it
(
'
should NOT be called if already loaded
'
,
()
=>
{
service
.
vorgangWithEingang$
.
next
(
vorgangWithEingangStateResource
);
service
.
getVorgangWithEingang
().
subscribe
();
expect
(
service
.
loadVorgangWithEingang
).
not
.
toHaveBeenCalled
();
})
})
})
describe
(
'
loadVorgangWithEingang
'
,
()
=>
{
...
...
This diff is collapsed.
Click to expand it.
goofy-client/libs/vorgang-shared/src/lib/vorgang.service.ts
+
10
−
8
View file @
036655c0
...
...
@@ -28,10 +28,10 @@ import { BinaryFileListResource } from '@goofy-client/binary-file-shared';
import
{
CommandListResource
,
CommandResource
,
CommandService
,
getPendingCommandByOrder
,
hasError
,
isDone
}
from
'
@goofy-client/command-shared
'
;
import
{
NavigationService
}
from
'
@goofy-client/navigation-shared
'
;
import
{
PostfachOrder
}
from
'
@goofy-client/postfach-shared
'
;
import
{
createEmptyStateResource
,
createStateResource
,
doIfLoadingRequired
,
isNotNil
,
isNotNull
,
isNotUndefined
,
StateResource
}
from
'
@goofy-client/tech-shared
'
;
import
{
getUrl
,
hasLink
,
ResourceUri
}
from
'
@ngxp/rest
'
;
import
{
StateResource
,
createEmptyStateResource
,
createStateResource
,
doIfLoadingRequired
,
isNotNil
,
isNotNull
,
isNotUndefined
}
from
'
@goofy-client/tech-shared
'
;
import
{
ResourceUri
,
getUrl
,
hasLink
}
from
'
@ngxp/rest
'
;
import
{
CommandLinkRel
}
from
'
libs/command-shared/src/lib/command.linkrel
'
;
import
{
BehaviorSubject
,
combineLatest
,
Observable
,
Subscription
}
from
'
rxjs
'
;
import
{
BehaviorSubject
,
Observable
,
Subscription
,
combineLatest
}
from
'
rxjs
'
;
import
{
first
,
map
,
startWith
,
tap
}
from
'
rxjs/operators
'
;
import
{
VorgangFacade
}
from
'
./+state/vorgang.facade
'
;
import
{
VorgangRepository
}
from
'
./+state/vorgang.repository
'
;
...
...
@@ -67,21 +67,23 @@ export class VorgangService {
}
public
getVorgangWithEingang
():
Observable
<
StateResource
<
VorgangWithEingangResource
>>
{
return
combineLatest
([
this
.
v
organg
WithEingang$
,
this
.
apiRootService
.
getApiRoot
()]).
pipe
(
return
combineLatest
([
this
.
getV
organg
AsObservable
()
,
this
.
apiRootService
.
getApiRoot
()]).
pipe
(
tap
(([
vorgangWithEingang
,
apiRoot
])
=>
{
if
(
isNotNull
(
apiRoot
.
resource
)){
doIfLoadingRequired
(
vorgangWithEingang
,
()
=>
this
.
loadVorgangWithEingang
(
this
.
getVorgangWithEingangUrl
()));
}
if
(
isNotNull
(
apiRoot
.
resource
))
doIfLoadingRequired
(
vorgangWithEingang
,
()
=>
this
.
loadVorgangWithEingang
(
this
.
getVorgangWithEingangUrl
()));
}),
map
(([
vorgangWithEingang
,])
=>
vorgangWithEingang
),
startWith
(
createEmptyStateResource
<
VorgangWithEingangResource
>
(
true
)));
}
getVorgangAsObservable
():
Observable
<
StateResource
<
VorgangWithEingangResource
>>
{
return
this
.
vorgangWithEingang$
.
asObservable
();
}
public
getVorgang
():
VorgangWithEingangResource
{
return
this
.
vorgangWithEingang$
.
value
.
resource
;
}
private
getVorgangWithEingangUrl
():
ResourceUri
|
undefined
{
private
getVorgangWithEingangUrl
():
ResourceUri
{
return
this
.
navigationService
.
getDecodedParam
(
VorgangService
.
VORGANG_WITH_EINGANG_URL
);
}
...
...
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