import assert from 'node:assert/strict'; import { test } from 'node:test'; import { install, nodes, server, settle } from './flow-helpers.mjs'; install(); const { globalRulesCard, regexDocs } = await import('../../bindery/static/js/rules.js'); const SYNTAX = 'https://docs.python.org/3/library/re.html#regular-expression-syntax'; const HOWTO = 'https://docs.python.org/3/howto/regex.html'; const links = (root) => nodes(root).filter((el) => el.tagName === 'a').map((a) => [a.textContent, a.attributes.href]); test('the rule hints link the regular expression syntax and an introduction', async (t) => { const backend = server(t); backend.on('GET', 'rules', { rules: [], paragraphs: null, global_paragraphs: false }); backend.on('GET', 'stories', []); const card = globalRulesCard(); await settle(); const expected = [['Python regular expressions', SYNTAX], ['introduction', HOWTO]]; assert.deepEqual(links(card).filter(([, href]) => href.startsWith('https://docs.python.org/')), expected); const [syntax] = regexDocs(); assert.equal(syntax.attributes.target, '_blank'); assert.equal(syntax.attributes.rel, 'noreferrer noopener'); });