import { describe, expect, it } from 'vitest' import { anchor, hiding } from './table' /** * The two rules a table follows that nothing on the screen reports. * * Both fail silently. A detail row addressed by a string carrying a space is * markup a browser accepts and a screen reader cannot follow, and a query * blamed for an empty venue is a sentence that reads as data. Neither throws, * neither is visible in a screenshot, and both were reachable from the example * this component ships with. */ describe('anchor', () => { it('leaves no space in an address, whatever a row is identified by', () => { // `aria-controls` is a list separated by spaces, so a pair naming itself // the way a venue does named four ids and reached none of them. expect(anchor('t1', 'LUX / USDC')).not.toMatch(/\s/) expect(anchor('t1', 'Example Token for Specimen')).not.toMatch(/\s/) }) it('gives two rows two addresses, and one row the same one twice', () => { // The control and the row it opens each write this, and they agree only // because it is one function. expect(anchor('t1', 'LUX / USDC')).toBe(anchor('t1', 'LUX / USDC')) expect(anchor('t1', 'LUX / USDC')).not.toBe(anchor('t1', 'LUX / USDT')) // Encoded rather than stripped: two identities that differ only in a space // would otherwise land on one address. expect(anchor('t1', 'a b')).not.toBe(anchor('t1', 'a-b')) }) it('gives two tables of the same thing two sets of addresses', () => { expect(anchor('t1', 'LUX / USDC')).not.toBe(anchor('t2', 'LUX / USDC')) }) }) describe('hiding', () => { it('blames the query only where there are rows for it to hide', () => { expect(hiding('usdc', 3)).toBe(true) }) it('does not blame the query for a venue that holds nothing', () => { // "No market matches that" over a venue with no market says markets exist. // The venue's own sentence is the true one. expect(hiding('usdc', 0)).toBe(false) }) it('does not blame a query nobody typed', () => { expect(hiding('', 0)).toBe(false) expect(hiding('', 3)).toBe(false) }) })