adapt-authoring-docs 1.3.0 → 1.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -23,7 +23,7 @@ function generateSectionTitle (sectionName) {
23
23
  export default async function docsify (app, configs, outputdir, defaultPages) {
24
24
  const dir = path.resolve(outputdir, 'manual')
25
25
  const sectionsConf = app.config.get('adapt-authoring-docs.manualSections')
26
- const defaultSection = Object.entries(sectionsConf).reduce((m, [id, data]) => data.default ? id : m)
26
+ const defaultSection = Object.entries(sectionsConf).find(([, data]) => data.default)?.[0]
27
27
  /**
28
28
  * init docsify folder
29
29
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "adapt-authoring-docs",
3
- "version": "1.3.0",
3
+ "version": "1.3.1",
4
4
  "description": "Tools for auto-generating documentation for the Adapt authoring tool",
5
5
  "homepage": "https://github.com/adapt-security/adapt-authoring-docs",
6
6
  "license": "GPL-3.0",
@@ -205,18 +205,7 @@ describe('docsify', () => {
205
205
  })
206
206
 
207
207
  describe('bugs', () => {
208
- it('TODO: defaultSection reduce with single entry returns array tuple instead of string', async () => {
209
- // BUG: In docsify.js line 26, Object.entries(sectionsConf).reduce((m, [id, data]) => ...)
210
- // has no initial value. When there is only one section entry, reduce() returns
211
- // the entry itself (an [id, data] array) without calling the callback.
212
- // This causes generateSectionTitle to fail with:
213
- // TypeError: sectionName.slice(...).replaceAll is not a function
214
- // because sectionName is an array, not a string.
215
- //
216
- // To fix: add an initial value to reduce, e.g.:
217
- // Object.entries(sectionsConf).reduce((m, [id, data]) => data.default ? id : m, undefined)
218
- // or use Array.find instead:
219
- // Object.entries(sectionsConf).find(([, data]) => data.default)?.[0]
208
+ it('defaultSection reduce with single entry returns string section name', async () => {
220
209
  tmpDir = await fs.mkdtemp(path.join(os.tmpdir(), 'docsify-test-'))
221
210
  const outputDir = tmpDir
222
211
  const docsSrcDir = await fs.mkdtemp(path.join(os.tmpdir(), 'docsify-src-'))
@@ -238,10 +227,8 @@ describe('docsify', () => {
238
227
  }]
239
228
 
240
229
  const { default: docsify } = await import('../docsify/docsify.js')
241
- // This should work but fails due to the bug described above
242
- await assert.rejects(
243
- () => docsify(mockApp, configs, outputDir, {}),
244
- TypeError
230
+ await assert.doesNotReject(
231
+ () => docsify(mockApp, configs, outputDir, {})
245
232
  )
246
233
 
247
234
  await fs.rm(docsSrcDir, { recursive: true, force: true })