advanced-defaults.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. var t = require('assert')
  2. module.exports = ({advanced}) => {
  3. before(async () => {
  4. await advanced.bringToFront()
  5. })
  6. it('access to file URLs', async () => {
  7. t.strictEqual(
  8. await advanced.evaluate(() =>
  9. state.file
  10. ),
  11. true,
  12. 'state.file should be true'
  13. )
  14. })
  15. it('header detection', async () => {
  16. t.strictEqual(
  17. await advanced.evaluate(() =>
  18. state.header
  19. ),
  20. true,
  21. 'state.header should be true'
  22. )
  23. })
  24. it('allowed origins', async () => {
  25. t.deepStrictEqual(
  26. await advanced.evaluate(() =>
  27. state.origins
  28. ),
  29. {
  30. 'file://': {
  31. match: '\\.(?:markdown|mdown|mkdn|md|mkd|mdwn|mdtxt|mdtext|text)(?:#.*|\\?.*)?$',
  32. csp: false,
  33. encoding: ''
  34. }
  35. },
  36. 'state.origins should contain the file:// origin'
  37. )
  38. t.equal(
  39. await advanced.evaluate(() =>
  40. document.querySelectorAll('.m-list li').length
  41. ),
  42. 1,
  43. 'should contain only one origin'
  44. )
  45. t.equal(
  46. await advanced.evaluate(() =>
  47. document.querySelector('.m-list li:nth-of-type(1) .m-origin').innerText
  48. ),
  49. 'file://',
  50. 'origin name should be file://'
  51. )
  52. t.equal(
  53. await advanced.evaluate(() =>
  54. document.querySelector('.m-list li:nth-of-type(1) .m-match input').value
  55. ),
  56. '\\.(?:markdown|mdown|mkdn|md|mkd|mdwn|mdtxt|mdtext|text)(?:#.*|\\?.*)?$',
  57. 'the text input should contain the default path matching regexp'
  58. )
  59. })
  60. }