👁️
5
fork

Configure Feed

Select the types of activity you want to include in your feed.

enhance tests

+64 -3
+64 -3
src/lib/__tests__/richtext-convert.test.ts
··· 1837 1837 .tuple(arbText, arbMarkSet) 1838 1838 .map(([text, marks]) => schema.text(text, marks)); 1839 1839 1840 - // Arbitrary for paragraph content (1-5 text nodes) 1841 - const arbParagraphContent = fc.array(arbTextNode, { 1840 + // Arbitrary for mention node 1841 + const arbMention = fc 1842 + .tuple( 1843 + fc 1844 + .string({ minLength: 1, maxLength: 20 }) 1845 + .filter((s) => !s.includes(" ")), 1846 + fc.string({ minLength: 10, maxLength: 30 }), 1847 + ) 1848 + .map(([handle, did]) => 1849 + schema.nodes.mention.create({ handle, did: `did:plc:${did}` }), 1850 + ); 1851 + 1852 + // Arbitrary for cardRef node (scryfall IDs are UUIDs, names can have unicode) 1853 + const arbCardName = fc.oneof( 1854 + fc.string({ minLength: 1, maxLength: 30 }), 1855 + fc.constant("Lightning Bolt"), 1856 + fc.constant("Jötun Grunt"), // non-ASCII 1857 + fc.constant("Fire // Ice"), // split card 1858 + fc.constant("闪电击"), // Chinese (Lightning Bolt) 1859 + fc.constant("בָּרָק"), // Hebrew (lightning) - RTL 1860 + fc.constant("صاعقة"), // Arabic (thunderbolt) - RTL 1861 + ); 1862 + const arbCardRef = fc 1863 + .tuple(arbCardName, fc.uuid()) 1864 + .map(([name, scryfallId]) => 1865 + schema.nodes.cardRef.create({ name, scryfallId }), 1866 + ); 1867 + 1868 + // Arbitrary for tag node (include unicode to catch byte offset bugs) 1869 + const arbTagText = fc.oneof( 1870 + fc.string({ minLength: 1, maxLength: 30 }), 1871 + fc.constant("日本語"), // Japanese 1872 + fc.constant("🎉party"), // emoji 1873 + fc.constant("café"), // accented 1874 + fc.constant("组合技"), // Chinese (combo) 1875 + fc.constant("תקציב"), // Hebrew (budget) - RTL 1876 + fc.constant("ميزانية"), // Arabic (budget) - RTL 1877 + ); 1878 + const arbTag = arbTagText.map((tag) => schema.nodes.tag.create({ tag })); 1879 + 1880 + // Arbitrary for any inline node (text with marks, or atom nodes) 1881 + const arbInlineNode = fc.oneof( 1882 + { weight: 5, arbitrary: arbTextNode }, 1883 + { weight: 1, arbitrary: arbMention }, 1884 + { weight: 1, arbitrary: arbCardRef }, 1885 + { weight: 1, arbitrary: arbTag }, 1886 + ); 1887 + 1888 + // Arbitrary for paragraph content (1-5 inline nodes, including atoms) 1889 + const arbParagraphContent = fc.array(arbInlineNode, { 1890 + minLength: 1, 1891 + maxLength: 5, 1892 + }); 1893 + 1894 + // Arbitrary for text-only paragraph content (no atoms - for text-specific tests) 1895 + const arbTextOnlyParagraphContent = fc.array(arbTextNode, { 1842 1896 minLength: 1, 1843 1897 maxLength: 5, 1844 1898 }); ··· 1952 2006 .map((blocks) => schema.node("doc", null, blocks)); 1953 2007 1954 2008 // Arbitrary for documents with only text blocks (for text-specific property tests) 1955 - const arbTextBlock = fc.oneof(arbParagraph, arbHeading); 2009 + // These use text-only content (no atom nodes like mentions/cardRefs/tags) 2010 + const arbTextOnlyParagraph = arbTextOnlyParagraphContent.map((content) => 2011 + schema.node("paragraph", null, content), 2012 + ); 2013 + const arbTextOnlyHeading = fc 2014 + .tuple(arbHeadingLevel, arbTextOnlyParagraphContent) 2015 + .map(([level, content]) => schema.node("heading", { level }, content)); 2016 + const arbTextBlock = fc.oneof(arbTextOnlyParagraph, arbTextOnlyHeading); 1956 2017 const arbTextOnlyDocument = fc 1957 2018 .array(arbTextBlock, { minLength: 1, maxLength: 5 }) 1958 2019 .map((blocks) => schema.node("doc", null, blocks));