Skip to content

Commit

Permalink
Add skeleton code for tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tfukaza committed Jul 14, 2024
1 parent 082643d commit d1b0de5
Show file tree
Hide file tree
Showing 13 changed files with 7,030 additions and 1,429 deletions.
4 changes: 4 additions & 0 deletions demo/react/src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ export default function App() {
slBackground.current,
slSelection.current,
);
handleSelectNode(null, "constant");
handleSelectNode(null, "constant");
handleSelectNode(null, "math");
handleSelectNode(null, "print");
}, []);

function typeToNode(node) {
Expand Down
17 changes: 0 additions & 17 deletions demo/react/vite.config.js

This file was deleted.

15 changes: 15 additions & 0 deletions demo/react/vite.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";

export default defineConfig(({ command, mode }) => {
return {
plugins: [react()],
server: {
port: 3002,
open: false,
strictPort: true,

preTransformRequests: false,
},
};
});
14 changes: 12 additions & 2 deletions demo/vanilla/demo.js → demo/vanilla/demo.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@ import SnapLine from "./lib/snapline.mjs";
const sl = new SnapLine("node-editor");

let addNodeMenu = null;
let themeMenu = null;

document.addEventListener("DOMContentLoaded", function () {
addNodeMenu = document.getElementById("addNodeButton");
themeMenu = document.getElementById("themeButton");

document
.getElementById("addNodeButton")
Expand All @@ -34,6 +32,11 @@ document.addEventListener("DOMContentLoaded", function () {
console.debug("initSnapLine", canvasContainer, canvas, background, selection);

sl.initSnapLine(canvasContainer, canvas, background, selection);

addNodeAuto("node-constant", -250, -150);
addNodeAuto("node-constant", -250, 0);
addNodeAuto("node-math", 0, -150);
addNodeAuto("node-print", 250, -150);
});

document.addEventListener("click", function (e) {
Expand All @@ -48,6 +51,13 @@ function toggleMenu(e, id) {
e.stopPropagation();
}

function addNodeAuto(name, x, y) {
let ele = document.createElement(name);
let node = sl.createNode(ele);
ele.initComponent(node);
sl.addNode(node, x, y);
}

function addNode(e, name) {
// Create a new Web Component element based on the node type
let ele = document.createElement(name);
Expand Down
4 changes: 2 additions & 2 deletions demo/vanilla/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset=" UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>SnapLineJS</title>
<title>SnapLine: Vanilla Js</title>
<link rel="stylesheet" href="demo.css" />

<link
Expand Down Expand Up @@ -85,7 +85,7 @@
</template>

<body>
<script type="module" src="demo.js" defer></script>
<script type="module" src="demo.mjs" defer></script>

<main>
<div id="sl-canvas-container" style="width: 100%; height: 100vh">
Expand Down
15 changes: 0 additions & 15 deletions demo/vanilla/vite.config.js

This file was deleted.

12 changes: 12 additions & 0 deletions demo/vanilla/vite.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { defineConfig } from "vite";

export default defineConfig(({ command, mode }) => {
return {
server: {
port: 3001,
open: false,
strictPort: true, // Enforce port since tests rely on it
preTransformRequests: false,
},
};
});
7 changes: 7 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/ @type {import('jest').Config} */;
const config = {
preset: "jest-puppeteer",
// Other Jest configurations...
};

module.exports = config;
Loading

0 comments on commit d1b0de5

Please sign in to comment.