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

octicon.js 1.7 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
  1. const renderContent = require('../../lib/render-content')
  2. describe('octicon tag', () => {
  3. it('renders the expected octicon', async () => {
  4. const actual = await renderContent('{% octicon "check" %}')
  5. expect(actual).toContain('<svg ')
  6. expect(actual).toContain('class="octicon octicon-check"')
  7. })
  8. it('renders the expected octicon with an option', async () => {
  9. const actual = await renderContent('{% octicon "check" width="64" %}')
  10. expect(actual).toContain('<svg ')
  11. expect(actual).toContain('class="octicon octicon-check"')
  12. expect(actual).toContain('width="64"')
  13. })
  14. it('renders the expected octicon with multiple options', async () => {
  15. const actual = await renderContent('{% octicon "check" width="64" aria-label="A checkmark" %}')
  16. expect(actual).toContain('<svg ')
  17. expect(actual).toContain('class="octicon octicon-check"')
  18. expect(actual).toContain('width="64"')
  19. expect(actual).toContain('aria-label="A checkmark"')
  20. })
  21. it('uses label to set aria-label', async () => {
  22. const actual = await renderContent('{% octicon "check" label="A checkmark" %}')
  23. expect(actual).toContain('<svg ')
  24. expect(actual).toContain('class="octicon octicon-check"')
  25. expect(actual).toContain('aria-label="A checkmark"')
  26. })
  27. it('throws an error with invalid syntax', async () => {
  28. await expect(renderContent('{% octicon 123 %}')).rejects
  29. .toThrowError('Syntax Error in tag \'octicon\' - Valid syntax: octicon "<name>" <key="value">')
  30. })
  31. it('throws an error with a non-existant octicon', async () => {
  32. await expect(renderContent('{% octicon "pizza-patrol" %}')).rejects
  33. .toThrowError('Octicon pizza-patrol does not exist')
  34. })
  35. })
Tip!

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

Comments

Loading...