Skip to content

Commit

Permalink
chore: rfc-index.txt minor tidyups
Browse files Browse the repository at this point in the history
  • Loading branch information
holloway committed Jan 16, 2025
1 parent b88bc96 commit 851934c
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 30 deletions.
5 changes: 4 additions & 1 deletion client/utilities/rfc-index-txt.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { DateTime } from 'luxon'
import { padStart } from 'lodash-es'
import type { ApiClient, RfcMetadata } from '~/generated/red-client'
import { SPACE } from './strings'
import type { ApiClient, RfcMetadata } from '~/generated/red-client'

// Note: this file is intentionally named rfc-index-txt.ts not rfc-index.txt.ts
// because vitest can't import that later filename

const COLUMN_PADDING = 1

Expand Down
28 changes: 26 additions & 2 deletions client/utilities/rfc-index.txt.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,33 @@
import fs from 'node:fs'
import path from 'node:path'
import { vi, describe, beforeEach, afterEach, test, expect } from 'vitest'
import { renderRfcIndexDotTxt } from './rfc-index-txt'
import { splitLinesAt, renderRfcIndexDotTxt } from './rfc-index-txt'
import { ApiClient, SlugEnum } from '~/generated/red-client'

const paragraph =
'Obsoletes xxxx refers to other RFCs that this one replaces; Obsoleted by xxxx refers to RFCs that have replaced this one. Updates xxxx refers to other RFCs that this one merely updates (but does not replace);'

test('splitWordsAt: 40', () => {
expect(splitLinesAt(paragraph, 40)).toEqual([
'Obsoletes xxxx refers to other RFCs that',
'this one replaces; Obsoleted by xxxx',
'refers to RFCs that have replaced this',
'one. Updates xxxx refers to other RFCs',
'that this one merely updates (but does',
'not replace);'
])
})

test('splitWordsAt: 50', () => {
expect(splitLinesAt(paragraph, 50)).toEqual([
'Obsoletes xxxx refers to other RFCs that this one',
'replaces; Obsoleted by xxxx refers to RFCs that',
'have replaced this one. Updates xxxx refers to',
'other RFCs that this one merely updates (but does',
'not replace);'
])
})

const originalFormatting = fs
.readFileSync(path.join(import.meta.dirname, 'rfc-index.txt'), 'utf-8')
.toString()
Expand Down Expand Up @@ -66,7 +90,7 @@ describe('renderRfcIndexDotTxt', () => {

const str = await streamWrapper()

expect(str.length).toBeGreaterThan(originalFormattingUntilRfc13.length)
expect(originalFormattingUntilRfc13.length).toBe(str.length)

// test rendering against a wget of the existing rfc-index.txt truncated to RFC0013
expect(str.substring(0, originalFormattingUntilRfc13.length)).toEqual(
Expand Down
27 changes: 0 additions & 27 deletions client/utilities/strings.test.ts

This file was deleted.

0 comments on commit 851934c

Please sign in to comment.