tiny_jest_examplemain.tsx7 matches
4import { expect, prettify, Test } from "https://esm.sh/tiny-jest@1.1.1";
56function App() {
7const [valUrl, setValUrl] = useState("");
8const [testCode, setTestCode] = useState("");
56}
5758function client() {
59createRoot(document.getElementById("root")).render(<App />);
60}
64}
6566export default async function server(request: Request): Promise<Response> {
67if (request.method === "POST" && new URL(request.url).pathname === "/run-tests") {
68const { valUrl, testCode } = await request.json();
70try {
71const userVal = await import(valUrl);
72const userFunction = userVal.default;
7374const { it, run } = new Test("User Tests");
7576// Create a function to safely evaluate the user's test code
77const safeEval = (code: string) => {
78return new Function("it", "expect", "userFunction", code);
79};
8081// Run the user's test code
82safeEval(testCode)(it, expect, userFunction);
8384const results = await run();
fizzBuzzTestmain.tsx22 matches
45const fizzBuzzTest = `
6// Test the FizzBuzz function
7function runFizzBuzzTests(fizzBuzz) {
8const tests = [
9{ name: "Return type", test: () => {
9293try {
94let fizzBuzzFunction;
95if (typeof module.default === 'function') {
96fizzBuzzFunction = module.default;
97} else if (typeof module === 'function') {
98fizzBuzzFunction = module;
99} else {
100throw new Error('The module does not export a function');
101}
102const testResults = runFizzBuzzTests(fizzBuzzFunction);
103return JSON.stringify(testResults, null, 2);
104} catch (error) {
107`;
108109function App() {
110const [valUrl, setValUrl] = useState("");
111const [results, setResults] = useState(null);
132<h2>Problem Statement:</h2>
133<p>
134Write a function that returns an array of 100 elements (1 to 100 inclusive). The function should do the following:
135</p>
136<ul>
141</ul>
142<p>
143Export this function as the default export of your module.
144</p>
145</div>
180<li>Verify that the module is publicly accessible.</li>
181<li>Check if there are any CORS issues preventing the module from being imported.</li>
182<li>Make sure your function is exported as the default export or as the module itself.</li>
183</ul>
184)}
197}
198199function client() {
200createRoot(document.getElementById("root")).render(<App />);
201}
205}
206207async function runTests(valUrl: string, testCode: string) {
208try {
209let module;
215}
216217let testFunction;
218try {
219testFunction = new Function("module", testCode);
220} catch (functionError) {
221console.error("Function creation error:", functionError);
222throw new Error(`Failed to create test function: ${functionError.message}`);
223}
224225let testResults;
226try {
227testResults = testFunction(module);
228} catch (testError) {
229console.error("Test execution error:", testError);
250}
251252export default async function server(request: Request): Promise<Response> {
253if (request.method === "POST" && new URL(request.url).pathname === "/run-tests") {
254const { valUrl, testCode } = await request.json();
12// check for multiples of three, five, and both.
1314function FizzBuzz();
15{
16let result = [];
39// FizzBuzz();
4041// function test() {
42// let result = [];
43// let count = 0;
58// test();
5960// function test() {
61// let result = [];
62// let count = 0;
cors_examplemain.tsx2 matches
5const BASE_URL = "https://stevekrouse-cors_example_backend.web.val.run";
67export function App() {
8const [logs, setLogs] = useState([]);
9async function request(url, options) {
10try {
11const response = await fetch(url, options);
bandcampWrappedmain.tsx1 match
1export default async function(req: Request): Promise<Response> {
2return new Response(
3`
bandcampWrappedScriptmain.tsx3 matches
14]
1516function esc(string) {
17return replacements.reduce(function(string, replacement) {
18return string.replace(replacement[0], replacement[1])
19}, string)
71)
7273function c(tag, style) {
74const elem = document.createElement(tag)
75if (style) elem.style = style
AboutNoelandLiammain.tsx4 matches
3import { createRoot } from "https://esm.sh/react-dom/client";
45function FAQ({ question, answer }) {
6const [isOpen, setIsOpen] = useState(false);
730}
3132function GallagherArticle() {
33const faqs = [
34{
133}
134135function client() {
136createRoot(document.getElementById("root")).render(<GallagherArticle />);
137}
139if (typeof document !== "undefined") { client(); }
140141export default async function server(request: Request): Promise<Response> {
142return new Response(`
143<html>
OasisDiscographymain.tsx6 matches
134];
135136function ExternalLinks() {
137return (
138<div className="external-links">
159}
160161function BandIntroduction() {
162return (
163<div className="band-introduction">
188}
189190function AlbumCard({ album }) {
191return (
192<div className="album-card">
206}
207208function App() {
209return (
210<div className="oasis-discography">
224}
225226function client() {
227createRoot(document.getElementById("root")).render(<App />);
228}
229if (typeof document !== "undefined") { client(); }
230231export default async function handler(request: Request): Promise<Response> {
232return new Response(`
233<html>
blueskyPostButtonmain.tsx3 matches
4import { createRoot } from "https://esm.sh/react-dom/client";
56function App() {
7const [message, setMessage] = useState("");
8const [status, setStatus] = useState("");
82}
8384function client() {
85createRoot(document.getElementById("root")).render(<App />);
86}
87if (typeof document !== "undefined") { client(); }
8889export default async function server(request: Request): Promise<Response> {
90if (request.method === "POST" && new URL(request.url).pathname === "/post-bluesky") {
91try {
curiousCyanWalrusmain.tsx1 match
23// Fetches a random joke.
4function fetchRandomJoke() {
5const response = fetch(
6"https://official-joke-api.appspot.com/random_joke",