feat: release OpsXShell 2.1.0 native Tauri edition
This commit is contained in:
1 parent
e9a0d21758
commit
a3dba0c6ed
311 files changed
+31748
-14897
No files matched your search
@@ -0,0 +1,38 @@
|
||||
import { describe, it, expect } from 'vitest'
|
||||
import { expandSnippetVariables } from '../../src/utils/snippetVariables'
|
||||
import { applyKeywordHighlights, DEFAULT_KEYWORD_HIGHLIGHT_RULES } from '../../src/utils/keywordHighlight'
|
||||
|
||||
describe('expandSnippetVariables', () => {
|
||||
it('replaces known placeholders', () => {
|
||||
const out = expandSnippetVariables('ssh {{username}}@{{host}}:{{port}}', {
|
||||
username: 'root',
|
||||
host: '10.0.0.1',
|
||||
port: 22,
|
||||
})
|
||||
expect(out).toBe('ssh root@10.0.0.1:22')
|
||||
})
|
||||
|
||||
it('uses default when missing', () => {
|
||||
const out = expandSnippetVariables('cd {{path:/tmp}}', {})
|
||||
expect(out).toBe('cd /tmp')
|
||||
})
|
||||
|
||||
it('keeps unknown placeholders without default', () => {
|
||||
const out = expandSnippetVariables('echo {{unknown}}', {})
|
||||
expect(out).toBe('echo {{unknown}}')
|
||||
})
|
||||
})
|
||||
|
||||
describe('applyKeywordHighlights', () => {
|
||||
it('highlights error keywords', () => {
|
||||
const out = applyKeywordHighlights('FATAL error happened', DEFAULT_KEYWORD_HIGHLIGHT_RULES)
|
||||
expect(out).toContain('\x1b[')
|
||||
expect(out).toContain('FATAL')
|
||||
})
|
||||
|
||||
it('returns original when disabled rules only', () => {
|
||||
const rules = DEFAULT_KEYWORD_HIGHLIGHT_RULES.map((r) => ({ ...r, enabled: false }))
|
||||
const text = 'no highlight'
|
||||
expect(applyKeywordHighlights(text, rules)).toBe(text)
|
||||
})
|
||||
})
|
||||
Reference in new issue
Block a user