online Minecraft written book viewer

test(text): write tests for subtypes

kokirigla.de 19f10dc6 abfac3f1

verified
+791 -10
+158 -9
Cargo.lock
··· 441 441 checksum = "75984efb6ed102a0d42db99afb6c1948f0380d1d91808d5529916e6c08b49d8d" 442 442 443 443 [[package]] 444 + name = "console" 445 + version = "0.15.11" 446 + source = "registry+https://github.com/rust-lang/crates.io-index" 447 + checksum = "054ccb5b10f9f2cbf51eb355ca1d05c2d279ce1804688d0db74b4733a5aeafd8" 448 + dependencies = [ 449 + "encode_unicode", 450 + "libc", 451 + "once_cell", 452 + "windows-sys 0.59.0", 453 + ] 454 + 455 + [[package]] 444 456 name = "const-oid" 445 457 version = "0.10.2" 446 458 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 576 588 checksum = "d0881ea181b1df73ff77ffaaf9c7544ecc11e82fba9b5f27b262a3c73a332555" 577 589 578 590 [[package]] 591 + name = "encode_unicode" 592 + version = "1.0.0" 593 + source = "registry+https://github.com/rust-lang/crates.io-index" 594 + checksum = "34aa73646ffb006b8f5147f3dc182bd4bcb190227ce861fc4a4844bf8e3cb2c0" 595 + 596 + [[package]] 579 597 name = "equivalent" 580 598 version = "1.0.2" 581 599 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 590 608 "libc", 591 609 "windows-sys 0.61.2", 592 610 ] 611 + 612 + [[package]] 613 + name = "fastrand" 614 + version = "2.3.0" 615 + source = "registry+https://github.com/rust-lang/crates.io-index" 616 + checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be" 593 617 594 618 [[package]] 595 619 name = "find-msvc-tools" ··· 861 885 ] 862 886 863 887 [[package]] 888 + name = "insta" 889 + version = "1.46.3" 890 + source = "registry+https://github.com/rust-lang/crates.io-index" 891 + checksum = "e82db8c87c7f1ccecb34ce0c24399b8a73081427f3c7c50a5d597925356115e4" 892 + dependencies = [ 893 + "console", 894 + "once_cell", 895 + "similar", 896 + "tempfile", 897 + ] 898 + 899 + [[package]] 864 900 name = "is_terminal_polyfill" 865 901 version = "1.70.2" 866 902 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 903 939 version = "0.2.182" 904 940 source = "registry+https://github.com/rust-lang/crates.io-index" 905 941 checksum = "6800badb6cb2082ffd7b6a67e6125bb39f18782f793520caee8cb8846be06112" 942 + 943 + [[package]] 944 + name = "linux-raw-sys" 945 + version = "0.12.1" 946 + source = "registry+https://github.com/rust-lang/crates.io-index" 947 + checksum = "32a66949e030da00e8c7d4434b251670a91556f4144941d37452769c25d58a53" 906 948 907 949 [[package]] 908 950 name = "lock_api" ··· 998 1040 name = "nara_text" 999 1041 version = "0.1.0" 1000 1042 dependencies = [ 1043 + "insta", 1001 1044 "serde", 1045 + "serde_json", 1002 1046 "serde_with", 1003 1047 ] 1004 1048 ··· 1157 1201 checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92" 1158 1202 dependencies = [ 1159 1203 "semver", 1204 + ] 1205 + 1206 + [[package]] 1207 + name = "rustix" 1208 + version = "1.1.4" 1209 + source = "registry+https://github.com/rust-lang/crates.io-index" 1210 + checksum = "b6fe4565b9518b83ef4f91bb47ce29620ca828bd32cb7e408f0062e9930ba190" 1211 + dependencies = [ 1212 + "bitflags", 1213 + "errno", 1214 + "libc", 1215 + "linux-raw-sys", 1216 + "windows-sys 0.61.2", 1160 1217 ] 1161 1218 1162 1219 [[package]] ··· 1345 1402 version = "0.3.8" 1346 1403 source = "registry+https://github.com/rust-lang/crates.io-index" 1347 1404 checksum = "e320a6c5ad31d271ad523dcf3ad13e2767ad8b1cb8f047f75a8aeaf8da139da2" 1405 + 1406 + [[package]] 1407 + name = "similar" 1408 + version = "2.7.0" 1409 + source = "registry+https://github.com/rust-lang/crates.io-index" 1410 + checksum = "bbbb5d9659141646ae647b42fe094daf6c6192d1620870b449d9557f748b2daa" 1348 1411 1349 1412 [[package]] 1350 1413 name = "slab" ··· 1402 1465 checksum = "0bf256ce5efdfa370213c1dabab5935a12e49f2c58d15e9eac2870d3b4f27263" 1403 1466 1404 1467 [[package]] 1468 + name = "tempfile" 1469 + version = "3.26.0" 1470 + source = "registry+https://github.com/rust-lang/crates.io-index" 1471 + checksum = "82a72c767771b47409d2345987fda8628641887d5466101319899796367354a0" 1472 + dependencies = [ 1473 + "fastrand", 1474 + "getrandom", 1475 + "once_cell", 1476 + "rustix", 1477 + "windows-sys 0.61.2", 1478 + ] 1479 + 1480 + [[package]] 1405 1481 name = "thiserror" 1406 1482 version = "2.0.18" 1407 1483 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 1764 1840 1765 1841 [[package]] 1766 1842 name = "windows-sys" 1843 + version = "0.59.0" 1844 + source = "registry+https://github.com/rust-lang/crates.io-index" 1845 + checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" 1846 + dependencies = [ 1847 + "windows-targets 0.52.6", 1848 + ] 1849 + 1850 + [[package]] 1851 + name = "windows-sys" 1767 1852 version = "0.60.2" 1768 1853 source = "registry+https://github.com/rust-lang/crates.io-index" 1769 1854 checksum = "f2f500e4d28234f72040990ec9d39e3a6b950f9f22d3dba18416c35882612bcb" 1770 1855 dependencies = [ 1771 - "windows-targets", 1856 + "windows-targets 0.53.5", 1772 1857 ] 1773 1858 1774 1859 [[package]] ··· 1782 1867 1783 1868 [[package]] 1784 1869 name = "windows-targets" 1870 + version = "0.52.6" 1871 + source = "registry+https://github.com/rust-lang/crates.io-index" 1872 + checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" 1873 + dependencies = [ 1874 + "windows_aarch64_gnullvm 0.52.6", 1875 + "windows_aarch64_msvc 0.52.6", 1876 + "windows_i686_gnu 0.52.6", 1877 + "windows_i686_gnullvm 0.52.6", 1878 + "windows_i686_msvc 0.52.6", 1879 + "windows_x86_64_gnu 0.52.6", 1880 + "windows_x86_64_gnullvm 0.52.6", 1881 + "windows_x86_64_msvc 0.52.6", 1882 + ] 1883 + 1884 + [[package]] 1885 + name = "windows-targets" 1785 1886 version = "0.53.5" 1786 1887 source = "registry+https://github.com/rust-lang/crates.io-index" 1787 1888 checksum = "4945f9f551b88e0d65f3db0bc25c33b8acea4d9e41163edf90dcd0b19f9069f3" 1788 1889 dependencies = [ 1789 1890 "windows-link", 1790 - "windows_aarch64_gnullvm", 1791 - "windows_aarch64_msvc", 1792 - "windows_i686_gnu", 1793 - "windows_i686_gnullvm", 1794 - "windows_i686_msvc", 1795 - "windows_x86_64_gnu", 1796 - "windows_x86_64_gnullvm", 1797 - "windows_x86_64_msvc", 1891 + "windows_aarch64_gnullvm 0.53.1", 1892 + "windows_aarch64_msvc 0.53.1", 1893 + "windows_i686_gnu 0.53.1", 1894 + "windows_i686_gnullvm 0.53.1", 1895 + "windows_i686_msvc 0.53.1", 1896 + "windows_x86_64_gnu 0.53.1", 1897 + "windows_x86_64_gnullvm 0.53.1", 1898 + "windows_x86_64_msvc 0.53.1", 1798 1899 ] 1900 + 1901 + [[package]] 1902 + name = "windows_aarch64_gnullvm" 1903 + version = "0.52.6" 1904 + source = "registry+https://github.com/rust-lang/crates.io-index" 1905 + checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" 1799 1906 1800 1907 [[package]] 1801 1908 name = "windows_aarch64_gnullvm" ··· 1805 1912 1806 1913 [[package]] 1807 1914 name = "windows_aarch64_msvc" 1915 + version = "0.52.6" 1916 + source = "registry+https://github.com/rust-lang/crates.io-index" 1917 + checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" 1918 + 1919 + [[package]] 1920 + name = "windows_aarch64_msvc" 1808 1921 version = "0.53.1" 1809 1922 source = "registry+https://github.com/rust-lang/crates.io-index" 1810 1923 checksum = "b9d782e804c2f632e395708e99a94275910eb9100b2114651e04744e9b125006" 1924 + 1925 + [[package]] 1926 + name = "windows_i686_gnu" 1927 + version = "0.52.6" 1928 + source = "registry+https://github.com/rust-lang/crates.io-index" 1929 + checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" 1811 1930 1812 1931 [[package]] 1813 1932 name = "windows_i686_gnu" ··· 1817 1936 1818 1937 [[package]] 1819 1938 name = "windows_i686_gnullvm" 1939 + version = "0.52.6" 1940 + source = "registry+https://github.com/rust-lang/crates.io-index" 1941 + checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" 1942 + 1943 + [[package]] 1944 + name = "windows_i686_gnullvm" 1820 1945 version = "0.53.1" 1821 1946 source = "registry+https://github.com/rust-lang/crates.io-index" 1822 1947 checksum = "fa7359d10048f68ab8b09fa71c3daccfb0e9b559aed648a8f95469c27057180c" 1823 1948 1824 1949 [[package]] 1825 1950 name = "windows_i686_msvc" 1951 + version = "0.52.6" 1952 + source = "registry+https://github.com/rust-lang/crates.io-index" 1953 + checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" 1954 + 1955 + [[package]] 1956 + name = "windows_i686_msvc" 1826 1957 version = "0.53.1" 1827 1958 source = "registry+https://github.com/rust-lang/crates.io-index" 1828 1959 checksum = "1e7ac75179f18232fe9c285163565a57ef8d3c89254a30685b57d83a38d326c2" 1829 1960 1830 1961 [[package]] 1831 1962 name = "windows_x86_64_gnu" 1963 + version = "0.52.6" 1964 + source = "registry+https://github.com/rust-lang/crates.io-index" 1965 + checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" 1966 + 1967 + [[package]] 1968 + name = "windows_x86_64_gnu" 1832 1969 version = "0.53.1" 1833 1970 source = "registry+https://github.com/rust-lang/crates.io-index" 1834 1971 checksum = "9c3842cdd74a865a8066ab39c8a7a473c0778a3f29370b5fd6b4b9aa7df4a499" 1835 1972 1836 1973 [[package]] 1837 1974 name = "windows_x86_64_gnullvm" 1975 + version = "0.52.6" 1976 + source = "registry+https://github.com/rust-lang/crates.io-index" 1977 + checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" 1978 + 1979 + [[package]] 1980 + name = "windows_x86_64_gnullvm" 1838 1981 version = "0.53.1" 1839 1982 source = "registry+https://github.com/rust-lang/crates.io-index" 1840 1983 checksum = "0ffa179e2d07eee8ad8f57493436566c7cc30ac536a3379fdf008f47f6bb7ae1" 1984 + 1985 + [[package]] 1986 + name = "windows_x86_64_msvc" 1987 + version = "0.52.6" 1988 + source = "registry+https://github.com/rust-lang/crates.io-index" 1989 + checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" 1841 1990 1842 1991 [[package]] 1843 1992 name = "windows_x86_64_msvc"
+1
Cargo.toml
··· 16 16 crab_nbt = { version = "=0.2.11", features = ["serde"] } 17 17 hex = "=0.4.3" 18 18 html-escape = "=0.2.13" 19 + insta = "=1.46.3" 19 20 lru = "=0.16.3" 20 21 serde = { version = "=1.0.228", features = ["derive"] } 21 22 serde_json = "=1.0.149"
+4 -1
justfile
··· 20 20 build: 21 21 @cargo build --release 22 22 23 + review: 24 + @cargo insta review --workspace 25 + 23 26 test: 24 - @cargo test 27 + @cargo test --workspace 25 28 26 29 ok: lint test 27 30 @cargo check --workspace
+4
nara_text/Cargo.toml
··· 6 6 [dependencies] 7 7 serde.workspace = true 8 8 serde_with.workspace = true 9 + 10 + [dev-dependencies] 11 + insta.workspace = true 12 + serde_json.workspace = true
+3
nara_text/tests/fixtures/keybind.json
··· 1 + { 2 + "keybind": "key.inventory" 3 + }
+7
nara_text/tests/fixtures/nbt_block.json
··· 1 + { 2 + "source": "block", 3 + "nbt": "foo", 4 + "interpret": true, 5 + "separator": ", ", 6 + "block": "~ ~ ~" 7 + }
+7
nara_text/tests/fixtures/nbt_entity.json
··· 1 + { 2 + "source": "entity", 3 + "nbt": "foo", 4 + "interpret": true, 5 + "separator": ", ", 6 + "entity": "@p" 7 + }
+7
nara_text/tests/fixtures/nbt_storage.json
··· 1 + { 2 + "source": "storage", 3 + "nbt": "foo", 4 + "interpret": true, 5 + "separator": ", ", 6 + "storage": "minecraft:example" 7 + }
+5
nara_text/tests/fixtures/object_atlas.json
··· 1 + { 2 + "object": "atlas", 3 + "atlas": "minecraft:blocks", 4 + "sprite": "minecraft:stone" 5 + }
+4
nara_text/tests/fixtures/object_player.json
··· 1 + { 2 + "object": "player", 3 + "player": "kokiriglade" 4 + }
+18
nara_text/tests/fixtures/object_player_profile.json
··· 1 + { 2 + "object": "player", 3 + "player": { 4 + "name": "kokiriglade", 5 + "id": [452952, 452952, 459252, 459252], 6 + "properties": [ 7 + { 8 + "name": "textures", 9 + "value": "foo", 10 + "signature": "bar" 11 + } 12 + ], 13 + "texture": "minecraft:steve", 14 + "cape": "minecraft:some_cape", 15 + "model": "wide" 16 + }, 17 + "hat": false 18 + }
+6
nara_text/tests/fixtures/score.json
··· 1 + { 2 + "score": { 3 + "name": "@p", 4 + "objective": "foo.bar" 5 + } 6 + }
+4
nara_text/tests/fixtures/selector.json
··· 1 + { 2 + "selector": "@p", 3 + "separator": ", " 4 + }
+1
nara_text/tests/fixtures/text_plain.json
··· 1 + "Hello, World!"
+3
nara_text/tests/fixtures/text_tagged.json
··· 1 + { 2 + "text": "Hello, World!" 3 + }
+10
nara_text/tests/fixtures/translation.json
··· 1 + { 2 + "translate": "foo.bar", 3 + "fallback": "foo bar xyzzy", 4 + "with": [ 5 + "foo", 6 + { 7 + "text": "bar" 8 + } 9 + ] 10 + }
+9
nara_text/tests/keybind.rs
··· 1 + use nara_text::Component; 2 + 3 + const FIXTURE: &str = include_str!("fixtures/keybind.json"); 4 + 5 + #[test] 6 + fn keybind() { 7 + let parsed = serde_json::from_str::<Component>(FIXTURE).unwrap(); 8 + insta::assert_debug_snapshot!(parsed); 9 + }
+23
nara_text/tests/nbt.rs
··· 1 + use nara_text::Component; 2 + 3 + const BLOCK_FIXTURE: &str = include_str!("fixtures/nbt_block.json"); 4 + const ENTITY_FIXTURE: &str = include_str!("fixtures/nbt_entity.json"); 5 + const STORAGE_FIXTURE: &str = include_str!("fixtures/nbt_storage.json"); 6 + 7 + #[test] 8 + fn block() { 9 + let parsed = serde_json::from_str::<Component>(BLOCK_FIXTURE).unwrap(); 10 + insta::assert_debug_snapshot!(parsed); 11 + } 12 + 13 + #[test] 14 + fn entity() { 15 + let parsed = serde_json::from_str::<Component>(ENTITY_FIXTURE).unwrap(); 16 + insta::assert_debug_snapshot!(parsed); 17 + } 18 + 19 + #[test] 20 + fn storage() { 21 + let parsed = serde_json::from_str::<Component>(STORAGE_FIXTURE).unwrap(); 22 + insta::assert_debug_snapshot!(parsed); 23 + }
+25
nara_text/tests/object.rs
··· 1 + use nara_text::Component; 2 + 3 + const ATLAS_FIXTURE: &str = include_str!("fixtures/object_atlas.json"); 4 + const PLAYER_FIXTURE: &str = include_str!("fixtures/object_player.json"); 5 + const PLAYER_PROFILE_FIXTURE: &str = 6 + include_str!("fixtures/object_player_profile.json"); 7 + 8 + #[test] 9 + fn atlas() { 10 + let parsed = serde_json::from_str::<Component>(ATLAS_FIXTURE).unwrap(); 11 + insta::assert_debug_snapshot!(parsed); 12 + } 13 + 14 + #[test] 15 + fn player() { 16 + let parsed = serde_json::from_str::<Component>(PLAYER_FIXTURE).unwrap(); 17 + insta::assert_debug_snapshot!(parsed); 18 + } 19 + 20 + #[test] 21 + fn player_profile() { 22 + let parsed = 23 + serde_json::from_str::<Component>(PLAYER_PROFILE_FIXTURE).unwrap(); 24 + insta::assert_debug_snapshot!(parsed); 25 + }
+9
nara_text/tests/score.rs
··· 1 + use nara_text::Component; 2 + 3 + const FIXTURE: &str = include_str!("fixtures/score.json"); 4 + 5 + #[test] 6 + fn score() { 7 + let parsed = serde_json::from_str::<Component>(FIXTURE).unwrap(); 8 + insta::assert_debug_snapshot!(parsed); 9 + }
+9
nara_text/tests/selector.rs
··· 1 + use nara_text::Component; 2 + 3 + const FIXTURE: &str = include_str!("fixtures/selector.json"); 4 + 5 + #[test] 6 + fn selector() { 7 + let parsed = serde_json::from_str::<Component>(FIXTURE).unwrap(); 8 + insta::assert_debug_snapshot!(parsed); 9 + }
+29
nara_text/tests/snapshots/keybind__keybind.snap
··· 1 + --- 2 + source: nara_text/tests/keybind.rs 3 + expression: parsed 4 + --- 5 + Object( 6 + ComponentObject { 7 + text: None, 8 + translation: None, 9 + score: None, 10 + selector: None, 11 + keybind: Some( 12 + KeybindComponent { 13 + keybind: "key.inventory", 14 + }, 15 + ), 16 + nbt: None, 17 + object: None, 18 + formatting: ComponentFormatting { 19 + color: None, 20 + font: None, 21 + bold: None, 22 + italic: None, 23 + underlined: None, 24 + strikethrough: None, 25 + obfuscated: None, 26 + }, 27 + children: [], 28 + }, 29 + )
+41
nara_text/tests/snapshots/nbt__block.snap
··· 1 + --- 2 + source: nara_text/tests/nbt.rs 3 + expression: parsed 4 + --- 5 + Object( 6 + ComponentObject { 7 + text: None, 8 + translation: None, 9 + score: None, 10 + selector: None, 11 + keybind: None, 12 + nbt: Some( 13 + NbtComponent { 14 + source: Some( 15 + Block, 16 + ), 17 + path: "foo", 18 + interpret: Some( 19 + true, 20 + ), 21 + separator: None, 22 + entity: None, 23 + block: Some( 24 + "~ ~ ~", 25 + ), 26 + storage: None, 27 + }, 28 + ), 29 + object: None, 30 + formatting: ComponentFormatting { 31 + color: None, 32 + font: None, 33 + bold: None, 34 + italic: None, 35 + underlined: None, 36 + strikethrough: None, 37 + obfuscated: None, 38 + }, 39 + children: [], 40 + }, 41 + )
+41
nara_text/tests/snapshots/nbt__entity.snap
··· 1 + --- 2 + source: nara_text/tests/nbt.rs 3 + expression: parsed 4 + --- 5 + Object( 6 + ComponentObject { 7 + text: None, 8 + translation: None, 9 + score: None, 10 + selector: None, 11 + keybind: None, 12 + nbt: Some( 13 + NbtComponent { 14 + source: Some( 15 + Entity, 16 + ), 17 + path: "foo", 18 + interpret: Some( 19 + true, 20 + ), 21 + separator: None, 22 + entity: Some( 23 + "@p", 24 + ), 25 + block: None, 26 + storage: None, 27 + }, 28 + ), 29 + object: None, 30 + formatting: ComponentFormatting { 31 + color: None, 32 + font: None, 33 + bold: None, 34 + italic: None, 35 + underlined: None, 36 + strikethrough: None, 37 + obfuscated: None, 38 + }, 39 + children: [], 40 + }, 41 + )
+41
nara_text/tests/snapshots/nbt__storage.snap
··· 1 + --- 2 + source: nara_text/tests/nbt.rs 3 + expression: parsed 4 + --- 5 + Object( 6 + ComponentObject { 7 + text: None, 8 + translation: None, 9 + score: None, 10 + selector: None, 11 + keybind: None, 12 + nbt: Some( 13 + NbtComponent { 14 + source: Some( 15 + Storage, 16 + ), 17 + path: "foo", 18 + interpret: Some( 19 + true, 20 + ), 21 + separator: None, 22 + entity: None, 23 + block: None, 24 + storage: Some( 25 + "minecraft:example", 26 + ), 27 + }, 28 + ), 29 + object: None, 30 + formatting: ComponentFormatting { 31 + color: None, 32 + font: None, 33 + bold: None, 34 + italic: None, 35 + underlined: None, 36 + strikethrough: None, 37 + obfuscated: None, 38 + }, 39 + children: [], 40 + }, 41 + )
+34
nara_text/tests/snapshots/object__atlas.snap
··· 1 + --- 2 + source: nara_text/tests/object.rs 3 + expression: parsed 4 + --- 5 + Object( 6 + ComponentObject { 7 + text: None, 8 + translation: None, 9 + score: None, 10 + selector: None, 11 + keybind: None, 12 + nbt: None, 13 + object: Some( 14 + Atlas( 15 + AtlasObject { 16 + atlas: Some( 17 + "minecraft:blocks", 18 + ), 19 + sprite: "minecraft:stone", 20 + }, 21 + ), 22 + ), 23 + formatting: ComponentFormatting { 24 + color: None, 25 + font: None, 26 + bold: None, 27 + italic: None, 28 + underlined: None, 29 + strikethrough: None, 30 + obfuscated: None, 31 + }, 32 + children: [], 33 + }, 34 + )
+34
nara_text/tests/snapshots/object__player.snap
··· 1 + --- 2 + source: nara_text/tests/object.rs 3 + expression: parsed 4 + --- 5 + Object( 6 + ComponentObject { 7 + text: None, 8 + translation: None, 9 + score: None, 10 + selector: None, 11 + keybind: None, 12 + nbt: None, 13 + object: Some( 14 + Player( 15 + PlayerObject { 16 + player: Name( 17 + "kokiriglade", 18 + ), 19 + hat: None, 20 + }, 21 + ), 22 + ), 23 + formatting: ComponentFormatting { 24 + color: None, 25 + font: None, 26 + bold: None, 27 + italic: None, 28 + underlined: None, 29 + strikethrough: None, 30 + obfuscated: None, 31 + }, 32 + children: [], 33 + }, 34 + )
+67
nara_text/tests/snapshots/object__player_profile.snap
··· 1 + --- 2 + source: nara_text/tests/object.rs 3 + expression: parsed 4 + --- 5 + Object( 6 + ComponentObject { 7 + text: None, 8 + translation: None, 9 + score: None, 10 + selector: None, 11 + keybind: None, 12 + nbt: None, 13 + object: Some( 14 + Player( 15 + PlayerObject { 16 + player: Profile( 17 + PlayerProfile { 18 + name: Some( 19 + "kokiriglade", 20 + ), 21 + id: Some( 22 + [ 23 + 452952, 24 + 452952, 25 + 459252, 26 + 459252, 27 + ], 28 + ), 29 + properties: [ 30 + PlayerProfileProperty { 31 + name: "textures", 32 + value: "foo", 33 + signature: Some( 34 + "bar", 35 + ), 36 + }, 37 + ], 38 + texture: Some( 39 + "minecraft:steve", 40 + ), 41 + cape: Some( 42 + "minecraft:some_cape", 43 + ), 44 + elytra: None, 45 + model: Some( 46 + Wide, 47 + ), 48 + }, 49 + ), 50 + hat: Some( 51 + false, 52 + ), 53 + }, 54 + ), 55 + ), 56 + formatting: ComponentFormatting { 57 + color: None, 58 + font: None, 59 + bold: None, 60 + italic: None, 61 + underlined: None, 62 + strikethrough: None, 63 + obfuscated: None, 64 + }, 65 + children: [], 66 + }, 67 + )
+30
nara_text/tests/snapshots/score__score.snap
··· 1 + --- 2 + source: nara_text/tests/score.rs 3 + expression: parsed 4 + --- 5 + Object( 6 + ComponentObject { 7 + text: None, 8 + translation: None, 9 + score: Some( 10 + ScoreComponent { 11 + name: "@p", 12 + objective: "foo.bar", 13 + }, 14 + ), 15 + selector: None, 16 + keybind: None, 17 + nbt: None, 18 + object: None, 19 + formatting: ComponentFormatting { 20 + color: None, 21 + font: None, 22 + bold: None, 23 + italic: None, 24 + underlined: None, 25 + strikethrough: None, 26 + obfuscated: None, 27 + }, 28 + children: [], 29 + }, 30 + )
+34
nara_text/tests/snapshots/selector__selector.snap
··· 1 + --- 2 + source: nara_text/tests/selector.rs 3 + expression: parsed 4 + --- 5 + Object( 6 + ComponentObject { 7 + text: None, 8 + translation: None, 9 + score: None, 10 + selector: Some( 11 + SelectorComponent { 12 + selector: "@p", 13 + separator: Some( 14 + String( 15 + ", ", 16 + ), 17 + ), 18 + }, 19 + ), 20 + keybind: None, 21 + nbt: None, 22 + object: None, 23 + formatting: ComponentFormatting { 24 + color: None, 25 + font: None, 26 + bold: None, 27 + italic: None, 28 + underlined: None, 29 + strikethrough: None, 30 + obfuscated: None, 31 + }, 32 + children: [], 33 + }, 34 + )
+7
nara_text/tests/snapshots/text__plain.snap
··· 1 + --- 2 + source: nara_text/tests/text.rs 3 + expression: parsed 4 + --- 5 + String( 6 + "Hello, World!", 7 + )
+29
nara_text/tests/snapshots/text__tagged.snap
··· 1 + --- 2 + source: nara_text/tests/text.rs 3 + expression: parsed 4 + --- 5 + Object( 6 + ComponentObject { 7 + text: Some( 8 + TextComponent { 9 + text: "Hello, World!", 10 + }, 11 + ), 12 + translation: None, 13 + score: None, 14 + selector: None, 15 + keybind: None, 16 + nbt: None, 17 + object: None, 18 + formatting: ComponentFormatting { 19 + color: None, 20 + font: None, 21 + bold: None, 22 + italic: None, 23 + underlined: None, 24 + strikethrough: None, 25 + obfuscated: None, 26 + }, 27 + children: [], 28 + }, 29 + )
+62
nara_text/tests/snapshots/translation__translation.snap
··· 1 + --- 2 + source: nara_text/tests/translation.rs 3 + expression: parsed 4 + --- 5 + Object( 6 + ComponentObject { 7 + text: None, 8 + translation: Some( 9 + TranslationComponent { 10 + translate: "foo.bar", 11 + fallback: Some( 12 + "foo bar xyzzy", 13 + ), 14 + with: [ 15 + String( 16 + "foo", 17 + ), 18 + Object( 19 + ComponentObject { 20 + text: Some( 21 + TextComponent { 22 + text: "bar", 23 + }, 24 + ), 25 + translation: None, 26 + score: None, 27 + selector: None, 28 + keybind: None, 29 + nbt: None, 30 + object: None, 31 + formatting: ComponentFormatting { 32 + color: None, 33 + font: None, 34 + bold: None, 35 + italic: None, 36 + underlined: None, 37 + strikethrough: None, 38 + obfuscated: None, 39 + }, 40 + children: [], 41 + }, 42 + ), 43 + ], 44 + }, 45 + ), 46 + score: None, 47 + selector: None, 48 + keybind: None, 49 + nbt: None, 50 + object: None, 51 + formatting: ComponentFormatting { 52 + color: None, 53 + font: None, 54 + bold: None, 55 + italic: None, 56 + underlined: None, 57 + strikethrough: None, 58 + obfuscated: None, 59 + }, 60 + children: [], 61 + }, 62 + )
+16
nara_text/tests/text.rs
··· 1 + use nara_text::Component; 2 + 3 + const PLAIN_FIXTURE: &str = include_str!("fixtures/text_plain.json"); 4 + const TAGGED_FIXTURE: &str = include_str!("fixtures/text_tagged.json"); 5 + 6 + #[test] 7 + fn plain() { 8 + let parsed = serde_json::from_str::<Component>(PLAIN_FIXTURE).unwrap(); 9 + insta::assert_debug_snapshot!(parsed); 10 + } 11 + 12 + #[test] 13 + fn tagged() { 14 + let parsed = serde_json::from_str::<Component>(TAGGED_FIXTURE).unwrap(); 15 + insta::assert_debug_snapshot!(parsed); 16 + }
+9
nara_text/tests/translation.rs
··· 1 + use nara_text::Component; 2 + 3 + const FIXTURE: &str = include_str!("fixtures/translation.json"); 4 + 5 + #[test] 6 + fn translation() { 7 + let parsed = serde_json::from_str::<Component>(FIXTURE).unwrap(); 8 + insta::assert_debug_snapshot!(parsed); 9 + }