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
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
OZG-Cloud
app
frontend-clients
Commits
c2a670b5
Verified
Commit
c2a670b5
authored
4 months ago
by
Sebastian Bergandy
Browse files
Options
Downloads
Patches
Plain Diff
OZG-5977 extract test function
parent
1f982b39
No related branches found
No related tags found
1 merge request
!67
OZG-5977 add multi option to file upload button
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
alfa-client/libs/binary-file-shared/src/lib/binary-file.service.spec.ts
+7
-30
7 additions, 30 deletions
...bs/binary-file-shared/src/lib/binary-file.service.spec.ts
alfa-client/libs/binary-file-shared/test/binary-file.ts
+11
-2
11 additions, 2 deletions
alfa-client/libs/binary-file-shared/test/binary-file.ts
with
18 additions
and
32 deletions
alfa-client/libs/binary-file-shared/src/lib/binary-file.service.spec.ts
+
7
−
30
View file @
c2a670b5
...
...
@@ -21,14 +21,7 @@
* Die sprachspezifischen Genehmigungen und Beschränkungen
* unter der Lizenz sind dem Lizenztext zu entnehmen.
*/
import
{
BlobWithFileName
,
createEmptyStateResource
,
createErrorStateResource
,
createStateResource
,
HttpError
,
StateResource
,
}
from
'
@alfa-client/tech-shared
'
;
import
{
BlobWithFileName
,
createEmptyStateResource
,
createErrorStateResource
,
createStateResource
,
HttpError
,
StateResource
,
}
from
'
@alfa-client/tech-shared
'
;
import
{
Mock
,
mock
,
useFromMock
}
from
'
@alfa-client/test-utils
'
;
import
{
SnackBarService
}
from
'
@alfa-client/ui
'
;
import
{
HttpErrorResponse
,
HttpResponse
}
from
'
@angular/common/http
'
;
...
...
@@ -36,7 +29,7 @@ import { fakeAsync, tick } from '@angular/core/testing';
import
{
faker
}
from
'
@faker-js/faker
'
;
import
{
getUrl
,
Resource
,
ResourceUri
}
from
'
@ngxp/rest
'
;
import
{
cold
,
hot
}
from
'
jest-marbles
'
;
import
{
createBinaryFileResource
,
createBlob
,
createFile
}
from
'
libs/binary-file-shared/test/binary-file
'
;
import
{
createBinaryFileResource
,
createBlob
,
createFile
,
createUploadFile
}
from
'
libs/binary-file-shared/test/binary-file
'
;
import
{
VALIDATION_MESSAGES
,
ValidationMessageCode
}
from
'
libs/tech-shared/src/lib/validation/tech.validation.messages
'
;
import
{
DummyLinkRel
}
from
'
libs/tech-shared/test/dummy
'
;
import
{
createProblemDetail
}
from
'
libs/tech-shared/test/error
'
;
...
...
@@ -86,11 +79,7 @@ describe('BinaryFileService', () => {
describe
(
'
get uploaded files
'
,
()
=>
{
const
type
:
FileUploadType
=
'
DummyType
'
;
const
uploadFile
:
UploadFile
=
{
key
:
faker
.
string
.
uuid
(),
fileToUpload
:
createFile
(),
uploadedFile
:
of
(
createStateResource
(
createBinaryFileResource
())),
};
const
uploadFile
:
UploadFile
=
createUploadFile
();
it
(
'
should return uploaded files by key
'
,
(
done
)
=>
{
service
.
uploadFiles
.
next
({
[
type
]:
[
uploadFile
]
});
...
...
@@ -124,18 +113,10 @@ describe('BinaryFileService', () => {
describe
(
'
remove uploaded file
'
,
()
=>
{
const
type
:
FileUploadType
=
'
dummyType
'
;
const
key1
:
string
=
faker
.
string
.
uuid
();
const
uploadFile1
:
UploadFile
=
{
key
:
key1
,
fileToUpload
:
createFile
(),
uploadedFile
:
of
(
createStateResource
(
createBinaryFileResource
())),
};
const
uploadFile1
:
UploadFile
=
{
...
createUploadFile
(),
key
:
key1
};
const
key2
:
string
=
faker
.
string
.
uuid
();
const
uploadFile2
:
UploadFile
=
{
key
:
key2
,
fileToUpload
:
createFile
(),
uploadedFile
:
of
(
createStateResource
(
createBinaryFileResource
())),
};
const
uploadFile2
:
UploadFile
=
{
...
createUploadFile
(),
key
:
key2
};
it
(
'
should remove uploaded file
'
,
()
=>
{
service
.
uploadFiles
.
next
({
[
type
]:
[
uploadFile1
,
uploadFile2
]
});
...
...
@@ -148,11 +129,7 @@ describe('BinaryFileService', () => {
});
describe
(
'
clear uploaded files
'
,
()
=>
{
const
uploadFile
:
UploadFile
=
{
key
:
faker
.
string
.
uuid
(),
fileToUpload
:
createFile
(),
uploadedFile
:
of
(
createStateResource
(
createBinaryFileResource
())),
};
const
uploadFile
:
UploadFile
=
createUploadFile
();
it
(
'
should remove entry by type from state
'
,
()
=>
{
const
type
:
FileUploadType
=
'
dummType
'
;
...
...
@@ -176,7 +153,7 @@ describe('BinaryFileService', () => {
const
binaryFileStateResource
$
:
Observable
<
StateResource
<
BinaryFileResource
>>
=
of
(
createStateResource
(
binaryFileResource
));
const
uploadFile
:
UploadFile
=
{
key
:
faker
.
string
.
uuid
(),
fileToUpload
:
file
,
uploadedFile
:
binaryFileStateResource$
};
const
uploadFile
:
UploadFile
=
{
...
createUploadFile
(),
fileToUpload
:
file
,
uploadedFile
:
binaryFileStateResource$
};
it
(
'
should push entry to uploaded files
'
,
()
=>
{
service
.
_buildUploadFile
=
jest
.
fn
().
mockReturnValue
(
uploadFile
);
...
...
This diff is collapsed.
Click to expand it.
alfa-client/libs/binary-file-shared/test/binary-file.ts
+
11
−
2
View file @
c2a670b5
...
...
@@ -21,12 +21,13 @@
* Die sprachspezifischen Genehmigungen und Beschränkungen
* unter der Lizenz sind dem Lizenztext zu entnehmen.
*/
import
{
GetRequestOptions
,
StateResource
,
create
StateResource
}
from
'
@alfa-client/tech-shared
'
;
import
{
createStateResource
,
GetRequestOptions
,
StateResource
}
from
'
@alfa-client/tech-shared
'
;
import
{
faker
}
from
'
@faker-js/faker
'
;
import
{
BinaryFileListLinkRel
}
from
'
libs/binary-file-shared/src/lib/binary-file.linkrel
'
;
import
{
BinaryFile
,
BinaryFileListResource
,
BinaryFileResource
}
from
'
libs/binary-file-shared/src/lib/binary-file.model
'
;
import
{
BinaryFile
,
BinaryFileListResource
,
BinaryFileResource
,
UploadFile
,
}
from
'
libs/binary-file-shared/src/lib/binary-file.model
'
;
import
{
toResource
}
from
'
libs/tech-shared/test/resource
'
;
import
{
times
}
from
'
lodash-es
'
;
import
{
of
}
from
'
rxjs
'
;
export
function
createBinaryFile
():
BinaryFile
{
return
{
...
...
@@ -78,3 +79,11 @@ export function createFile(): File {
webkitRelativePath
:
null
,
};
}
export
function
createUploadFile
():
UploadFile
{
return
{
key
:
faker
.
string
.
uuid
(),
fileToUpload
:
createFile
(),
uploadedFile
:
of
(
createStateResource
(
createBinaryFileResource
())),
};
}
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