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
870d23e8
Commit
870d23e8
authored
2 years ago
by
Muhammed-Ali Demir
Browse files
Options
Downloads
Patches
Plain Diff
test: added tests for ad items, extended tests for respPerson
parent
7dfdfd32
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
Checking pipeline status
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
tests/DCC/AdministrativeData.Items.test.ts
+117
-0
117 additions, 0 deletions
tests/DCC/AdministrativeData.Items.test.ts
tests/DCC/AdministrativeData.RespPersons.test.ts
+22
-8
22 additions, 8 deletions
tests/DCC/AdministrativeData.RespPersons.test.ts
with
139 additions
and
8 deletions
tests/DCC/AdministrativeData.Items.test.ts
0 → 100644
+
117
−
0
View file @
870d23e8
/**
* @jest-environment ./tests/XMLEnvironment.ts
* @xml ./tests/resources/example.xml
*/
import
{
select
,
toTextArr
,
toTextContentArr
}
from
"
../util
"
;
import
{
ItemType
,
DCCDocument
,
DCCXMLElement
,
IdentificationType
}
from
"
../../src
"
;
const
base
=
"
//dcc:administrativeData/dcc:items
"
;
const
xpath
=
{
items
:
{
item
:
{
name
:
{
content
:
`
${
base
}
/dcc:item[1]/dcc:name/dcc:content`
,
},
manufacturer
:
{
name
:
{
content
:
`
${
base
}
/dcc:item[1]/dcc:manufacturer/dcc:name/dcc:content`
,
},
},
model
:
`string(
${
base
}
/dcc:item[1]/dcc:model)`
,
identifications
:
{
identification1
:
{
issuer
:
`string(
${
base
}
/dcc:item[1]/dcc:identifications/dcc:identification[1]/dcc:issuer)`
,
value
:
`string(
${
base
}
/dcc:item[1]/dcc:identifications/dcc:identification[1]/dcc:value)`
,
name
:
{
content
:
`
${
base
}
/dcc:item[1]/dcc:identifications/dcc:identification[1]/dcc:name/dcc:content`
,
},
},
identification2
:
{
issuer
:
`string(
${
base
}
/dcc:item[1]/dcc:identifications/dcc:identification[2]/dcc:issuer)`
,
value
:
`string(
${
base
}
/dcc:item[1]/dcc:identifications/dcc:identification[2]/dcc:value)`
,
name
:
{
content
:
`
${
base
}
/dcc:item[1]/dcc:identifications/dcc:identification[2]/dcc:name/dcc:content`
,
},
},
identification3
:
{
issuer
:
`string(
${
base
}
/dcc:item[1]/dcc:identifications/dcc:identification[3]/dcc:issuer)`
,
value
:
`string(
${
base
}
/dcc:item[1]/dcc:identifications/dcc:identification[3]/dcc:value)`
,
name
:
{
content
:
`
${
base
}
/dcc:item[1]/dcc:identifications/dcc:identification[3]/dcc:name/dcc:content`
,
},
},
},
},
},
};
describe
(
"
ItemType
"
,
()
=>
{
let
dcc
:
DCCDocument
,
item
:
ItemType
,
identification1
,
identification2
,
identification3
:
IdentificationType
,
dom
;
beforeEach
(
async
()
=>
{
({
dcc
,
dom
}
=
await
xmlEnv
.
recreateEnv
());
item
=
dcc
.
digitalCalibrationCertificate
.
administrativeData
.
items
.
item
[
0
];
identification1
=
item
.
identifications
.
identification
[
0
];
identification2
=
item
.
identifications
.
identification
[
1
];
identification3
=
item
.
identifications
.
identification
[
2
];
});
test
(
"
should get correct item name content from XML
"
,
()
=>
{
// get expected list from example xml
const
expected
=
<
Element
[]
>
select
(
xpath
.
items
.
item
.
name
.
content
,
dom
);
expect
(
toTextArr
(
item
.
name
.
content
)).
toEqual
(
toTextContentArr
(
expected
));
});
test
(
"
should get correct item manufacturer name content from XML
"
,
()
=>
{
// get expected list from example xml
const
expected
=
<
Element
[]
>
select
(
xpath
.
items
.
item
.
manufacturer
.
name
.
content
,
dom
);
expect
(
toTextArr
(
item
.
manufacturer
.
name
.
content
)).
toEqual
(
toTextContentArr
(
expected
));
});
test
(
"
should get correct item model from XML
"
,
()
=>
{
expect
(
item
.
model
.
_text
).
toBe
(
select
(
xpath
.
items
.
item
.
model
,
dom
));
});
test
(
"
should get correct identification 1 issuer from XML
"
,
()
=>
{
expect
(
identification1
.
issuer
.
_text
).
toBe
(
select
(
xpath
.
items
.
item
.
identifications
.
identification1
.
issuer
,
dom
));
});
test
(
"
should get correct identification 1 value from XML
"
,
()
=>
{
expect
(
identification1
.
value
.
_text
).
toBe
(
select
(
xpath
.
items
.
item
.
identifications
.
identification1
.
value
,
dom
));
});
test
(
"
should get correct identification 1 name content from XML
"
,
()
=>
{
const
expected
=
<
Element
[]
>
select
(
xpath
.
items
.
item
.
identifications
.
identification1
.
name
.
content
,
dom
);
expect
(
toTextArr
(
identification1
.
name
.
content
)).
toEqual
(
toTextContentArr
(
expected
));
});
test
(
"
should get correct identification 2 issuer from XML
"
,
()
=>
{
expect
(
identification2
.
issuer
.
_text
).
toBe
(
select
(
xpath
.
items
.
item
.
identifications
.
identification2
.
issuer
,
dom
));
});
test
(
"
should get correct identification 2 value from XML
"
,
()
=>
{
expect
(
identification2
.
value
.
_text
).
toBe
(
select
(
xpath
.
items
.
item
.
identifications
.
identification2
.
value
,
dom
));
});
test
(
"
should get correct identification 2 name content from XML
"
,
()
=>
{
const
expected
=
<
Element
[]
>
select
(
xpath
.
items
.
item
.
identifications
.
identification2
.
name
.
content
,
dom
);
expect
(
toTextArr
(
identification2
.
name
.
content
)).
toEqual
(
toTextContentArr
(
expected
));
});
test
(
"
should get correct identification 3 issuer from XML
"
,
()
=>
{
expect
(
identification3
.
issuer
.
_text
).
toBe
(
select
(
xpath
.
items
.
item
.
identifications
.
identification3
.
issuer
,
dom
));
});
test
(
"
should get correct identification 3 value from XML
"
,
()
=>
{
expect
(
identification3
.
value
.
_text
).
toBe
(
select
(
xpath
.
items
.
item
.
identifications
.
identification3
.
value
,
dom
));
});
test
(
"
should get correct identification 3 name content from XML
"
,
()
=>
{
const
expected
=
<
Element
[]
>
select
(
xpath
.
items
.
item
.
identifications
.
identification3
.
name
.
content
,
dom
);
expect
(
toTextArr
(
identification3
.
name
.
content
)).
toEqual
(
toTextContentArr
(
expected
));
});
/* TODO: setters */
});
This diff is collapsed.
Click to expand it.
tests/DCC/AdministrativeData.RespPersons.test.ts
+
22
−
8
View file @
870d23e8
...
...
@@ -9,7 +9,7 @@ import { RespPersonType, DCCDocument } from "../../src";
const
base
=
"
//dcc:administrativeData/dcc:respPersons
"
;
const
xpath
=
{
respPersons
:
{
respPerson
:
{
respPerson
1
:
{
person
:
{
name
:
{
content
:
`
${
base
}
/dcc:respPerson[1]/dcc:person/dcc:name/dcc:content`
,
...
...
@@ -17,25 +17,39 @@ const xpath = {
},
mainSigner
:
`string(
${
base
}
/dcc:respPerson[1]/dcc:mainSigner)`
,
},
respPerson2
:
{
person
:
{
name
:
{
content
:
`
${
base
}
/dcc:respPerson[2]/dcc:person/dcc:name/dcc:content`
,
},
},
},
},
};
describe
(
"
ContactType
"
,
()
=>
{
let
dcc
:
DCCDocument
,
respPerson
:
RespPersonType
,
dom
;
let
dcc
:
DCCDocument
,
respPerson
1
,
respPerson2
:
RespPersonType
,
dom
;
beforeEach
(
async
()
=>
{
({
dcc
,
dom
}
=
await
xmlEnv
.
recreateEnv
());
respPerson
=
dcc
.
digitalCalibrationCertificate
.
administrativeData
.
respPersons
.
respPerson
[
0
];
respPerson1
=
dcc
.
digitalCalibrationCertificate
.
administrativeData
.
respPersons
.
respPerson
[
0
];
respPerson2
=
dcc
.
digitalCalibrationCertificate
.
administrativeData
.
respPersons
.
respPerson
[
1
];
});
test
(
"
should get correct res name content from XML
"
,
()
=>
{
test
(
"
should get correct res
ponsible person 1
name content from XML
"
,
()
=>
{
// get expected list from example xml
const
expected
=
<
Element
[]
>
select
(
xpath
.
respPersons
.
respPerson
.
person
.
name
.
content
,
dom
);
expect
(
toTextArr
(
respPerson
.
person
.
name
.
content
)).
toEqual
(
toTextContentArr
(
expected
));
const
expected
=
<
Element
[]
>
select
(
xpath
.
respPersons
.
respPerson1
.
person
.
name
.
content
,
dom
);
expect
(
toTextArr
(
respPerson1
.
person
.
name
.
content
)).
toEqual
(
toTextContentArr
(
expected
));
});
test
(
"
should get correct responsible person 1 main signer flag from XML
"
,
()
=>
{
expect
(
respPerson1
.
mainSigner
.
_text
).
toBe
(
select
(
xpath
.
respPersons
.
respPerson1
.
mainSigner
,
dom
));
});
test
(
"
should get correct responsible person main signer flag from XML
"
,
()
=>
{
expect
(
respPerson
.
mainSigner
.
_text
).
toBe
(
select
(
xpath
.
respPersons
.
respPerson
.
mainSigner
,
dom
));
test
(
"
should get correct responsible person 2 name content from XML
"
,
()
=>
{
// get expected list from example xml
const
expected
=
<
Element
[]
>
select
(
xpath
.
respPersons
.
respPerson2
.
person
.
name
.
content
,
dom
);
expect
(
toTextArr
(
respPerson2
.
person
.
name
.
content
)).
toEqual
(
toTextContentArr
(
expected
));
});
/* TODO: setters */
...
...
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