diff --git a/aas-web-ui/tests/mixins/SubmodelElementHandling.test.ts b/aas-web-ui/tests/mixins/SubmodelElementHandling.test.ts index 8b37c21..29b0ae5 100644 --- a/aas-web-ui/tests/mixins/SubmodelElementHandling.test.ts +++ b/aas-web-ui/tests/mixins/SubmodelElementHandling.test.ts @@ -9,23 +9,283 @@ describe('SubmodelElementHandling', () => { setActivePinia(createPinia()); }); - it('should return true for valid Eclass SemanticId', () => { - // Define a test component that uses the mixin - const TestComponent = defineComponent({ - mixins: [SubmodelElementHandling], - template: '
', - }); + // Define a test component that uses the mixin + const DummyComponent = defineComponent({ + mixins: [SubmodelElementHandling], + template: '', + }); + + // Define semanticId + const iri = 'https://admin-shell.io/zvei/nameplate/2/0/Nameplate'; + const eclassIrdiWithVersion = '0173-1#01-AHF578#001'; + const eclassIrdiWithoutVersion = '0173-1#01-AHF578'; + const eclassIrdiSlashesWithVersion = '0173/1///01#AHF578#001'; + const eclassIrdiSlashesWithoutVersion = '0173/1///01#AHF578'; + const eclassIriWithVersion = 'https://api.eclass-cdp.com/0173-1-01-AHF578-001'; + const eclassIriWithoutVersion = 'https://api.eclass-cdp.com/0173-1-01-AHF578'; + + // Define test data for semanticIdCheck() + const semanticIdTestCombinations = [ + // IRI test cases + { + semanticId: iri, + submodelElementSemanticId: iri, + strategy: 'exact', + match: true, + }, + + // Eclass IRDI (hash) test cases + { + semanticId: eclassIrdiWithVersion, + submodelElementSemanticId: eclassIrdiWithVersion, + strategy: 'exact', + match: true, + }, + { + semanticId: eclassIrdiWithoutVersion, + submodelElementSemanticId: eclassIrdiWithoutVersion, + strategy: 'exact', + match: true, + }, + { + semanticId: eclassIrdiWithVersion, + submodelElementSemanticId: eclassIrdiWithoutVersion, + strategy: '', + match: false, + }, + { + semanticId: eclassIrdiWithoutVersion, + submodelElementSemanticId: eclassIrdiWithVersion, + strategy: '', + match: true, + }, + + // Eclass IRDI (slashes) test cases + { + semanticId: eclassIrdiSlashesWithVersion, + submodelElementSemanticId: eclassIrdiSlashesWithVersion, + strategy: 'exact', + match: true, + }, + { + semanticId: eclassIrdiSlashesWithoutVersion, + submodelElementSemanticId: eclassIrdiSlashesWithoutVersion, + strategy: 'exact', + match: true, + }, + { + semanticId: eclassIrdiSlashesWithVersion, + submodelElementSemanticId: eclassIrdiSlashesWithoutVersion, + strategy: '', + match: false, + }, + { + semanticId: eclassIrdiSlashesWithoutVersion, + submodelElementSemanticId: eclassIrdiSlashesWithVersion, + strategy: '', + match: true, + }, + + // Eclass IRI test cases + { + semanticId: eclassIriWithVersion, + submodelElementSemanticId: eclassIriWithVersion, + strategy: 'exact', + match: true, + }, + { + semanticId: eclassIriWithoutVersion, + submodelElementSemanticId: eclassIriWithoutVersion, + strategy: 'exact', + match: true, + }, + { + semanticId: eclassIriWithVersion, + submodelElementSemanticId: eclassIriWithoutVersion, + strategy: '', + match: false, + }, + { + semanticId: eclassIriWithoutVersion, + submodelElementSemanticId: eclassIriWithVersion, + strategy: '', + match: true, + }, + + // Eclass IRDI (hash) and IRDI (slashes) test cases + { + semanticId: eclassIrdiWithVersion, + submodelElementSemanticId: eclassIrdiSlashesWithVersion, + strategy: 'exact', + match: true, + }, + { + semanticId: eclassIrdiSlashesWithVersion, + submodelElementSemanticId: eclassIrdiWithVersion, + strategy: 'exact', + match: true, + }, + + { + semanticId: eclassIrdiWithoutVersion, + submodelElementSemanticId: eclassIrdiSlashesWithoutVersion, + strategy: 'exact', + match: true, + }, + { + semanticId: eclassIrdiSlashesWithoutVersion, + submodelElementSemanticId: eclassIrdiWithoutVersion, + strategy: 'exact', + match: true, + }, + + { + semanticId: eclassIrdiWithVersion, + submodelElementSemanticId: eclassIrdiSlashesWithoutVersion, + strategy: '', + match: false, + }, + { + semanticId: eclassIrdiSlashesWithoutVersion, + submodelElementSemanticId: eclassIrdiWithVersion, + strategy: '', + match: false, + }, - // Mount the component - const wrapper: VueWrapper