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
9b85eaa6
Prev
Next
Show latest version
1 file
+
211
−
0
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
9b85eaa6
test: added test for ad statements (wip)
· 9b85eaa6
Muhammed-Ali Demir
authored
2 years ago
tests/DCC/AdministrativeData.Statements.test.ts
0 → 100644
+
211
−
0
Options
/**
* @jest-environment ./tests/XMLEnvironment.ts
* @xml ./tests/resources/example.xml
*/
import
{
select
,
toTextArr
,
toTextContentArr
}
from
"
../util
"
;
import
{
StatementMetaDataType
,
DCCDocument
}
from
"
../../src
"
;
const
base
=
"
//dcc:administrativeData/dcc:statements
"
;
const
xpath
=
{
statements
:
{
statement1
:
{
norm
:
`string(
${
base
}
/dcc:statement[1]/dcc:norm)`
,
reference
:
`string(
${
base
}
/dcc:statement[1]/dcc:reference)`
,
declaration
:
{
content
:
`
${
base
}
/dcc:statement[1]/dcc:declaration/dcc:content`
,
},
refType
:
`string(
${
base
}
/dcc:statement[1]/@refType)`
,
},
statement2
:
{
declaration
:
{
content
:
`
${
base
}
/dcc:statement[2]/dcc:declaration/dcc:content`
,
},
data
:
{
quantity1
:
{
name
:
{
content
:
`
${
base
}
/dcc:statement[2]/dcc:data/dcc:quantity[1]/dcc:name/dcc:content`
,
},
si_real
:
{
si_value
:
`string(
${
base
}
/dcc:statement[2]/dcc:data/dcc:quantity[1]/si:real/si:value)`
,
si_unit
:
`string(
${
base
}
/dcc:statement[2]/dcc:data/dcc:quantity[1]/si:real/si:unit)`
,
},
},
quantity2
:
{
name
:
{
content
:
`
${
base
}
/dcc:statement[2]/dcc:data/dcc:quantity[2]/dcc:name/dcc:content`
,
},
si_real
:
{
si_value
:
`string(
${
base
}
/dcc:statement[2]/dcc:data/dcc:quantity[2]/si:real/si:value)`
,
si_unit
:
`string(
${
base
}
/dcc:statement[2]/dcc:data/dcc:quantity[2]/si:real/si:unit)`
,
},
},
},
refType
:
`string(
${
base
}
/dcc:statement[2]/@refType)`
,
},
statement3
:
{
declaration
:
{
content
:
`
${
base
}
/dcc:statement[3]/dcc:declaration/dcc:content`
,
},
respAuthority
:
{
name
:
{
content
:
`
${
base
}
/dcc:statement[3]/dcc:respAuthority/dcc:name/dcc:content`
,
},
email
:
`string(
${
base
}
/dcc:statement[3]/dcc:respAuthority/dcc:email)`
,
location
:
{
city
:
`string(
${
base
}
/dcc:statement[3]/dcc:respAuthority/dcc:location/dcc:city)`
,
countryCode
:
`string(
${
base
}
/dcc:statement[3]/dcc:respAuthority/dcc:location/dcc:countryCode)`
,
postCode
:
`string(
${
base
}
/dcc:statement[3]/dcc:respAuthority/dcc:location/dcc:postCode)`
,
},
},
conformity
:
`string(
${
base
}
/dcc:statement[3]/dcc:conformity)`
,
refType
:
`string(
${
base
}
/dcc:statement[3]/@refType)`
,
},
statement4
:
{
declaration
:
{
content
:
`
${
base
}
/dcc:statement[4]/dcc:declaration/dcc:content`
,
},
date
:
`string(
${
base
}
/dcc:statement[4]/dcc:date)`
,
respAuthority
:
{
name
:
{
content
:
`
${
base
}
/dcc:statement[3]/dcc:respAuthority/dcc:name/dcc:content`
,
},
email
:
`string(
${
base
}
/dcc:statement[3]/dcc:respAuthority/dcc:email)`
,
location
:
{
city
:
`string(
${
base
}
/dcc:statement[3]/dcc:respAuthority/dcc:location/dcc:city)`
,
countryCode
:
`string(
${
base
}
/dcc:statement[3]/dcc:respAuthority/dcc:location/dcc:countryCode)`
,
postCode
:
`string(
${
base
}
/dcc:statement[3]/dcc:respAuthority/dcc:location/dcc:postCode)`
,
},
},
refType
:
`string(
${
base
}
/dcc:statement[4]/@refType)`
,
},
},
};
describe
(
"
ItemType
"
,
()
=>
{
let
dcc
:
DCCDocument
,
statement1
,
statement2
,
statement3
,
statement4
:
StatementMetaDataType
,
dom
;
beforeEach
(
async
()
=>
{
({
dcc
,
dom
}
=
await
xmlEnv
.
recreateEnv
());
statement1
=
dcc
.
digitalCalibrationCertificate
.
administrativeData
.
statements
.
statement
[
0
];
statement2
=
dcc
.
digitalCalibrationCertificate
.
administrativeData
.
statements
.
statement
[
1
];
statement3
=
dcc
.
digitalCalibrationCertificate
.
administrativeData
.
statements
.
statement
[
2
];
statement4
=
dcc
.
digitalCalibrationCertificate
.
administrativeData
.
statements
.
statement
[
3
];
});
test
(
"
should get correct statement 1 declaration content from XML
"
,
()
=>
{
// get expected list from example xml
const
expected
=
<
Element
[]
>
select
(
xpath
.
statements
.
statement1
.
declaration
.
content
,
dom
);
expect
(
toTextArr
(
statement1
.
declaration
.
content
)).
toEqual
(
toTextContentArr
(
expected
));
});
test
(
"
should get correct statement 1 norm model from XML
"
,
()
=>
{
expect
(
statement1
.
norm
[
0
].
_text
).
toBe
(
select
(
xpath
.
statements
.
statement1
.
norm
,
dom
));
});
test
(
"
should get correct statement 1 reference from XML
"
,
()
=>
{
expect
(
statement1
.
reference
[
0
].
_text
).
toBe
(
select
(
xpath
.
statements
.
statement1
.
reference
,
dom
));
});
/* TODO: get refType from jest */
/*
test("should get correct statement 1 refType from XML", () => {
console.log(statement1);
expect(statement1.refType._text).toBe(select(xpath.statements.statement1.refType, dom));
});
*/
test
(
"
should get correct statement 2 declaration content from XML
"
,
()
=>
{
// get expected list from example xml
const
expected
=
<
Element
[]
>
select
(
xpath
.
statements
.
statement2
.
declaration
.
content
,
dom
);
expect
(
toTextArr
(
statement2
.
declaration
.
content
)).
toEqual
(
toTextContentArr
(
expected
));
});
test
(
"
should get correct statement 2 data quantity 1 name content from XML
"
,
()
=>
{
// get expected list from example xml
const
expected
=
<
Element
[]
>
select
(
xpath
.
statements
.
statement2
.
data
.
quantity1
.
name
.
content
,
dom
);
expect
(
toTextArr
(
statement2
.
data
.
quantity
[
0
].
name
.
content
)).
toEqual
(
toTextContentArr
(
expected
));
});
test
(
"
should get correct statement 2 data quantity 1 si:value from XML
"
,
()
=>
{
expect
(
statement2
.
data
.
quantity
[
0
].
real
.
value
.
_text
).
toBe
(
select
(
xpath
.
statements
.
statement2
.
data
.
quantity1
.
si_real
.
si_value
,
dom
));
});
test
(
"
should get correct statement 2 data quantity 2 si:unit from XML
"
,
()
=>
{
expect
(
statement2
.
data
.
quantity
[
0
].
real
.
unit
.
_text
).
toBe
(
select
(
xpath
.
statements
.
statement2
.
data
.
quantity1
.
si_real
.
si_unit
,
dom
));
});
test
(
"
should get correct statement 2 data quantity 2 name content from XML
"
,
()
=>
{
// get expected list from example xml
const
expected
=
<
Element
[]
>
select
(
xpath
.
statements
.
statement2
.
data
.
quantity2
.
name
.
content
,
dom
);
expect
(
toTextArr
(
statement2
.
data
.
quantity
[
1
].
name
.
content
)).
toEqual
(
toTextContentArr
(
expected
));
});
test
(
"
should get correct statement 2 data quantity 2 si:value from XML
"
,
()
=>
{
expect
(
statement2
.
data
.
quantity
[
1
].
real
.
value
.
_text
).
toBe
(
select
(
xpath
.
statements
.
statement2
.
data
.
quantity2
.
si_real
.
si_value
,
dom
));
});
test
(
"
should get correct statement 2 data quantity 2 si:unit from XML
"
,
()
=>
{
expect
(
statement2
.
data
.
quantity
[
1
].
real
.
unit
.
_text
).
toBe
(
select
(
xpath
.
statements
.
statement2
.
data
.
quantity2
.
si_real
.
si_unit
,
dom
));
});
test
(
"
should get correct statement 3 declaration content from XML
"
,
()
=>
{
// get expected list from example xml
const
expected
=
<
Element
[]
>
select
(
xpath
.
statements
.
statement3
.
declaration
.
content
,
dom
);
expect
(
toTextArr
(
statement3
.
declaration
.
content
)).
toEqual
(
toTextContentArr
(
expected
));
});
test
(
"
should get correct statement 3 responsible authority name content from XML
"
,
()
=>
{
// get expected list from example xml
const
expected
=
<
Element
[]
>
select
(
xpath
.
statements
.
statement3
.
respAuthority
.
name
.
content
,
dom
);
expect
(
toTextArr
(
statement3
.
respAuthority
.
name
.
content
)).
toEqual
(
toTextContentArr
(
expected
));
});
/* responsible authority 3 */
test
(
"
should get correct statement 3 responsible authority email from XML
"
,
()
=>
{
expect
(
statement3
.
respAuthority
.
eMail
.
_text
).
toBe
(
select
(
xpath
.
statements
.
statement3
.
respAuthority
.
email
,
dom
));
});
test
(
"
should get correct statement 3 responsible authority location city from XML
"
,
()
=>
{
expect
(
statement3
.
respAuthority
.
location
.
city
[
0
].
_text
).
toBe
(
select
(
xpath
.
statements
.
statement3
.
respAuthority
.
location
.
city
,
dom
));
});
test
(
"
should get correct statement 3 responsible authority location country code from XML
"
,
()
=>
{
expect
(
statement3
.
respAuthority
.
location
.
countryCode
[
0
].
_text
).
toBe
(
select
(
xpath
.
statements
.
statement3
.
respAuthority
.
location
.
countryCode
,
dom
));
});
test
(
"
should get correct statement 3 responsible authority location post code from XML
"
,
()
=>
{
expect
(
statement3
.
respAuthority
.
location
.
postCode
[
0
].
_text
).
toBe
(
select
(
xpath
.
statements
.
statement3
.
respAuthority
.
location
.
postCode
,
dom
));
});
test
(
"
should get correct statement 3 conformity from XML
"
,
()
=>
{
expect
(
statement3
.
conformity
.
_text
).
toBe
(
select
(
xpath
.
statements
.
statement3
.
conformity
,
dom
));
});
test
(
"
should get correct statement 4 declaration content from XML
"
,
()
=>
{
// get expected list from example xml
const
expected
=
<
Element
[]
>
select
(
xpath
.
statements
.
statement4
.
declaration
.
content
,
dom
);
expect
(
toTextArr
(
statement4
.
declaration
.
content
)).
toEqual
(
toTextContentArr
(
expected
));
});
test
(
"
should get correct statement 4 date from XML
"
,
()
=>
{
expect
(
statement4
.
date
.
_text
).
toBe
(
select
(
xpath
.
statements
.
statement4
.
date
,
dom
));
});
/* responsible authority 4 */
test
(
"
should get correct statement 4 responsible authority email from XML
"
,
()
=>
{
expect
(
statement4
.
respAuthority
.
eMail
.
_text
).
toBe
(
select
(
xpath
.
statements
.
statement4
.
respAuthority
.
email
,
dom
));
});
test
(
"
should get correct statement 4 responsible authority location city from XML
"
,
()
=>
{
expect
(
statement4
.
respAuthority
.
location
.
city
[
0
].
_text
).
toBe
(
select
(
xpath
.
statements
.
statement4
.
respAuthority
.
location
.
city
,
dom
));
});
test
(
"
should get correct statement 4 responsible authority location country code from XML
"
,
()
=>
{
expect
(
statement4
.
respAuthority
.
location
.
countryCode
[
0
].
_text
).
toBe
(
select
(
xpath
.
statements
.
statement4
.
respAuthority
.
location
.
countryCode
,
dom
));
});
test
(
"
should get correct statement 4 responsible authority location post code from XML
"
,
()
=>
{
expect
(
statement4
.
respAuthority
.
location
.
postCode
[
0
].
_text
).
toBe
(
select
(
xpath
.
statements
.
statement4
.
respAuthority
.
location
.
postCode
,
dom
));
});
/* TODO: refTypes */
/* TODO: setters */
});
Loading