Skip to content

Commit

Permalink
Tests improved, Editor loading text overflow fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
TeaByte committed Jan 21, 2024
1 parent 9aa53b3 commit bc9de91
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 7 deletions.
12 changes: 7 additions & 5 deletions components/EditorSplit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@ export default function EditorSplit(props: { slug: string }) {
dir="ltr"
id="editor"
>
<p
<div
id="editor-loading"
class="flex h-full items-center justify-center text-lg rounded-btn text-base-content"
class="overflow-hidden flex justify-center items-center h-full"
>
جاري تحميل المحرر
<span class="loading loading-lg ml-2"></span>
</p>
<p class="flex h-full items-center justify-center text-lg rounded-btn text-base-content">
جاري تحميل المحرر
<span class="loading loading-lg ml-2"></span>
</p>
</div>
</div>
</div>
</div>
Expand Down
23 changes: 21 additions & 2 deletions islands/Editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,12 @@ export default function Editor(props: EditorProps) {
const [output, setOutput] = useState<string>("");
const [isError, setIsError] = useState<boolean>(false);

const [numberOfTest, setNumberOfTest] = useState<number>(1);
const [testing, setTesting] = useState<boolean>(false);
const [isTestPassed, setIsTestPassed] = useState<boolean | undefined>(
undefined,
);

const { showToast } = useToast();

function handleCodeClear() {
Expand All @@ -58,6 +60,22 @@ export default function Editor(props: EditorProps) {
// deno-lint-ignore prefer-const
let msg = "هناك خطأ في الاختبارات";
try {
try {
eval(code);
} catch (e) {
setTesting(false);
setIsTestPassed(false);
setNumberOfTest(numberOfTest + 1);
setIsError(true);
showToast({
msg: "هناك خطأ في الكود",
type: "error",
});
setOutput(`[Test Failed, ${numberOfTest}]\n${e}`);
return;
}

setIsError(false);
eval(props.testingCode);
if (isPass) {
let courseSlug: string;
Expand All @@ -82,7 +100,7 @@ export default function Editor(props: EditorProps) {
type: "success",
});
newPassSignal.value = newPassSignal.value + 1;
setOutput("تم تجاوز الاختبارات بنجاح");
setOutput("[Test Passed] -> تم تجاوز الاختبارات بنجاح");
setIsTestPassed(true);
setTesting(false);
return;
Expand All @@ -91,9 +109,10 @@ export default function Editor(props: EditorProps) {
msg,
type: "error",
});
setOutput(`${msg}`);
setOutput(`[Test Failed, ${numberOfTest}] -> ${msg}`);
setIsTestPassed(false);
setTesting(false);
setNumberOfTest(numberOfTest + 1);
return;
}
} catch (error) {
Expand Down

0 comments on commit bc9de91

Please sign in to comment.