script.test.js 982 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import test from 'tape';
  2. import { parseMeta } from '#/background/utils/script';
  3. const baseMeta = {
  4. include: [],
  5. exclude: [],
  6. match: [],
  7. excludeMatch: [],
  8. require: [],
  9. grant: [],
  10. resources: {},
  11. noframes: false,
  12. };
  13. test('parseMeta', (t) => {
  14. t.deepEqual(parseMeta(`\
  15. // ==UserScript==
  16. // @name New Script
  17. // @namespace Violentmonkey Scripts
  18. // @description This is a script
  19. // @version 1.0
  20. // @match *://*/*
  21. // @grant none
  22. // ==/UserScript==
  23. `), Object.assign({}, baseMeta, {
  24. name: 'New Script',
  25. namespace: 'Violentmonkey Scripts',
  26. description: 'This is a script',
  27. version: '1.0',
  28. match: ['*://*/*'],
  29. grant: ['none'],
  30. }));
  31. t.deepEqual(parseMeta(`\
  32. // ==UserScript==
  33. // @name New Script
  34. // @namespace Violentmonkey Scripts
  35. // @match *://*/*
  36. // @noframes
  37. // ==/UserScript==
  38. `), Object.assign({}, baseMeta, {
  39. name: 'New Script',
  40. namespace: 'Violentmonkey Scripts',
  41. match: ['*://*/*'],
  42. noframes: true,
  43. }));
  44. t.end();
  45. });