Edge Rewrite
// HTMLRewriter · presentation

This page was redesigned at the edge.

Cloudflare fetched the original article and streamed it through HTMLRewriter to apply an entirely new visual system without rebuilding the source page.

Jump to content

Module:Goban/accessibility/testcases

From Wikipedia, the free encyclopedia
-- Unit tests for [[Module:Goban/accessibility]]. Click talk page to run tests.
local p = require('Module:UnitTests')

local a11y = require('Module:Goban/accessibility')

local function grid(rows, cols, codes)
	return function(r, c) return codes[(r - 1) * cols + c] or '' end
end

function p:test_empty_board()
	self:equals('empty 5x5', a11y.describe(5, 5, grid(5, 5, {})), 'Go board, 5 by 5, empty.')
	self:equals('edges and hoshi are silent',
		a11y.describe(2, 2, grid(2, 2, { 'ul', 'ur', '-', 'x' })), 'Go board, 2 by 2, empty.')
end

function p:test_stones_and_marks()
	self:equals('stones', a11y.describe(2, 2, grid(2, 2, { 'b', 'w', '', 'bT' })),
		'Go board, 2 by 2. Black stones: A2, B1. White stones: B2. Marks: triangle on black stone at B1.')
	self:equals('marks', a11y.describe(1, 4, grid(1, 4, { 'A', 'X', '-c', 'wS' })),
		'Go board, 1 by 4. White stones: D1. Marks: letter A at A1; X at B1; circle at C1; square on white stone at D1.')
end

function p:test_moves()
	self:equals('moves in order', a11y.describe(1, 4, grid(1, 4, { '02', 'w3', '01', 'b2' })),
		'Go board, 1 by 4. Moves: 1 black C1; 2 black D1; 2 white A1; 3 white B1.')
	self:equals('three digits', a11y.describe(1, 2, grid(1, 2, { '250', '101' })),
		'Go board, 1 by 2. Moves: 101 black B1; 250 white A1.')
end

function p:test_unknown_code()
	self:equals('escaped', a11y.describe(1, 1, grid(1, 1, { 'b<x>' })),
		'Go board, 1 by 1. Marks: b&#60;x&#62; tile at A1.')
end

function p:test_description()
	self:equals('generated', a11y.description(nil, 1, 1, grid(1, 1, {})),
		'<span class="sr-only">Go board, 1 by 1, empty.</span>')
	self:equals('alt', a11y.description(nil, 1, 1, grid(1, 1, {}), '  A ladder.  '),
		'<span class="sr-only">A ladder.</span>')
end

return p