parsers/stanza_error: fix tests behind 'component' feature

pep created

Signed-off-by: pep <pep@bouah.net>

Change summary

parsers/ChangeLog           |  1 +
parsers/src/stanza_error.rs | 17 +++++++++++++++++
2 files changed, 18 insertions(+)

Detailed changes

parsers/ChangeLog 🔗

@@ -122,6 +122,7 @@ XXXX-YY-ZZ RELEASER <admin@example.com>
       - Fix compatibility to uuid 1.12
       - Implement Default for Tune
       - Re-export xso::error::FromElementError.
+      - Fix a few tests behind 'component' feature
 
 Version 0.21.0:
 2024-07-25 Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>

parsers/src/stanza_error.rs 🔗

@@ -375,9 +375,17 @@ mod tests {
 
     #[test]
     fn test_error_code() {
+        #[cfg(not(feature = "component"))]
         let elem: Element = r#"<error code="501" type="cancel" xmlns='jabber:client'>
     <feature-not-implemented xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
     <text xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'>The feature requested is not implemented by the recipient or server and therefore cannot be processed.</text>
+</error>"#
+            .parse()
+            .unwrap();
+        #[cfg(feature = "component")]
+        let elem: Element = r#"<error code="501" type="cancel" xmlns='jabber:component:accept'>
+    <feature-not-implemented xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
+    <text xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'>The feature requested is not implemented by the recipient or server and therefore cannot be processed.</text>
 </error>"#
             .parse()
             .unwrap();
@@ -387,10 +395,19 @@ mod tests {
 
     #[test]
     fn test_error_multiple_text() {
+        #[cfg(not(feature = "component"))]
         let elem: Element = r#"<error type="cancel" xmlns='jabber:client'>
     <item-not-found xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
     <text xmlns='urn:ietf:params:xml:ns:xmpp-stanzas' xml:lang="fr">Nœud non trouvé</text>
     <text xmlns='urn:ietf:params:xml:ns:xmpp-stanzas' xml:lang="en">Node not found</text>
+</error>"#
+            .parse()
+            .unwrap();
+        #[cfg(feature = "component")]
+        let elem: Element = r#"<error type="cancel" xmlns='jabber:component:accept'>
+    <item-not-found xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
+    <text xmlns='urn:ietf:params:xml:ns:xmpp-stanzas' xml:lang="fr">Nœud non trouvé</text>
+    <text xmlns='urn:ietf:params:xml:ns:xmpp-stanzas' xml:lang="en">Node not found</text>
 </error>"#
             .parse()
             .unwrap();