defaults-options.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. origins.state.file
  10. ),
  11. true,
  12. 'origins.state.file should be true'
  13. )
  14. })
  15. it('header detection', async () => {
  16. t.strictEqual(
  17. await advanced.evaluate(() =>
  18. origins.state.header
  19. ),
  20. true,
  21. 'origins.state.header should be true'
  22. )
  23. t.strictEqual(
  24. await advanced.evaluate(() =>
  25. document.querySelector('.m-switch')
  26. ),
  27. null,
  28. 'header detection switch should be hidden'
  29. )
  30. })
  31. it('allowed origins', async () => {
  32. t.deepStrictEqual(
  33. await advanced.evaluate(() =>
  34. origins.state.origins
  35. ),
  36. {
  37. 'file://': {
  38. match: '\\.(?:markdown|mdown|mkdn|md|mkd|mdwn|mdtxt|mdtext|text)(?:#.*|\\?.*)?$',
  39. csp: false,
  40. encoding: ''
  41. }
  42. },
  43. 'origins.state.origins should contain the file:// origin'
  44. )
  45. t.equal(
  46. await advanced.evaluate(() =>
  47. document.querySelectorAll('.m-origins .m-list li').length
  48. ),
  49. 1,
  50. 'should contain only one origin'
  51. )
  52. t.equal(
  53. await advanced.evaluate(() =>
  54. document.querySelector('.m-origins .m-list li:nth-of-type(1) .m-title').innerText
  55. ),
  56. 'file://',
  57. 'origin name should be file://'
  58. )
  59. t.equal(
  60. await advanced.evaluate(() =>
  61. document.querySelector('.m-list li:nth-of-type(1) .m-match input').value
  62. ),
  63. '\\.(?:markdown|mdown|mkdn|md|mkd|mdwn|mdtxt|mdtext|text)(?:#.*|\\?.*)?$',
  64. 'the text input should contain the default path matching regexp'
  65. )
  66. })
  67. }