mirror of
https://github.com/GetOpenScript/OpenScript.git
synced 2026-09-18 09:45:43 +00:00
Add optional script version metadata
This commit is contained in:
@@ -23,6 +23,7 @@ test('parseMeta extracts only OpenScript metadata', () => {
|
||||
|
||||
assert.deepEqual(meta, {
|
||||
name: 'Test Script',
|
||||
version: '2.1.0',
|
||||
description: 'Sample description',
|
||||
matches: ['https://example.com/*'],
|
||||
runAt: 'document_start',
|
||||
@@ -33,6 +34,7 @@ test('parseMeta extracts only OpenScript metadata', () => {
|
||||
test('parseMeta falls back to defaults when fields are missing', () => {
|
||||
const meta = parseMeta('// ==UserScript==\n// ==/UserScript==');
|
||||
assert.equal(meta.name, 'Untitled Script');
|
||||
assert.equal(meta.version, '');
|
||||
assert.equal(meta.description, '');
|
||||
assert.deepEqual(meta.matches, ['*://*/*']);
|
||||
assert.equal(meta.runAt, 'document_idle');
|
||||
@@ -137,6 +139,7 @@ test('getBoilerplate is wrapper-free and minimalist', () => {
|
||||
const template = getBoilerplate('My Script');
|
||||
assert.ok(template.includes('// @name My Script'));
|
||||
assert.ok(template.includes("console.log('Running on', location.hostname);"));
|
||||
for (const legacy of ['@namespace', '@grant', '@version', '@author', '(function'])
|
||||
for (const legacy of ['@namespace', '@grant', '@author', '(function'])
|
||||
assert.ok(!template.includes(legacy));
|
||||
assert.ok(!template.includes('@version'));
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user