Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/components/RequestAuthForm/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@
display: flex;
align-items: center;
justify-content: center;
}
}
34 changes: 13 additions & 21 deletions src/components/RequestAuthForm/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,29 +41,21 @@ const ApiKeyAuthForm = (props: AuthFormsProps) => {

const onAuthKeyChange = (event: React.ChangeEvent<HTMLInputElement>) => {
setAuthKey(event.target.value);
props.onCredentialsChange({key: event.target.value, value: authValue});
}
props.onCredentialsChange({ key: event.target.value, value: authValue });
};

const onAuthValueChange = (event: React.ChangeEvent<HTMLInputElement>) => {
setAuthValue(event.target.value);
props.onCredentialsChange({key: authKey, value: event.target.value});
}
return <div className="authentication-form horizontal">
<input
value={authKey}
className="input"
placeholder="Key"
onChange={onAuthKeyChange}
/>
<span className="keyValueSeparator">:</span>
<input
value={authValue}
className="input"
placeholder="Value"
onChange={onAuthValueChange}
/>
</div>;
}
props.onCredentialsChange({ key: authKey, value: event.target.value });
};
return (
<div className="authentication-form horizontal">
<input value={authKey} className="input" placeholder="Key" onChange={onAuthKeyChange} />
<span className="keyValueSeparator">:</span>
<input value={authValue} className="input" placeholder="Value" onChange={onAuthValueChange} />
</div>
);
};

const RequestAuthForm = (props: RequestAuthFormProps) => {
if (props.authType == AuthType.NoAuth) {
Expand All @@ -72,7 +64,7 @@ const RequestAuthForm = (props: RequestAuthFormProps) => {
if (props.authType == AuthType.BasicAuth) {
return <BasicAuthForm onCredentialsChange={props.onCredentialsChange} />;
}
return <ApiKeyAuthForm onCredentialsChange={props.onCredentialsChange}/>
return <ApiKeyAuthForm onCredentialsChange={props.onCredentialsChange} />;
};

export default RequestAuthForm;
12 changes: 6 additions & 6 deletions tests/components/Editor.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { describe, it, expect, vi, beforeEach } from 'vitest';
import Editor from '../../src/components/Editor';
import '@testing-library/jest-dom';

vi.spyOn(console, 'log').mockImplementation(() => {});

vi.mock('react-ace', () => ({
default: ({
className,
Expand Down Expand Up @@ -112,23 +114,21 @@ describe('Editor Component', () => {
});

it('should render JsonViewer when readOnly is true and log correct message', () => {
const consoleSpy = vi.spyOn(console, 'log').mockImplementation(() => {});
vi.clearAllMocks();
render(<Editor readOnly={true} initialValue={mockJsonValue} />);

expect(consoleSpy).toHaveBeenCalledWith('Read only Editor loaded!');
consoleSpy.mockRestore();
expect(console.log).toHaveBeenCalledWith('Read only Editor loaded!');
});
});

describe('JsonEditor (Editable mode)', () => {
it('should render JsonEditor when readOnly is false and log correct message', () => {
const consoleSpy = vi.spyOn(console, 'log').mockImplementation(() => {});
vi.clearAllMocks();
render(
<Editor readOnly={false} initialValue={mockJsonValue} onValueChange={mockOnValueChange} />
);

expect(consoleSpy).toHaveBeenCalledWith('Editor loaded!');
consoleSpy.mockRestore();
expect(console.log).toHaveBeenCalledWith('Editor loaded!');
});

it('should display the initial value in editable mode', () => {
Expand Down