版博士V2.0程序
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import { resolve, dirname } from "node:path";
  2. import { renderPlop } from "./render.js";
  3. import { fileURLToPath } from "node:url";
  4. const __dirname = dirname(fileURLToPath(import.meta.url));
  5. test("should load ESM file", async () => {
  6. const { findByText, userEvent } = await renderPlop([], {
  7. cwd: resolve(__dirname, "./examples/esm"),
  8. });
  9. expect(await findByText("What is your name?")).toBeInTheConsole();
  10. userEvent.keyboard("Joe");
  11. expect(await findByText("Joe")).toBeInTheConsole();
  12. userEvent.keyboard("[Enter]");
  13. });
  14. test("should load MJS file", async () => {
  15. const { findByText, userEvent } = await renderPlop([], {
  16. cwd: resolve(__dirname, "./examples/mjs"),
  17. });
  18. expect(await findByText("What is your name?")).toBeInTheConsole();
  19. userEvent.keyboard("Joe");
  20. expect(await findByText("Joe")).toBeInTheConsole();
  21. userEvent.keyboard("[Enter]");
  22. });
  23. test("should load CJS file", async () => {
  24. const { findByText, userEvent } = await renderPlop([], {
  25. cwd: resolve(__dirname, "./examples/cjs"),
  26. });
  27. expect(await findByText("What is your name?")).toBeInTheConsole();
  28. userEvent.keyboard("Joe");
  29. expect(await findByText("Joe")).toBeInTheConsole();
  30. userEvent.keyboard("[Enter]");
  31. });
  32. test("should load JS module='commonjs' file", async () => {
  33. const { findByText, userEvent } = await renderPlop([], {
  34. cwd: resolve(__dirname, "./examples/cjs-js"),
  35. });
  36. expect(await findByText("What is your name?")).toBeInTheConsole();
  37. userEvent.keyboard("Joe");
  38. expect(await findByText("Joe")).toBeInTheConsole();
  39. userEvent.keyboard("[Enter]");
  40. });