Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,17 @@ jobs:
- run: npm test
- run: npm run test:integration-issues

test-templates:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Use Node.js 24
uses: actions/setup-node@v4
with:
node-version: 24
- run: npm install
- run: npm run test:templates

testint:
runs-on: ubuntu-latest
# only run if not a fork PR targeting main repo due to permissions
Expand Down
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,6 @@ When using EJS templates for your meeting issues, the following data properties
'Australia/Sydney'
]; %>

# <%= title %>

## Date/Time

| Timezone | Date/Time |
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"test:integration": "standard && mocha test/integration.js",
"test:integration:debug": "GITHUB_TOKEN=$(gh auth token) mocha --inspect --inspect-brk test/integration.js",
"test:integration-issues": "standard && mocha test/integration-issues.js",
"test:templates": "standard && mocha test/templates.js",
"lint:fix": "standard --fix",
"preversion": "npm t",
"postpublish": "git push origin && git push origin --tags",
Expand Down
64 changes: 64 additions & 0 deletions test/templates.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
'use strict'
/* global Temporal */
const fs = require('fs')
const path = require('path')
const ejs = require('ejs')
const { suite, test } = require('mocha')
const assert = require('assert')
if (!global.Temporal) {
const polyfill = require('@js-temporal/polyfill')
global.Temporal = polyfill.Temporal
}

const testData = {
date: Temporal.Instant.from('2024-01-01T12:00:00Z'),
agendaIssues: [
{ html_url: 'https://example.com/issue/1', title: 'issue 1' },
{ html_url: 'https://example.com/issue/2', title: 'issue 2' }
],
agendaLabel: 'meeting-agenda',
meetingNotes: 'https://example.com/notes',
owner: 'test-owner',
repo: 'test-repo',
meetingLink: 'https://meet.example.com',
title: 'Ye Olde Meetinge'
}

const readme = fs.readFileSync(path.join(__dirname, '../README.md'), 'utf8')
const defaultTemplate = require('../lib/default-template')
const mdTemplate = fs.readFileSync(path.join(__dirname, '../.github/ISSUE_TEMPLATE/meeting.md'), 'utf8')

const compiledMd = ejs.render(mdTemplate, testData)
const compiledDefault = defaultTemplate(testData)
const readmeTemplate = getReadmeTemplate()

suite('template consistency', () => {
test('default template should match md template', () => {
const normalizedMd = normalizeOutput(compiledMd)
const normalizedDefault = normalizeOutput(compiledDefault)

assert.strictEqual(normalizedMd, normalizedDefault)
})

test('readme template should match md template', () => {
const normalizedReadme = normalizeOutput(readmeTemplate)
const normalizedMd = normalizeOutput(mdTemplate)

assert.strictEqual(normalizedReadme, normalizedMd)
})
})

function normalizeOutput (content) {
return content.trim()
}

function getReadmeTemplate () {
const ejsStart = readme.indexOf('```ejs')
const ejsEnd = readme.indexOf('```', ejsStart + 6)

if (ejsStart < 0 || ejsEnd < 0) {
throw new Error('couldn\'t find ejs template section in readme')
}

return readme.substring(ejsStart + 6, ejsEnd)
}