Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
D
dcc-js
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
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
D-PTB
DCC
Development
dcc-js
Merge requests
!5
Add tests
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Add tests
feat-jest-tests
into
master
Overview
1
Commits
50
Pipelines
42
Changes
1
Merged
Jan Loewe
requested to merge
feat-jest-tests
into
master
2 years ago
Overview
1
Commits
50
Pipelines
42
Changes
1
Expand
0
0
Merge request reports
Viewing commit
0d28d88b
Prev
Next
Show latest version
1 file
+
0
−
66
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
0d28d88b
test: updated tests for ad customer and ad coreData
· 0d28d88b
Muhammed-Ali Demir
authored
2 years ago
tests/DCC/CoreDataType.test.ts deleted
100644 → 0
+
0
−
66
Options
/**
* @jest-environment ./tests/XMLEnvironment.ts
* @xml ./tests/resources/example.xml
*/
import
*
as
fc
from
"
fast-check
"
;
import
{
indexOf
,
select
,
toTextArr
,
toTextContentArr
}
from
"
../util
"
;
import
{
CoreDataType
,
DCCDocument
,
DCCXMLElement
}
from
"
../../src
"
;
import
{
string_ISO639_1
}
from
"
../Arbitraries
"
;
const
base
=
"
/dcc:digitalCalibrationCertificate/dcc:administrativeData/dcc:coreData
"
;
const
xpath
=
{
countryCodeISO3166_1
:
`string(
${
base
}
/dcc:countryCodeISO3166_1)`
,
usedLangCodeISO639_1
:
`
${
base
}
/dcc:usedLangCodeISO639_1`
,
};
describe
(
"
CoreDataType
"
,
()
=>
{
let
dcc
:
DCCDocument
,
coreData
:
CoreDataType
,
dom
;
beforeEach
(
async
()
=>
{
({
dcc
,
dom
}
=
await
xmlEnv
.
recreateEnv
());
coreData
=
dcc
.
digitalCalibrationCertificate
.
administrativeData
.
coreData
;
});
test
(
"
should get correct countryCodeISO3166_1 from XML
"
,
()
=>
{
expect
(
coreData
.
countryCodeISO3166_1
.
_text
).
toBe
(
select
(
xpath
.
countryCodeISO3166_1
,
dom
));
});
test
(
"
should get correct usedLangCodeISO639_1 from XML
"
,
()
=>
{
// get expected list from example xml
const
expected
=
<
Element
[]
>
select
(
xpath
.
usedLangCodeISO639_1
,
dom
);
expect
(
toTextArr
(
coreData
.
usedLangCodeISO639_1
)).
toEqual
(
toTextContentArr
(
expected
));
});
test
(
"
should set usedLangCodeISO639_1 correctly
"
,
()
=>
{
fc
.
assert
(
fc
.
property
(
string_ISO639_1
(),
(
str
)
=>
{
// add new element to array
coreData
.
usedLangCodeISO639_1
.
push
(
new
DCCXMLElement
({
_text
:
str
}));
// get actual list from xml
const
actual
=
<
Element
[]
>
select
(
xpath
.
usedLangCodeISO639_1
,
dcc
);
expect
(
toTextArr
(
coreData
.
usedLangCodeISO639_1
)).
toContain
(
str
);
expect
(
toTextContentArr
(
actual
)).
toContain
(
str
);
}),
);
});
test
(
"
should delete usedLangCodeISO639_1 correctly
"
,
()
=>
{
const
selection
=
toTextContentArr
(
<
Element
[]
>
select
(
xpath
.
usedLangCodeISO639_1
,
dom
));
fc
.
assert
(
fc
.
property
(
fc
.
constantFrom
(...
selection
),
(
str
)
=>
{
// get index and remove element from array
const
index
=
indexOf
(
coreData
.
usedLangCodeISO639_1
,
str
);
coreData
.
usedLangCodeISO639_1
.
splice
(
index
,
1
);
// get actual list from xml
const
actual
=
<
Element
[]
>
select
(
xpath
.
usedLangCodeISO639_1
,
dcc
);
expect
(
toTextArr
(
coreData
.
usedLangCodeISO639_1
)).
not
.
toContain
(
str
);
expect
(
toTextContentArr
(
actual
)).
not
.
toContain
(
str
);
}),
);
});
});
Loading