File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed
crates/common/src/components Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change 11use std:: {
2+ fmt,
23 ops:: Deref ,
34 path:: {
45 Component as PathComponent ,
@@ -102,6 +103,12 @@ impl Deref for ComponentDefinitionPath {
102103 }
103104}
104105
106+ impl fmt:: Display for ComponentDefinitionPath {
107+ fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
108+ write ! ( f, "{}" , & * * self )
109+ }
110+ }
111+
105112impl From < ComponentDefinitionPath > for String {
106113 fn from ( value : ComponentDefinitionPath ) -> Self {
107114 value
@@ -139,3 +146,26 @@ impl proptest::arbitrary::Arbitrary for ComponentDefinitionPath {
139146 . boxed ( )
140147 }
141148}
149+
150+ #[ cfg( test) ]
151+ mod tests {
152+ use super :: * ;
153+
154+ #[ test]
155+ fn test_display_root_component ( ) {
156+ let path = ComponentDefinitionPath :: root ( ) ;
157+ assert_eq ! ( path. to_string( ) , "" ) ;
158+ }
159+
160+ #[ test]
161+ fn test_display_one_level ( ) {
162+ let path: ComponentDefinitionPath = "component1" . parse ( ) . unwrap ( ) ;
163+ assert_eq ! ( path. to_string( ) , "component1" ) ;
164+ }
165+
166+ #[ test]
167+ fn test_display_two_level ( ) {
168+ let path: ComponentDefinitionPath = "component1/component2" . parse ( ) . unwrap ( ) ;
169+ assert_eq ! ( path. to_string( ) , "component1/component2" ) ;
170+ }
171+ }
You can’t perform that action at this time.
0 commit comments