Skip to content

Commit

Permalink
Merge pull request #346 from ashik-75/work
Browse files Browse the repository at this point in the history
fix test , update code formatter
  • Loading branch information
lifeparticle authored Oct 6, 2023
2 parents 0042dbe + 89d2291 commit 6412c77
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 35 deletions.
6 changes: 6 additions & 0 deletions ui/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
### [6.3.0] - 2023-10-03

- Fix Test
- update design & maintain consistency
- Enable code formatter for JSX code

### [6.3.0] - 2023-10-03

- Update code editor
- update base64 and json to typescript

Expand Down
4 changes: 2 additions & 2 deletions ui/src/pages/Converter/Base64/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const Base64: React.FC = () => {
status={status}
label="Text"
code={input}
language="json"
language={" "}
handleCode={(value) => {
setInput(value || "");
onClick("encode", value || "");
Expand All @@ -53,7 +53,7 @@ const Base64: React.FC = () => {
status={status}
label="Base64"
code={result}
language="json"
language={" "}
handleCode={(value) => {
setResult(value || "");
onClick("decode", value || "");
Expand Down
10 changes: 2 additions & 8 deletions ui/src/pages/Converter/Base64/tests/base64.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { render, screen } from "@testing-library/react";
import { describe } from "vitest";
import user from "@testing-library/user-event";
import Base64 from "pages/Converter/Base64";

describe("BASE64", () => {
Expand All @@ -11,13 +10,8 @@ describe("BASE64", () => {
test("textbox", async () => {
render(<Base64 />);

const TEXT = "hello";
const outputLabel = screen.getByText(/base64/i);

const textInputArea = screen.getByPlaceholderText(/decoded text/i);
expect(textInputArea).toBeInTheDocument();

await user.type(textInputArea, TEXT);

expect(textInputArea).toHaveValue(TEXT);
expect(outputLabel).toBeInTheDocument();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,17 @@
height: 100%;

&_warning {
min-height: 375px;
min-height: 500px;
display: flex;
flex-direction: column;
justify-content: center;
}

// xl(1280px)
@media screen and (min-width: 1280px) {
&_warning {
min-height: 600px;
}
}
}
}
5 changes: 2 additions & 3 deletions ui/src/pages/Converter/CodeFormatter/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ const CodeFormatter: React.FC = () => {
const formatCode = () => {
try {
const options = {
indent_size: Number(indentationLevel),
indent_size: indentationLevel,
indent_with_tabs: indentationLevel === "tab" ? true : false,
e4x: true,
};

const selectedBeautifyFunction =
Expand Down Expand Up @@ -76,8 +77,6 @@ const CodeFormatter: React.FC = () => {
label="Enter code"
/>

<br />

<Space>
<ResponsiveButton
onClick={formatCode}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,20 @@
}

&__output {
min-height: 424px;
height: 100%;

&_warning {
min-height: 375px;
min-height: 500px;
display: flex;
flex-direction: column;
justify-content: center;
}

// xl(1280px)
@media screen and (min-width: 1280px) {
&_warning {
min-height: 600px;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,36 +10,23 @@ describe("JsonToTs", () => {
test("render json textfield", () => {
render(<JsonToTypescript key={101} />);

const JsonTextbox = screen.getByPlaceholderText("JSON");
expect(JsonTextbox).toBeInTheDocument();

const rootInterfacenameInput = screen.getByPlaceholderText(
"Enter Interface name"
);
expect(rootInterfacenameInput).toBeInTheDocument();
});

test("generates interfaces on button click", () => {
test("show initial warning text", () => {
render(<JsonToTypescript key={101} />);

const jsonTextarea = screen.getByPlaceholderText("JSON");
fireEvent.change(jsonTextarea, {
target: { value: '{"key": "value"}' },
});

const interfaceInput =
screen.getByPlaceholderText(/Enter Interface name/i);
const ROOT_INTERFACE_NAME = "MyInterface";

fireEvent.change(interfaceInput, {
target: { value: ROOT_INTERFACE_NAME },
});
const warningText = screen.getByText(
/There is no data for JSON, please provide data first./i
);

const convertButton = screen.getByText("Convert");
fireEvent.click(convertButton);

const getValueOfType = screen.getByText(/string/i);

expect(getValueOfType).toBeInTheDocument();
expect(warningText).toBeInTheDocument();
expect(convertButton).toBeInTheDocument();
});
});

0 comments on commit 6412c77

Please sign in to comment.