mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-11-05 03:08:13 +00:00
Highlighted code blocks inside the app (#1153)
This commit is contained in:
1 parent
0b42c0288e
commit
f4a86c2fb8
60 files changed
+2550
-41
No files matched your search
@@ -0,0 +1,21 @@
|
||||
using AIStudio.Tools.CodeHighlighting.Languages;
|
||||
|
||||
namespace AIStudio.Tests.Tools.CodeHighlighting;
|
||||
|
||||
[TestFixture]
|
||||
public sealed class JavaScriptCodeRulesTests
|
||||
{
|
||||
[TestCase("import { useState } from 'react';", "{keyword:import} { useState } {keyword:from} {string:'react'};")]
|
||||
[TestCase("const add = (a, b) => a + b;", "{keyword:const} add = (a, b) => a + b;")]
|
||||
[TestCase("function greet(name) { return `Hi ${name}`; }", "{keyword:function} {function:greet}(name) { {keyword:return} {string:`Hi ${name}`}; }")]
|
||||
[TestCase("class Dog extends Animal {}", "{keyword:class} {type:Dog} {keyword:extends} Animal {}")]
|
||||
[TestCase("if (x === null || y === undefined) console.log(NaN);", "{keyword:if} (x === {literal:null} || y === {literal:undefined}) console.{function:log}({literal:NaN});")]
|
||||
[TestCase("let $el = $('#id');", "{keyword:let} $el = {function:$}({string:'#id'});")]
|
||||
[TestCase("const n = 0xFF + 1e3 + 10n;", "{keyword:const} n = {number:0xFF} + {number:1e3} + {number:10n};")]
|
||||
[TestCase("// note /* not a block */", "{comment:// note /* not a block */}")]
|
||||
[TestCase("@Component class A {}", "{meta:@Component} {keyword:class} {type:A} {}")]
|
||||
public void JavaScriptGetsItsColors(string code, string expected)
|
||||
{
|
||||
Assert.That(CodeMarkup.Of(code, JavaScriptCodeRules.RULES), Is.EqualTo(expected));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user