@@ -2158,3 +2158,56 @@ describe('roxy-dasha-timeline heads correctly with no period attribute', () => {
21582158 el . remove ( ) ;
21592159 } ) ;
21602160} ) ;
2161+
2162+ /**
2163+ * Tarot spread heading. Same failure class as the dasha timeline: the label used
2164+ * to come from the `spread` ATTRIBUTE, whose default is `three-card`, so a host
2165+ * that cannot set attributes (the WordPress plugin) headed every reading "three
2166+ * card" including a yes or no cast. The API also sends `spread: null` on several
2167+ * casts, so the response field alone is not enough either.
2168+ */
2169+ describe ( 'roxy-tarot-spread titles itself from the response' , ( ) => {
2170+ async function mount ( data : unknown ) {
2171+ const el = document . createElement ( 'roxy-tarot-spread' ) as HTMLElement & {
2172+ data ?: unknown ;
2173+ } ;
2174+ document . body . appendChild ( el ) ;
2175+ el . data = data ;
2176+ await settled ( el ) ;
2177+ return el ;
2178+ }
2179+ const title = ( el : Element ) =>
2180+ el . shadowRoot ?. querySelector ( '.title' ) ?. textContent ?. trim ( ) ?? '' ;
2181+
2182+ test ( 'a yes or no cast is not headed "three card"' , async ( ) => {
2183+ const el = await mount ( {
2184+ question : 'Should I take the new job' ,
2185+ answer : 'Yes' ,
2186+ strength : 'Strong' ,
2187+ spread : null ,
2188+ card : { name : 'The Star' , orientation : 'upright' } ,
2189+ } ) ;
2190+ expect ( title ( el ) ) . toBe ( 'Yes or no' ) ;
2191+ el . remove ( ) ;
2192+ } ) ;
2193+
2194+ test ( 'a named spread is used and capitalised' , async ( ) => {
2195+ const el = await mount ( {
2196+ spread : 'celtic cross' ,
2197+ question : 'What about work' ,
2198+ positions : [ { position : 'Present' , card : { name : 'The Star' } } ] ,
2199+ } ) ;
2200+ expect ( title ( el ) ) . toBe ( 'Celtic cross' ) ;
2201+ el . remove ( ) ;
2202+ } ) ;
2203+
2204+ test ( 'a null spread falls back without rendering an empty heading' , async ( ) => {
2205+ const el = await mount ( {
2206+ spread : null ,
2207+ question : 'What about work' ,
2208+ positions : [ { position : 'Present' , card : { name : 'The Star' } } ] ,
2209+ } ) ;
2210+ expect ( title ( el ) ) . toBe ( 'Three card' ) ;
2211+ el . remove ( ) ;
2212+ } ) ;
2213+ } ) ;
0 commit comments