test-article-reading-data.mjs 1.5 KB

1234567891011121314151617181920212223242526
  1. import assert from 'node:assert/strict'
  2. import { readFile } from 'node:fs/promises'
  3. const unitId = 'SHEP-5-上-Unit2'
  4. const topicUrl = new URL('../src/views/Editor/EnglishSpeaking/data/topicDiscussionTasks.json', import.meta.url)
  5. const articleUrl = new URL('../src/views/Editor/EnglishSpeaking/data/articleReadingTasks.json', import.meta.url)
  6. const topics = JSON.parse(await readFile(topicUrl, 'utf8'))
  7. const articles = JSON.parse(await readFile(articleUrl, 'utf8'))
  8. assert.equal(topics[unitId].length, 4)
  9. assert.ok(topics[unitId].every(task => task.taskType === 'topic-discussion'))
  10. assert.equal(articles[unitId].length, 1)
  11. const article = articles[unitId][0]
  12. assert.equal(article.id, 'ar-unit2-zoo')
  13. assert.equal(article.taskType, 'article-reading')
  14. assert.equal(article.titleEn, 'A Day at the Zoo')
  15. assert.equal(article.durationMinutes, 10)
  16. // 标题只住在 titleEn 里,**不再重复进正文**(2026-07-26 起)——
  17. // 正文第一段就是第一段朗读内容,否则学生第一次录音录的是标题。
  18. assert.ok(!article.content.startsWith(article.titleEn), 'title must not be duplicated into content')
  19. assert.ok(article.content.startsWith('Last Sunday'))
  20. assert.ok(article.content.endsWith('I learned many things about animals.'))
  21. // 首尾由上面两条断言守住;这条只兜住"中段被删",故用宽松下限而非精确值——
  22. // 正文允许正常修订,但不该缩水到只剩几段。(enspeak 原文实测 829 字符。)
  23. assert.ok(article.content.length > 700, 'full demo article must not be truncated')