@@ -42,7 +42,53 @@ final class ParserTests: XCTestCase {
4242 let expected = Container (
4343 name: " Untitled " ,
4444 previewImageURL: URL ( string: " https://metaspace.rocks/mtsp/preview.jpg " ) !,
45- sceneURL: URL ( string: " https://metaspace.rocks/mtsp/file.usdz " ) !
45+ sceneURL: URL ( string: " https://metaspace.rocks/mtsp/file.usdz " ) !,
46+ navigation: [ : ]
47+ )
48+
49+ let data = input. data ( using: . utf8) !
50+ let result = try Parser . parse ( data, containerURL: containerURL)
51+
52+ XCTAssertEqual ( expected, result)
53+ }
54+
55+ func testParse_ValidWithNavigation_Succeed( ) throws {
56+ let containerURL = URL ( string: " https://metaspace.rocks/mtsp/index.html " ) !
57+ let input : String = """
58+ // Copyright 2024 Rafal Kopiec
59+ //
60+ // Licensed under the Apache License, Version 2.0 (the " License " );
61+ // you may not use this file except in compliance with the License.
62+ // You may obtain a copy of the License at
63+ // http://www.apache.org/licenses/LICENSE-2.0
64+ //
65+ // Unless required by applicable law or agreed to in writing, software
66+ // distributed under the License is distributed on an " AS IS " BASIS,
67+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
68+ // See the License for the specific language governing permissions and
69+ // limitations under the License.
70+
71+ #METASPACE_HOST
72+ #METASPACE_VERSION:1
73+ #METASPACE_NAME: " Untitled "
74+ #METASPACE_PREVIEW_PATH: " preview.jpg "
75+ #METASPACE_3D_PATH: " file.usdz "
76+ #METASPACE_NAVIGATION: " red_box " -> " red_box/index.mtsp "
77+ #METASPACE_NAVIGATION: " yellow_box " -> " yellow_box/index.mtsp "
78+ #METASPACE_NAVIGATION: " green_box " -> " green_box/index.mtsp "
79+ #METASPACE_NAVIGATION: " up_level_box " -> " ../index.mtsp "
80+ """
81+
82+ let expected = Container (
83+ name: " Untitled " ,
84+ previewImageURL: URL ( string: " https://metaspace.rocks/mtsp/preview.jpg " ) !,
85+ sceneURL: URL ( string: " https://metaspace.rocks/mtsp/file.usdz " ) !,
86+ navigation: [
87+ " red_box " : URL ( string: " https://metaspace.rocks/mtsp/red_box/index.mtsp " ) !,
88+ " yellow_box " : URL ( string: " https://metaspace.rocks/mtsp/yellow_box/index.mtsp " ) !,
89+ " green_box " : URL ( string: " https://metaspace.rocks/mtsp/green_box/index.mtsp " ) !,
90+ " up_level_box " : URL ( string: " https://metaspace.rocks/index.mtsp " ) !,
91+ ]
4692 )
4793
4894 let data = input. data ( using: . utf8) !
@@ -77,7 +123,8 @@ final class ParserTests: XCTestCase {
77123 let expected = Container (
78124 name: " Untitled " ,
79125 previewImageURL: URL ( string: " https://metaspace.rocks/mtsp/preview.jpg " ) !,
80- sceneURL: URL ( string: " https://metaspace.rocks/mtsp/file.usdz " ) !
126+ sceneURL: URL ( string: " https://metaspace.rocks/mtsp/file.usdz " ) !,
127+ navigation: [ : ]
81128 )
82129
83130 let data = input. data ( using: . utf8) !
0 commit comments