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
Commits
51ee3365
Commit
51ee3365
authored
2 years ago
by
Muhammed-Ali Demir
Browse files
Options
Downloads
Patches
Plain Diff
test fnished customer minimal test, corrected software list test
parent
7bf63308
No related branches found
No related tags found
3 merge requests
!10
Refactor Test Resources
,
!6
Adaptations for new DCC V3.2.1
,
!5
Add tests
Pipeline
#19238
failed
2 years ago
Stage: .pre
Stage: test
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
tests/DCC/AdministrativeData.Customer.test.ts
+72
-0
72 additions, 0 deletions
tests/DCC/AdministrativeData.Customer.test.ts
tests/DCC/AdministrativeData.SoftwareListType.test.ts
+22
-12
22 additions, 12 deletions
tests/DCC/AdministrativeData.SoftwareListType.test.ts
with
94 additions
and
12 deletions
tests/DCC/AdministrativeData.Customer.test.ts
0 → 100644
+
72
−
0
View file @
51ee3365
/**
* @jest-environment ./tests/XMLEnvironment.ts
* @xml ./tests/resources/example.xml
*/
import
{
select
,
toTextArr
,
toTextContentArr
}
from
"
../util
"
;
import
{
ContactType
,
DCCDocument
,
LocationType
}
from
"
../../src
"
;
const
base
=
"
//dcc:administrativeData/dcc:customer
"
;
const
xpath
=
{
customerNameContent
:
`
${
base
}
/dcc:name/dcc:content`
,
customerEmail
:
`string(
${
base
}
/dcc:eMail)`
,
customerPhone
:
`
${
base
}
/dcc:phone)`
,
customerFax
:
`
${
base
}
/dcc:fax)`
,
customerLocation
:
`
${
base
}
/dcc:location`
,
customerLocationCity
:
`
${
base
}
/dcc:location/dcc:city[1]`
,
customerLocationCountryCode
:
`
${
base
}
/dcc:location/dcc:countryCode[1]`
,
customerLocationPostCode
:
`
${
base
}
/dcc:location/dcc:postCode[1]`
,
customerLocationPostBoxOffice
:
`
${
base
}
/dcc:location/dcc:postBoxOffice[1]`
,
customerLocationState
:
`
${
base
}
/dcc:location/dcc:state[1]`
,
customerLocationStreet
:
`
${
base
}
/dcc:location/dcc:street[1]`
,
customerLocationStreetNo
:
`
${
base
}
/dcc:location/dcc:streetNo[1]`
,
customerLocationFurther
:
`
${
base
}
/dcc:location/dcc:further[1]/dcc:content`
,
customerLocationPositionCoordinates
:
`
${
base
}
/dcc:location/dcc:positionCoordinates[1]`
,
customerDescriptionData
:
`
${
base
}
/dcc:descriptionData`
,
customerId
:
`
${
base
}
/@id`
,
};
describe
(
"
ContactType
"
,
()
=>
{
let
dcc
:
DCCDocument
,
customer
:
ContactType
,
location
:
LocationType
,
dom
;
beforeEach
(
async
()
=>
{
({
dcc
,
dom
}
=
await
xmlEnv
.
recreateEnv
());
customer
=
dcc
.
digitalCalibrationCertificate
.
administrativeData
.
customer
;
location
=
customer
.
location
;
});
test
(
"
should get correct customer name content from XML
"
,
()
=>
{
// get expected list from example xml
const
expected
=
<
Element
[]
>
select
(
xpath
.
customerNameContent
,
dom
);
expect
(
toTextArr
(
customer
.
name
.
content
)).
toEqual
(
toTextContentArr
(
expected
));
});
test
(
"
should get correct customer email address from XML
"
,
()
=>
{
expect
(
customer
.
eMail
.
_text
).
toBe
(
select
(
xpath
.
customerEmail
,
dom
));
});
test
(
"
should get correct customer location city from XML
"
,
()
=>
{
const
expected
=
<
Element
[]
>
select
(
xpath
.
customerLocationCity
,
dom
);
expect
(
customer
.
location
.
city
[
0
].
_text
).
toEqual
(
toTextContentArr
(
expected
).
pop
());
});
test
(
"
should get correct customer location county code from XML
"
,
()
=>
{
const
expected
=
<
Element
[]
>
select
(
xpath
.
customerLocationCountryCode
,
dom
);
expect
(
customer
.
location
.
countryCode
[
0
].
_text
).
toEqual
(
toTextContentArr
(
expected
).
pop
());
});
test
(
"
should get correct customer location post code from XML
"
,
()
=>
{
const
expected
=
<
Element
[]
>
select
(
xpath
.
customerLocationPostCode
,
dom
);
expect
(
customer
.
location
.
postCode
[
0
].
_text
).
toEqual
(
toTextContentArr
(
expected
).
pop
());
});
test
(
"
should get correct customer location further from XML
"
,
()
=>
{
const
expected
=
<
Element
[]
>
select
(
xpath
.
customerLocationFurther
,
dom
);
for
(
var
i
=
0
;
i
<
expected
.
length
;
i
++
)
{
expect
(
customer
.
location
.
further
[
0
].
content
[
i
].
_text
).
toBe
(
expected
[
i
].
textContent
);
}
});
/* TODO: setters */
});
This diff is collapsed.
Click to expand it.
tests/DCC/AdministrativeData.SoftwareListType.test.ts
+
22
−
12
View file @
51ee3365
...
...
@@ -10,22 +10,19 @@ const base = "//dcc:administrativeData/dcc:dccSoftware/dcc:software";
const
xpath
=
{
softwareNameContent
:
`
${
base
}
/dcc:name/dcc:content`
,
softwareRelease
:
`string(
${
base
}
/dcc:release)`
,
softwareType
:
"
string(${base}/dcc:type)
"
,
softwareDescription
:
"
${base}/dcc:description
"
,
softwareTypeId
:
"
${base}/@id
"
,
softwareTypeRefType
:
"
${base}/@refType
"
,
softwareType
:
`
string(
${
base
}
/dcc:type)
`
,
softwareDescription
:
`
${
base
}
/dcc:description
`
,
softwareTypeId
:
`
${
base
}
/@id
`
,
softwareTypeRefType
:
`
${
base
}
/@refType
`
,
};
/*
TODO: DCC enthält mehrere Sprachen, dass muss für bestimmte Felder wie z.B. Name auf alle Sprachen geprüft und verglichen werden
* */
describe
(
"
DccSoftwareType
"
,
()
=>
{
let
dcc
:
DCCDocument
,
dccSoftware
:
SoftwareListType
,
software
:
SoftwareType
,
dom
;
beforeEach
(
async
()
=>
{
({
dcc
,
dom
}
=
await
xmlEnv
.
recreateEnv
());
dccSoftware
=
dcc
.
digitalCalibrationCertificate
.
administrativeData
.
dccSoftware
;
software
=
dccSoftware
.
software
[
1
];
/* TODO: evtl. nicht nur mit ersten Index testen */
software
=
dccSoftware
.
software
[
0
];
/* TODO: evtl. nicht nur mit ersten Index testen */
});
test
(
"
should get correct software name content from XML
"
,
()
=>
{
...
...
@@ -38,16 +35,29 @@ describe("DccSoftwareType", () => {
expect
(
software
.
release
.
_text
).
toBe
(
select
(
xpath
.
softwareRelease
,
dom
));
});
/*
test("should get correct software type of software from XML", () => {
expect
(
software
.
type
.
_text
).
toBe
(
select
(
xpath
.
softwareType
,
dom
));
console.log(software);
if (select(xpath.softwareType, dom)) {
expect(software.type._text).toBe(select(xpath.softwareType, dom));
}
});
*/
/* TODO: description testen*/
/*
test("should get correct software reftype ...", () => {
expect
(
software
.
_attr
.
refType
).
toBe
(
select
(
xpath
.
softwareTypeRefType
,
dom
));
console.log(select(xpath.softwareTypeRefType, dom));
if (select(xpath.softwareTypeRefType, dom) != "") {
expect(software._attr.refType).toBe(select(xpath.softwareTypeRefType, dom));
}
});
test("should get correct software id ...", () => {
expect
(
software
.
_attr
.
id
).
toBe
(
select
(
xpath
.
softwareTypeId
,
dom
));
});
console.log(select(xpath.softwareTypeId, dom));
if (select(xpath.softwareTypeId, dom) != "") {
expect(software._attr.id).toBe(select(xpath.softwareTypeId, dom));
}
});*/
});
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