tangled
alpha
login
or
join now
kokirigla.de
/
nara
0
fork
atom
online Minecraft written book viewer
0
fork
atom
overview
issues
pulls
pipelines
test(text): write tests for subtypes
kokirigla.de
3 weeks ago
19f10dc6
abfac3f1
verified
This commit was signed with the committer's
known signature
.
kokirigla.de
SSH Key Fingerprint:
SHA256:BlSEtD3ZoKT3iKveofI8gba+lZ9CEolKRM1Pzy3pAwg=
+791
-10
35 changed files
expand all
collapse all
unified
split
Cargo.lock
Cargo.toml
justfile
nara_text
Cargo.toml
tests
fixtures
keybind.json
nbt_block.json
nbt_entity.json
nbt_storage.json
object_atlas.json
object_player.json
object_player_profile.json
score.json
selector.json
text_plain.json
text_tagged.json
translation.json
keybind.rs
nbt.rs
object.rs
score.rs
selector.rs
snapshots
keybind__keybind.snap
nbt__block.snap
nbt__entity.snap
nbt__storage.snap
object__atlas.snap
object__player.snap
object__player_profile.snap
score__score.snap
selector__selector.snap
text__plain.snap
text__tagged.snap
translation__translation.snap
text.rs
translation.rs
+158
-9
Cargo.lock
···
441
441
checksum = "75984efb6ed102a0d42db99afb6c1948f0380d1d91808d5529916e6c08b49d8d"
442
442
443
443
[[package]]
444
444
+
name = "console"
445
445
+
version = "0.15.11"
446
446
+
source = "registry+https://github.com/rust-lang/crates.io-index"
447
447
+
checksum = "054ccb5b10f9f2cbf51eb355ca1d05c2d279ce1804688d0db74b4733a5aeafd8"
448
448
+
dependencies = [
449
449
+
"encode_unicode",
450
450
+
"libc",
451
451
+
"once_cell",
452
452
+
"windows-sys 0.59.0",
453
453
+
]
454
454
+
455
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
591
+
name = "encode_unicode"
592
592
+
version = "1.0.0"
593
593
+
source = "registry+https://github.com/rust-lang/crates.io-index"
594
594
+
checksum = "34aa73646ffb006b8f5147f3dc182bd4bcb190227ce861fc4a4844bf8e3cb2c0"
595
595
+
596
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
611
+
612
612
+
[[package]]
613
613
+
name = "fastrand"
614
614
+
version = "2.3.0"
615
615
+
source = "registry+https://github.com/rust-lang/crates.io-index"
616
616
+
checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be"
593
617
594
618
[[package]]
595
619
name = "find-msvc-tools"
···
861
885
]
862
886
863
887
[[package]]
888
888
+
name = "insta"
889
889
+
version = "1.46.3"
890
890
+
source = "registry+https://github.com/rust-lang/crates.io-index"
891
891
+
checksum = "e82db8c87c7f1ccecb34ce0c24399b8a73081427f3c7c50a5d597925356115e4"
892
892
+
dependencies = [
893
893
+
"console",
894
894
+
"once_cell",
895
895
+
"similar",
896
896
+
"tempfile",
897
897
+
]
898
898
+
899
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
942
+
943
943
+
[[package]]
944
944
+
name = "linux-raw-sys"
945
945
+
version = "0.12.1"
946
946
+
source = "registry+https://github.com/rust-lang/crates.io-index"
947
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
1043
+
"insta",
1001
1044
"serde",
1045
1045
+
"serde_json",
1002
1046
"serde_with",
1003
1047
]
1004
1048
···
1157
1201
checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92"
1158
1202
dependencies = [
1159
1203
"semver",
1204
1204
+
]
1205
1205
+
1206
1206
+
[[package]]
1207
1207
+
name = "rustix"
1208
1208
+
version = "1.1.4"
1209
1209
+
source = "registry+https://github.com/rust-lang/crates.io-index"
1210
1210
+
checksum = "b6fe4565b9518b83ef4f91bb47ce29620ca828bd32cb7e408f0062e9930ba190"
1211
1211
+
dependencies = [
1212
1212
+
"bitflags",
1213
1213
+
"errno",
1214
1214
+
"libc",
1215
1215
+
"linux-raw-sys",
1216
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
1405
+
1406
1406
+
[[package]]
1407
1407
+
name = "similar"
1408
1408
+
version = "2.7.0"
1409
1409
+
source = "registry+https://github.com/rust-lang/crates.io-index"
1410
1410
+
checksum = "bbbb5d9659141646ae647b42fe094daf6c6192d1620870b449d9557f748b2daa"
1348
1411
1349
1412
[[package]]
1350
1413
name = "slab"
···
1402
1465
checksum = "0bf256ce5efdfa370213c1dabab5935a12e49f2c58d15e9eac2870d3b4f27263"
1403
1466
1404
1467
[[package]]
1468
1468
+
name = "tempfile"
1469
1469
+
version = "3.26.0"
1470
1470
+
source = "registry+https://github.com/rust-lang/crates.io-index"
1471
1471
+
checksum = "82a72c767771b47409d2345987fda8628641887d5466101319899796367354a0"
1472
1472
+
dependencies = [
1473
1473
+
"fastrand",
1474
1474
+
"getrandom",
1475
1475
+
"once_cell",
1476
1476
+
"rustix",
1477
1477
+
"windows-sys 0.61.2",
1478
1478
+
]
1479
1479
+
1480
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
1843
+
version = "0.59.0"
1844
1844
+
source = "registry+https://github.com/rust-lang/crates.io-index"
1845
1845
+
checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b"
1846
1846
+
dependencies = [
1847
1847
+
"windows-targets 0.52.6",
1848
1848
+
]
1849
1849
+
1850
1850
+
[[package]]
1851
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
1771
-
"windows-targets",
1856
1856
+
"windows-targets 0.53.5",
1772
1857
]
1773
1858
1774
1859
[[package]]
···
1782
1867
1783
1868
[[package]]
1784
1869
name = "windows-targets"
1870
1870
+
version = "0.52.6"
1871
1871
+
source = "registry+https://github.com/rust-lang/crates.io-index"
1872
1872
+
checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973"
1873
1873
+
dependencies = [
1874
1874
+
"windows_aarch64_gnullvm 0.52.6",
1875
1875
+
"windows_aarch64_msvc 0.52.6",
1876
1876
+
"windows_i686_gnu 0.52.6",
1877
1877
+
"windows_i686_gnullvm 0.52.6",
1878
1878
+
"windows_i686_msvc 0.52.6",
1879
1879
+
"windows_x86_64_gnu 0.52.6",
1880
1880
+
"windows_x86_64_gnullvm 0.52.6",
1881
1881
+
"windows_x86_64_msvc 0.52.6",
1882
1882
+
]
1883
1883
+
1884
1884
+
[[package]]
1885
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
1790
-
"windows_aarch64_gnullvm",
1791
1791
-
"windows_aarch64_msvc",
1792
1792
-
"windows_i686_gnu",
1793
1793
-
"windows_i686_gnullvm",
1794
1794
-
"windows_i686_msvc",
1795
1795
-
"windows_x86_64_gnu",
1796
1796
-
"windows_x86_64_gnullvm",
1797
1797
-
"windows_x86_64_msvc",
1891
1891
+
"windows_aarch64_gnullvm 0.53.1",
1892
1892
+
"windows_aarch64_msvc 0.53.1",
1893
1893
+
"windows_i686_gnu 0.53.1",
1894
1894
+
"windows_i686_gnullvm 0.53.1",
1895
1895
+
"windows_i686_msvc 0.53.1",
1896
1896
+
"windows_x86_64_gnu 0.53.1",
1897
1897
+
"windows_x86_64_gnullvm 0.53.1",
1898
1898
+
"windows_x86_64_msvc 0.53.1",
1798
1899
]
1900
1900
+
1901
1901
+
[[package]]
1902
1902
+
name = "windows_aarch64_gnullvm"
1903
1903
+
version = "0.52.6"
1904
1904
+
source = "registry+https://github.com/rust-lang/crates.io-index"
1905
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
1915
+
version = "0.52.6"
1916
1916
+
source = "registry+https://github.com/rust-lang/crates.io-index"
1917
1917
+
checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469"
1918
1918
+
1919
1919
+
[[package]]
1920
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
1924
+
1925
1925
+
[[package]]
1926
1926
+
name = "windows_i686_gnu"
1927
1927
+
version = "0.52.6"
1928
1928
+
source = "registry+https://github.com/rust-lang/crates.io-index"
1929
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
1939
+
version = "0.52.6"
1940
1940
+
source = "registry+https://github.com/rust-lang/crates.io-index"
1941
1941
+
checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66"
1942
1942
+
1943
1943
+
[[package]]
1944
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
1951
+
version = "0.52.6"
1952
1952
+
source = "registry+https://github.com/rust-lang/crates.io-index"
1953
1953
+
checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66"
1954
1954
+
1955
1955
+
[[package]]
1956
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
1963
+
version = "0.52.6"
1964
1964
+
source = "registry+https://github.com/rust-lang/crates.io-index"
1965
1965
+
checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78"
1966
1966
+
1967
1967
+
[[package]]
1968
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
1975
+
version = "0.52.6"
1976
1976
+
source = "registry+https://github.com/rust-lang/crates.io-index"
1977
1977
+
checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d"
1978
1978
+
1979
1979
+
[[package]]
1980
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
1984
+
1985
1985
+
[[package]]
1986
1986
+
name = "windows_x86_64_msvc"
1987
1987
+
version = "0.52.6"
1988
1988
+
source = "registry+https://github.com/rust-lang/crates.io-index"
1989
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
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
23
+
review:
24
24
+
@cargo insta review --workspace
25
25
+
23
26
test:
24
24
-
@cargo test
27
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
9
+
10
10
+
[dev-dependencies]
11
11
+
insta.workspace = true
12
12
+
serde_json.workspace = true
+3
nara_text/tests/fixtures/keybind.json
···
1
1
+
{
2
2
+
"keybind": "key.inventory"
3
3
+
}
+7
nara_text/tests/fixtures/nbt_block.json
···
1
1
+
{
2
2
+
"source": "block",
3
3
+
"nbt": "foo",
4
4
+
"interpret": true,
5
5
+
"separator": ", ",
6
6
+
"block": "~ ~ ~"
7
7
+
}
+7
nara_text/tests/fixtures/nbt_entity.json
···
1
1
+
{
2
2
+
"source": "entity",
3
3
+
"nbt": "foo",
4
4
+
"interpret": true,
5
5
+
"separator": ", ",
6
6
+
"entity": "@p"
7
7
+
}
+7
nara_text/tests/fixtures/nbt_storage.json
···
1
1
+
{
2
2
+
"source": "storage",
3
3
+
"nbt": "foo",
4
4
+
"interpret": true,
5
5
+
"separator": ", ",
6
6
+
"storage": "minecraft:example"
7
7
+
}
+5
nara_text/tests/fixtures/object_atlas.json
···
1
1
+
{
2
2
+
"object": "atlas",
3
3
+
"atlas": "minecraft:blocks",
4
4
+
"sprite": "minecraft:stone"
5
5
+
}
+4
nara_text/tests/fixtures/object_player.json
···
1
1
+
{
2
2
+
"object": "player",
3
3
+
"player": "kokiriglade"
4
4
+
}
+18
nara_text/tests/fixtures/object_player_profile.json
···
1
1
+
{
2
2
+
"object": "player",
3
3
+
"player": {
4
4
+
"name": "kokiriglade",
5
5
+
"id": [452952, 452952, 459252, 459252],
6
6
+
"properties": [
7
7
+
{
8
8
+
"name": "textures",
9
9
+
"value": "foo",
10
10
+
"signature": "bar"
11
11
+
}
12
12
+
],
13
13
+
"texture": "minecraft:steve",
14
14
+
"cape": "minecraft:some_cape",
15
15
+
"model": "wide"
16
16
+
},
17
17
+
"hat": false
18
18
+
}
+6
nara_text/tests/fixtures/score.json
···
1
1
+
{
2
2
+
"score": {
3
3
+
"name": "@p",
4
4
+
"objective": "foo.bar"
5
5
+
}
6
6
+
}
+4
nara_text/tests/fixtures/selector.json
···
1
1
+
{
2
2
+
"selector": "@p",
3
3
+
"separator": ", "
4
4
+
}
+1
nara_text/tests/fixtures/text_plain.json
···
1
1
+
"Hello, World!"
+3
nara_text/tests/fixtures/text_tagged.json
···
1
1
+
{
2
2
+
"text": "Hello, World!"
3
3
+
}
+10
nara_text/tests/fixtures/translation.json
···
1
1
+
{
2
2
+
"translate": "foo.bar",
3
3
+
"fallback": "foo bar xyzzy",
4
4
+
"with": [
5
5
+
"foo",
6
6
+
{
7
7
+
"text": "bar"
8
8
+
}
9
9
+
]
10
10
+
}
+9
nara_text/tests/keybind.rs
···
1
1
+
use nara_text::Component;
2
2
+
3
3
+
const FIXTURE: &str = include_str!("fixtures/keybind.json");
4
4
+
5
5
+
#[test]
6
6
+
fn keybind() {
7
7
+
let parsed = serde_json::from_str::<Component>(FIXTURE).unwrap();
8
8
+
insta::assert_debug_snapshot!(parsed);
9
9
+
}
+23
nara_text/tests/nbt.rs
···
1
1
+
use nara_text::Component;
2
2
+
3
3
+
const BLOCK_FIXTURE: &str = include_str!("fixtures/nbt_block.json");
4
4
+
const ENTITY_FIXTURE: &str = include_str!("fixtures/nbt_entity.json");
5
5
+
const STORAGE_FIXTURE: &str = include_str!("fixtures/nbt_storage.json");
6
6
+
7
7
+
#[test]
8
8
+
fn block() {
9
9
+
let parsed = serde_json::from_str::<Component>(BLOCK_FIXTURE).unwrap();
10
10
+
insta::assert_debug_snapshot!(parsed);
11
11
+
}
12
12
+
13
13
+
#[test]
14
14
+
fn entity() {
15
15
+
let parsed = serde_json::from_str::<Component>(ENTITY_FIXTURE).unwrap();
16
16
+
insta::assert_debug_snapshot!(parsed);
17
17
+
}
18
18
+
19
19
+
#[test]
20
20
+
fn storage() {
21
21
+
let parsed = serde_json::from_str::<Component>(STORAGE_FIXTURE).unwrap();
22
22
+
insta::assert_debug_snapshot!(parsed);
23
23
+
}
+25
nara_text/tests/object.rs
···
1
1
+
use nara_text::Component;
2
2
+
3
3
+
const ATLAS_FIXTURE: &str = include_str!("fixtures/object_atlas.json");
4
4
+
const PLAYER_FIXTURE: &str = include_str!("fixtures/object_player.json");
5
5
+
const PLAYER_PROFILE_FIXTURE: &str =
6
6
+
include_str!("fixtures/object_player_profile.json");
7
7
+
8
8
+
#[test]
9
9
+
fn atlas() {
10
10
+
let parsed = serde_json::from_str::<Component>(ATLAS_FIXTURE).unwrap();
11
11
+
insta::assert_debug_snapshot!(parsed);
12
12
+
}
13
13
+
14
14
+
#[test]
15
15
+
fn player() {
16
16
+
let parsed = serde_json::from_str::<Component>(PLAYER_FIXTURE).unwrap();
17
17
+
insta::assert_debug_snapshot!(parsed);
18
18
+
}
19
19
+
20
20
+
#[test]
21
21
+
fn player_profile() {
22
22
+
let parsed =
23
23
+
serde_json::from_str::<Component>(PLAYER_PROFILE_FIXTURE).unwrap();
24
24
+
insta::assert_debug_snapshot!(parsed);
25
25
+
}
+9
nara_text/tests/score.rs
···
1
1
+
use nara_text::Component;
2
2
+
3
3
+
const FIXTURE: &str = include_str!("fixtures/score.json");
4
4
+
5
5
+
#[test]
6
6
+
fn score() {
7
7
+
let parsed = serde_json::from_str::<Component>(FIXTURE).unwrap();
8
8
+
insta::assert_debug_snapshot!(parsed);
9
9
+
}
+9
nara_text/tests/selector.rs
···
1
1
+
use nara_text::Component;
2
2
+
3
3
+
const FIXTURE: &str = include_str!("fixtures/selector.json");
4
4
+
5
5
+
#[test]
6
6
+
fn selector() {
7
7
+
let parsed = serde_json::from_str::<Component>(FIXTURE).unwrap();
8
8
+
insta::assert_debug_snapshot!(parsed);
9
9
+
}
+29
nara_text/tests/snapshots/keybind__keybind.snap
···
1
1
+
---
2
2
+
source: nara_text/tests/keybind.rs
3
3
+
expression: parsed
4
4
+
---
5
5
+
Object(
6
6
+
ComponentObject {
7
7
+
text: None,
8
8
+
translation: None,
9
9
+
score: None,
10
10
+
selector: None,
11
11
+
keybind: Some(
12
12
+
KeybindComponent {
13
13
+
keybind: "key.inventory",
14
14
+
},
15
15
+
),
16
16
+
nbt: None,
17
17
+
object: None,
18
18
+
formatting: ComponentFormatting {
19
19
+
color: None,
20
20
+
font: None,
21
21
+
bold: None,
22
22
+
italic: None,
23
23
+
underlined: None,
24
24
+
strikethrough: None,
25
25
+
obfuscated: None,
26
26
+
},
27
27
+
children: [],
28
28
+
},
29
29
+
)
+41
nara_text/tests/snapshots/nbt__block.snap
···
1
1
+
---
2
2
+
source: nara_text/tests/nbt.rs
3
3
+
expression: parsed
4
4
+
---
5
5
+
Object(
6
6
+
ComponentObject {
7
7
+
text: None,
8
8
+
translation: None,
9
9
+
score: None,
10
10
+
selector: None,
11
11
+
keybind: None,
12
12
+
nbt: Some(
13
13
+
NbtComponent {
14
14
+
source: Some(
15
15
+
Block,
16
16
+
),
17
17
+
path: "foo",
18
18
+
interpret: Some(
19
19
+
true,
20
20
+
),
21
21
+
separator: None,
22
22
+
entity: None,
23
23
+
block: Some(
24
24
+
"~ ~ ~",
25
25
+
),
26
26
+
storage: None,
27
27
+
},
28
28
+
),
29
29
+
object: None,
30
30
+
formatting: ComponentFormatting {
31
31
+
color: None,
32
32
+
font: None,
33
33
+
bold: None,
34
34
+
italic: None,
35
35
+
underlined: None,
36
36
+
strikethrough: None,
37
37
+
obfuscated: None,
38
38
+
},
39
39
+
children: [],
40
40
+
},
41
41
+
)
+41
nara_text/tests/snapshots/nbt__entity.snap
···
1
1
+
---
2
2
+
source: nara_text/tests/nbt.rs
3
3
+
expression: parsed
4
4
+
---
5
5
+
Object(
6
6
+
ComponentObject {
7
7
+
text: None,
8
8
+
translation: None,
9
9
+
score: None,
10
10
+
selector: None,
11
11
+
keybind: None,
12
12
+
nbt: Some(
13
13
+
NbtComponent {
14
14
+
source: Some(
15
15
+
Entity,
16
16
+
),
17
17
+
path: "foo",
18
18
+
interpret: Some(
19
19
+
true,
20
20
+
),
21
21
+
separator: None,
22
22
+
entity: Some(
23
23
+
"@p",
24
24
+
),
25
25
+
block: None,
26
26
+
storage: None,
27
27
+
},
28
28
+
),
29
29
+
object: None,
30
30
+
formatting: ComponentFormatting {
31
31
+
color: None,
32
32
+
font: None,
33
33
+
bold: None,
34
34
+
italic: None,
35
35
+
underlined: None,
36
36
+
strikethrough: None,
37
37
+
obfuscated: None,
38
38
+
},
39
39
+
children: [],
40
40
+
},
41
41
+
)
+41
nara_text/tests/snapshots/nbt__storage.snap
···
1
1
+
---
2
2
+
source: nara_text/tests/nbt.rs
3
3
+
expression: parsed
4
4
+
---
5
5
+
Object(
6
6
+
ComponentObject {
7
7
+
text: None,
8
8
+
translation: None,
9
9
+
score: None,
10
10
+
selector: None,
11
11
+
keybind: None,
12
12
+
nbt: Some(
13
13
+
NbtComponent {
14
14
+
source: Some(
15
15
+
Storage,
16
16
+
),
17
17
+
path: "foo",
18
18
+
interpret: Some(
19
19
+
true,
20
20
+
),
21
21
+
separator: None,
22
22
+
entity: None,
23
23
+
block: None,
24
24
+
storage: Some(
25
25
+
"minecraft:example",
26
26
+
),
27
27
+
},
28
28
+
),
29
29
+
object: None,
30
30
+
formatting: ComponentFormatting {
31
31
+
color: None,
32
32
+
font: None,
33
33
+
bold: None,
34
34
+
italic: None,
35
35
+
underlined: None,
36
36
+
strikethrough: None,
37
37
+
obfuscated: None,
38
38
+
},
39
39
+
children: [],
40
40
+
},
41
41
+
)
+34
nara_text/tests/snapshots/object__atlas.snap
···
1
1
+
---
2
2
+
source: nara_text/tests/object.rs
3
3
+
expression: parsed
4
4
+
---
5
5
+
Object(
6
6
+
ComponentObject {
7
7
+
text: None,
8
8
+
translation: None,
9
9
+
score: None,
10
10
+
selector: None,
11
11
+
keybind: None,
12
12
+
nbt: None,
13
13
+
object: Some(
14
14
+
Atlas(
15
15
+
AtlasObject {
16
16
+
atlas: Some(
17
17
+
"minecraft:blocks",
18
18
+
),
19
19
+
sprite: "minecraft:stone",
20
20
+
},
21
21
+
),
22
22
+
),
23
23
+
formatting: ComponentFormatting {
24
24
+
color: None,
25
25
+
font: None,
26
26
+
bold: None,
27
27
+
italic: None,
28
28
+
underlined: None,
29
29
+
strikethrough: None,
30
30
+
obfuscated: None,
31
31
+
},
32
32
+
children: [],
33
33
+
},
34
34
+
)
+34
nara_text/tests/snapshots/object__player.snap
···
1
1
+
---
2
2
+
source: nara_text/tests/object.rs
3
3
+
expression: parsed
4
4
+
---
5
5
+
Object(
6
6
+
ComponentObject {
7
7
+
text: None,
8
8
+
translation: None,
9
9
+
score: None,
10
10
+
selector: None,
11
11
+
keybind: None,
12
12
+
nbt: None,
13
13
+
object: Some(
14
14
+
Player(
15
15
+
PlayerObject {
16
16
+
player: Name(
17
17
+
"kokiriglade",
18
18
+
),
19
19
+
hat: None,
20
20
+
},
21
21
+
),
22
22
+
),
23
23
+
formatting: ComponentFormatting {
24
24
+
color: None,
25
25
+
font: None,
26
26
+
bold: None,
27
27
+
italic: None,
28
28
+
underlined: None,
29
29
+
strikethrough: None,
30
30
+
obfuscated: None,
31
31
+
},
32
32
+
children: [],
33
33
+
},
34
34
+
)
+67
nara_text/tests/snapshots/object__player_profile.snap
···
1
1
+
---
2
2
+
source: nara_text/tests/object.rs
3
3
+
expression: parsed
4
4
+
---
5
5
+
Object(
6
6
+
ComponentObject {
7
7
+
text: None,
8
8
+
translation: None,
9
9
+
score: None,
10
10
+
selector: None,
11
11
+
keybind: None,
12
12
+
nbt: None,
13
13
+
object: Some(
14
14
+
Player(
15
15
+
PlayerObject {
16
16
+
player: Profile(
17
17
+
PlayerProfile {
18
18
+
name: Some(
19
19
+
"kokiriglade",
20
20
+
),
21
21
+
id: Some(
22
22
+
[
23
23
+
452952,
24
24
+
452952,
25
25
+
459252,
26
26
+
459252,
27
27
+
],
28
28
+
),
29
29
+
properties: [
30
30
+
PlayerProfileProperty {
31
31
+
name: "textures",
32
32
+
value: "foo",
33
33
+
signature: Some(
34
34
+
"bar",
35
35
+
),
36
36
+
},
37
37
+
],
38
38
+
texture: Some(
39
39
+
"minecraft:steve",
40
40
+
),
41
41
+
cape: Some(
42
42
+
"minecraft:some_cape",
43
43
+
),
44
44
+
elytra: None,
45
45
+
model: Some(
46
46
+
Wide,
47
47
+
),
48
48
+
},
49
49
+
),
50
50
+
hat: Some(
51
51
+
false,
52
52
+
),
53
53
+
},
54
54
+
),
55
55
+
),
56
56
+
formatting: ComponentFormatting {
57
57
+
color: None,
58
58
+
font: None,
59
59
+
bold: None,
60
60
+
italic: None,
61
61
+
underlined: None,
62
62
+
strikethrough: None,
63
63
+
obfuscated: None,
64
64
+
},
65
65
+
children: [],
66
66
+
},
67
67
+
)
+30
nara_text/tests/snapshots/score__score.snap
···
1
1
+
---
2
2
+
source: nara_text/tests/score.rs
3
3
+
expression: parsed
4
4
+
---
5
5
+
Object(
6
6
+
ComponentObject {
7
7
+
text: None,
8
8
+
translation: None,
9
9
+
score: Some(
10
10
+
ScoreComponent {
11
11
+
name: "@p",
12
12
+
objective: "foo.bar",
13
13
+
},
14
14
+
),
15
15
+
selector: None,
16
16
+
keybind: None,
17
17
+
nbt: None,
18
18
+
object: None,
19
19
+
formatting: ComponentFormatting {
20
20
+
color: None,
21
21
+
font: None,
22
22
+
bold: None,
23
23
+
italic: None,
24
24
+
underlined: None,
25
25
+
strikethrough: None,
26
26
+
obfuscated: None,
27
27
+
},
28
28
+
children: [],
29
29
+
},
30
30
+
)
+34
nara_text/tests/snapshots/selector__selector.snap
···
1
1
+
---
2
2
+
source: nara_text/tests/selector.rs
3
3
+
expression: parsed
4
4
+
---
5
5
+
Object(
6
6
+
ComponentObject {
7
7
+
text: None,
8
8
+
translation: None,
9
9
+
score: None,
10
10
+
selector: Some(
11
11
+
SelectorComponent {
12
12
+
selector: "@p",
13
13
+
separator: Some(
14
14
+
String(
15
15
+
", ",
16
16
+
),
17
17
+
),
18
18
+
},
19
19
+
),
20
20
+
keybind: None,
21
21
+
nbt: None,
22
22
+
object: None,
23
23
+
formatting: ComponentFormatting {
24
24
+
color: None,
25
25
+
font: None,
26
26
+
bold: None,
27
27
+
italic: None,
28
28
+
underlined: None,
29
29
+
strikethrough: None,
30
30
+
obfuscated: None,
31
31
+
},
32
32
+
children: [],
33
33
+
},
34
34
+
)
+7
nara_text/tests/snapshots/text__plain.snap
···
1
1
+
---
2
2
+
source: nara_text/tests/text.rs
3
3
+
expression: parsed
4
4
+
---
5
5
+
String(
6
6
+
"Hello, World!",
7
7
+
)
+29
nara_text/tests/snapshots/text__tagged.snap
···
1
1
+
---
2
2
+
source: nara_text/tests/text.rs
3
3
+
expression: parsed
4
4
+
---
5
5
+
Object(
6
6
+
ComponentObject {
7
7
+
text: Some(
8
8
+
TextComponent {
9
9
+
text: "Hello, World!",
10
10
+
},
11
11
+
),
12
12
+
translation: None,
13
13
+
score: None,
14
14
+
selector: None,
15
15
+
keybind: None,
16
16
+
nbt: None,
17
17
+
object: None,
18
18
+
formatting: ComponentFormatting {
19
19
+
color: None,
20
20
+
font: None,
21
21
+
bold: None,
22
22
+
italic: None,
23
23
+
underlined: None,
24
24
+
strikethrough: None,
25
25
+
obfuscated: None,
26
26
+
},
27
27
+
children: [],
28
28
+
},
29
29
+
)
+62
nara_text/tests/snapshots/translation__translation.snap
···
1
1
+
---
2
2
+
source: nara_text/tests/translation.rs
3
3
+
expression: parsed
4
4
+
---
5
5
+
Object(
6
6
+
ComponentObject {
7
7
+
text: None,
8
8
+
translation: Some(
9
9
+
TranslationComponent {
10
10
+
translate: "foo.bar",
11
11
+
fallback: Some(
12
12
+
"foo bar xyzzy",
13
13
+
),
14
14
+
with: [
15
15
+
String(
16
16
+
"foo",
17
17
+
),
18
18
+
Object(
19
19
+
ComponentObject {
20
20
+
text: Some(
21
21
+
TextComponent {
22
22
+
text: "bar",
23
23
+
},
24
24
+
),
25
25
+
translation: None,
26
26
+
score: None,
27
27
+
selector: None,
28
28
+
keybind: None,
29
29
+
nbt: None,
30
30
+
object: None,
31
31
+
formatting: ComponentFormatting {
32
32
+
color: None,
33
33
+
font: None,
34
34
+
bold: None,
35
35
+
italic: None,
36
36
+
underlined: None,
37
37
+
strikethrough: None,
38
38
+
obfuscated: None,
39
39
+
},
40
40
+
children: [],
41
41
+
},
42
42
+
),
43
43
+
],
44
44
+
},
45
45
+
),
46
46
+
score: None,
47
47
+
selector: None,
48
48
+
keybind: None,
49
49
+
nbt: None,
50
50
+
object: None,
51
51
+
formatting: ComponentFormatting {
52
52
+
color: None,
53
53
+
font: None,
54
54
+
bold: None,
55
55
+
italic: None,
56
56
+
underlined: None,
57
57
+
strikethrough: None,
58
58
+
obfuscated: None,
59
59
+
},
60
60
+
children: [],
61
61
+
},
62
62
+
)
+16
nara_text/tests/text.rs
···
1
1
+
use nara_text::Component;
2
2
+
3
3
+
const PLAIN_FIXTURE: &str = include_str!("fixtures/text_plain.json");
4
4
+
const TAGGED_FIXTURE: &str = include_str!("fixtures/text_tagged.json");
5
5
+
6
6
+
#[test]
7
7
+
fn plain() {
8
8
+
let parsed = serde_json::from_str::<Component>(PLAIN_FIXTURE).unwrap();
9
9
+
insta::assert_debug_snapshot!(parsed);
10
10
+
}
11
11
+
12
12
+
#[test]
13
13
+
fn tagged() {
14
14
+
let parsed = serde_json::from_str::<Component>(TAGGED_FIXTURE).unwrap();
15
15
+
insta::assert_debug_snapshot!(parsed);
16
16
+
}
+9
nara_text/tests/translation.rs
···
1
1
+
use nara_text::Component;
2
2
+
3
3
+
const FIXTURE: &str = include_str!("fixtures/translation.json");
4
4
+
5
5
+
#[test]
6
6
+
fn translation() {
7
7
+
let parsed = serde_json::from_str::<Component>(FIXTURE).unwrap();
8
8
+
insta::assert_debug_snapshot!(parsed);
9
9
+
}