This commit is contained in:
Alie 2024-04-27 18:17:56 +02:00
parent 0c1de423ef
commit 42ca60c026
8 changed files with 57 additions and 50 deletions

View File

@ -2,17 +2,17 @@ module.exports = {
root: true,
env: { browser: true, es2020: true },
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:react-hooks/recommended',
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:react-hooks/recommended",
],
ignorePatterns: ['dist', '.eslintrc.cjs'],
parser: '@typescript-eslint/parser',
plugins: ['react-refresh'],
ignorePatterns: ["dist", ".eslintrc.cjs"],
parser: "@typescript-eslint/parser",
plugins: ["react-refresh"],
rules: {
'react-refresh/only-export-components': [
'warn',
"react-refresh/only-export-components": [
"warn",
{ allowConstantExport: true },
],
},
}
};

View File

@ -6,4 +6,4 @@ COPY . /temp/prod/
RUN cd /temp/prod && bun run build
FROM nginx AS release
COPY --from=install /temp/prod/dist /usr/share/nginx/html
COPY --from=install /temp/prod/dist /usr/share/nginx/html

View File

@ -1,13 +1,20 @@
<!doctype html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link
rel="icon"
type="image/svg+xml"
href="/vite.svg" />
<meta
name="viewport"
content="width=device-width, initial-scale=1.0" />
<title>Vite + React + TS</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
<script
type="module"
src="/src/main.tsx"></script>
</body>
</html>

View File

@ -1,10 +1,10 @@
db = new Mongo().getDB("bot");
db.createCollection('authorizations');
db.createCollection("authorizations");
db.authorizations.insert([
{
app: "tester",
secret: "test"
}
])
{
app: "tester",
secret: "test",
},
]);

View File

@ -1,8 +1,8 @@
export interface ButtonProps {
label: string;
action?: () => void;
label: string;
action?: () => void;
}
export default function ImageViewer(props: ButtonProps) {
return <button onClick={props.action}>{props.label}</button>
}
return <button onClick={props.action}>{props.label}</button>;
}

View File

@ -1,7 +1,5 @@
import ReactDOM from 'react-dom/client'
import App from './App.tsx'
import './index.css'
import ReactDOM from "react-dom/client";
import App from "./App.tsx";
import "./index.css";
ReactDOM.createRoot(document.getElementById('root')!).render(
<App />
)
ReactDOM.createRoot(document.getElementById("root")!).render(<App />);

View File

@ -1,29 +1,31 @@
import React from "react";
import { render, screen } from "@testing-library/react";
import { describe, expect, it } from "bun:test";
import ImageModerator, { ImageModeratorProps } from '../../src/components/ImageModerator/ImageModerator';
import ImageModerator, {
ImageModeratorProps,
} from "../../src/components/ImageModerator/ImageModerator";
const properties: ImageModeratorProps = {
acceptLabel: "Accept",
discardLabel: "Discard"
}
acceptLabel: "Accept",
discardLabel: "Discard",
};
it("should render into the document", () => {
render(<ImageModerator {...properties} />);
render(<ImageModerator {...properties} />);
});
it("should show a new image when accept button is clicked", () => {
const acceptButton = screen.getByText(properties.acceptLabel);
const imgElement = screen.getByRole("img");
const imgElementSrcBefore = imgElement.getAttribute("src");
acceptButton.click();
expect(imgElement.getAttribute("src")).not.toEqual(imgElementSrcBefore);
const acceptButton = screen.getByText(properties.acceptLabel);
const imgElement = screen.getByRole("img");
const imgElementSrcBefore = imgElement.getAttribute("src");
acceptButton.click();
expect(imgElement.getAttribute("src")).not.toEqual(imgElementSrcBefore);
});
it("should show a new image when discard button is clicked", () => {
const discardButton = screen.getByText(properties.discardLabel);
const imgElement = screen.getByRole("img");
const imgElementSrcBefore = imgElement.getAttribute("src");
discardButton.click();
expect(imgElement.getAttribute("src")).not.toEqual(imgElementSrcBefore);
});
const discardButton = screen.getByText(properties.discardLabel);
const imgElement = screen.getByRole("img");
const imgElementSrcBefore = imgElement.getAttribute("src");
discardButton.click();
expect(imgElement.getAttribute("src")).not.toEqual(imgElementSrcBefore);
});

View File

@ -1,7 +1,7 @@
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react-swc'
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react-swc";
// https://vitejs.dev/config/
export default defineConfig({
plugins: [react()]
})
plugins: [react()],
});