Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

glossary.js 2.1 KB

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
  1. const loadSiteData = require('../../lib/site-data')
  2. describe('glossaries', () => {
  3. let glossaries
  4. beforeAll(async (done) => {
  5. glossaries = (await loadSiteData()).en.site.data.glossaries
  6. done()
  7. })
  8. test('are broken into external, internal, and candidates', async () => {
  9. const keys = Object.keys(glossaries)
  10. expect(keys).toHaveLength(3)
  11. expect(keys).toContain('candidates')
  12. expect(keys).toContain('external')
  13. expect(keys).toContain('internal')
  14. })
  15. test('every entry has a valid term', async () => {
  16. function hasValidTerm (entry) {
  17. return entry.term && entry.term.length && !entry.term.includes('*')
  18. }
  19. expect(glossaries.external.every(hasValidTerm)).toBe(true)
  20. expect(glossaries.internal.every(hasValidTerm)).toBe(true)
  21. expect(glossaries.candidates.every(hasValidTerm)).toBe(true)
  22. })
  23. test('external glossary has entries, and they all have descriptions', async () => {
  24. expect(glossaries.external.length).toBeGreaterThan(20)
  25. glossaries.external.forEach(entry => {
  26. const message = `entry '${entry.term}' is missing a description`
  27. expect(entry.description && entry.description.length > 0, message).toBe(true)
  28. })
  29. })
  30. test('internal glossary has entries, and they all have descriptions', async () => {
  31. expect(glossaries.internal.length).toBeGreaterThan(20)
  32. glossaries.internal.forEach(entry => {
  33. const message = `entry '${entry.term}' is missing a description`
  34. expect(entry.description && entry.description.length > 0, message).toBe(true)
  35. })
  36. })
  37. test('non-English external glossary is in correct order', async () => {
  38. const vals = (await loadSiteData()).ja.site.data.glossaries.external
  39. vals.forEach((val, i) => {
  40. expect(val.term.localeCompare(vals[i + 1], 'ja')).toBeGreaterThan(0)
  41. })
  42. })
  43. test('candidates all have a term, but no description', async () => {
  44. expect(glossaries.candidates.length).toBeGreaterThan(20)
  45. glossaries.candidates.forEach(entry => {
  46. const message = `entry '${entry.term}' not expected to have a description`
  47. expect(!entry.description, message).toBe(true)
  48. })
  49. })
  50. })
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...