Here are all the little ways in which I’ve shored up A Place For My Head in the two months since the last instalment:

Something related to the last point that you won’t see directly but might feel the subtle effects of: I added tests. I’ve always believed in tests as a software developer, but the blog seemed like a special case. Two years later, I’m finally taking the time to verify the complex logic I’ve accreted, as well as simple things that I never bothered confirming. I wish I’d done this before, as it would have saved a lot of time even early on. At any rate, the list of passing tests is immensely satisfying:

> mocha



  :work
    ✔ should be processed correctly once parsed 1
    ✔ should be processed correctly once parsed 2
    ✔ should be processed correctly once parsed 3
    ✔ should be processed correctly once parsed 4
    ✔ should be processed correctly once parsed 5

  media
    isFloated works correctly
      ✔ {} → false
      ✔ {"attributes":{}} → false
      ✔ {"attributes":{"class":""}} → false
      ✔ {"attributes":{"class":"foo bar"}} → false
      ✔ {"attributes":{"class":"foo float--left"}} → true
      ✔ {"attributes":{"class":"float--right foo"}} → true
      ✔ {"attributes":{"class":"bar float--right foo"}} → true
    parseWidth works correctly
      ✔ "100w" → ["100","w"]
      ✔ "1w" → ["1","w"]
    image groups plugin
      ✔ buildImageSrc works: "1234" → "S/A/I/1234"
      ✔ getImageSizes works correctly
      ✔ buildImageElement works 1
      ✔ buildImageElement works 2
      ✔ buildPictureElement works 1
      ✔ buildPictureElement works 2
      ✔ buildFigureElement works 1
      ✔ buildSourceElement works 1
      ✔ buildSourceElement works 2
      ✔ convertToLinkElement works 1
      ✔ convertToLinkElement works 2

  rehype output
    ✔ spans should be created correctly
    ✔ can make lines 1
    ✔ can make lines 2
    ✔ can make lines 3
    ✔ can split lines 1

  text
    lab nodes are transformed correctly
      ✔ {"type":"element","attributes":{"path":"/"}} → {"attributes":{"path":"/"},"data":{"hName":"iframe","hProperties":{"class":"lab","src":"https://example.com/?bare=1"}},"type":"element"}
      ✔ {"type":"element","attributes":{"path":"/foo-bar/baz?quux=frob","class":["foo","bar"]}} → {"attributes":{"path":"/foo-bar/baz?quux=frob","class":["foo","bar"]},"data":{"hName":"iframe","hProperties":{"class":"lab foo bar","src":"https://some.site.dev/foo-bar/baz?quux=frob&bare=1"}},"type":"element"}

  compareLowercase
    ✔ should correctly compare strings 1: "a", "b", -1
    ✔ should correctly compare strings 2: "A", "b", -1
    ✔ should correctly compare strings 3: "B", "a", 1
    ✔ should correctly compare strings 4: "A", "a", 0
    ✔ should correctly compare strings 5: "a", "A", 0
    ✔ should correctly compare strings 6: "this AND that", "this and that", 0

  toTitlecase
    ✔ works correctly 1
    ✔ works correctly 2
    ✔ works correctly 3
    ✔ works correctly 4

  ordinalSuffix
    ✔ works correctly 1: 0, th
    ✔ works correctly 2: 1, st
    ✔ works correctly 3: 2, nd
    ✔ works correctly 4: 3, rd
    ✔ works correctly 5: 4, th
    ✔ works correctly 6: 10, th
    ✔ works correctly 7: 11, th
    ✔ works correctly 8: 20, th
    ✔ works correctly 9: 21, st
    ✔ works correctly 10: 100, th

  niceOrdinal
    without HTML
      ✔ works correctly 1: 0, zeroth
      ✔ works correctly 2: 1, first
      ✔ works correctly 3: 2, second
      ✔ works correctly 4: 3, third
      ✔ works correctly 5: 4, fourth
      ✔ works correctly 6: 10, 10th
      ✔ works correctly 7: 11, 11th
      ✔ works correctly 8: 20, 20th
      ✔ works correctly 9: 21, 21st
      ✔ works correctly 10: 100, 100th
    with HTML
      ✔ works correctly 1: 0, zeroth
      ✔ works correctly 2: 1, first
      ✔ works correctly 3: 2, second
      ✔ works correctly 4: 3, third
      ✔ works correctly 5: 4, fourth
      ✔ works correctly 6: 10, 10<sup class="ordinal">th</sup>
      ✔ works correctly 7: 11, 11<sup class="ordinal">th</sup>
      ✔ works correctly 8: 20, 20<sup class="ordinal">th</sup>
      ✔ works correctly 9: 21, 21<sup class="ordinal">st</sup>
      ✔ works correctly 10: 100, 100<sup class="ordinal">th</sup>

  asSeparatedList
    ✔ works correctly 1: [], undefined, undefined,
    ✔ works correctly 2: [], ",", "&",
    ✔ works correctly 3: ["a$"], ",", "&", a$
    ✔ works correctly 4: ["a,"], ",", "&", a,
    ✔ works correctly 5: ["a,","b"], ",", " &", a, &b
    ✔ works correctly 6: ["a,","bar","and baz"], ",", " &", a,,bar &and baz
    ✔ works correctly 7: ["foo","bar","baz"], ", ", " and ", foo, bar and baz
    ✔ works correctly 8: ["foo","bar","baz","quux"], ", ", " and ", foo, bar, baz and quux


  80 passing (31ms)

I also improved the accessibility testing I run as part of my build. I still want to add a test page with snapshots to ensure I don’t unwittingly alter the output of my custom Markdown directives. Then I might want some kind of CSS testing. I don’t know whether comparing screenshots will be useful there since they’ll change so often, but I’m not aware of a good alternative.

I really wish I could upgrade to Eleventy v2 for the sake of the WebC and Vite plugins. It irks me that I’m stymied by the long-abandoned esm’s inability to parse conditional chaining on the one hand and Eleventy’s lack of support for ECMAScript Modules on the other.

Regardless, that’s all for now. Expect an article soon about how I re-engineered code blocks. I could tell you another recent entry is of great relevance, but why spoil the fun?