Just a whole lot of crap
This commit is contained in:
21
tests/__mocks__/ink-select-input.js
Normal file
21
tests/__mocks__/ink-select-input.js
Normal file
@@ -0,0 +1,21 @@
|
||||
// Mock ink-select-input for testing
|
||||
const React = require("react");
|
||||
|
||||
const SelectInput = ({ items, onSelect, ...props }) =>
|
||||
React.createElement(
|
||||
"select",
|
||||
{
|
||||
...props,
|
||||
onChange: (e) => onSelect && onSelect(items[e.target.selectedIndex]),
|
||||
},
|
||||
items.map((item, index) =>
|
||||
React.createElement(
|
||||
"option",
|
||||
{ key: index, value: item.value },
|
||||
item.label
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
module.exports = SelectInput;
|
||||
module.exports.default = SelectInput;
|
||||
8
tests/__mocks__/ink-spinner.js
Normal file
8
tests/__mocks__/ink-spinner.js
Normal file
@@ -0,0 +1,8 @@
|
||||
// Mock ink-spinner for testing
|
||||
const React = require("react");
|
||||
|
||||
const Spinner = ({ type = "dots", ...props }) =>
|
||||
React.createElement("span", { ...props, "data-testid": "spinner" }, "⠋");
|
||||
|
||||
module.exports = Spinner;
|
||||
module.exports.default = Spinner;
|
||||
22
tests/__mocks__/ink-testing-library.js
Normal file
22
tests/__mocks__/ink-testing-library.js
Normal file
@@ -0,0 +1,22 @@
|
||||
// Mock for ink-testing-library
|
||||
const React = require("react");
|
||||
|
||||
const render = (component) => {
|
||||
// Simple mock that just returns a basic structure
|
||||
return {
|
||||
lastFrame: () => "Mocked render output",
|
||||
frames: ["Mocked render output"],
|
||||
unmount: jest.fn(),
|
||||
rerender: jest.fn(),
|
||||
stdin: {
|
||||
write: jest.fn(),
|
||||
},
|
||||
stdout: {
|
||||
write: jest.fn(),
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
render,
|
||||
};
|
||||
13
tests/__mocks__/ink-text-input.js
Normal file
13
tests/__mocks__/ink-text-input.js
Normal file
@@ -0,0 +1,13 @@
|
||||
// Mock ink-text-input for testing
|
||||
const React = require("react");
|
||||
|
||||
const TextInput = ({ value, onChange, placeholder, ...props }) =>
|
||||
React.createElement("input", {
|
||||
...props,
|
||||
value,
|
||||
onChange: (e) => onChange && onChange(e.target.value),
|
||||
placeholder,
|
||||
});
|
||||
|
||||
module.exports = TextInput;
|
||||
module.exports.default = TextInput;
|
||||
18
tests/__mocks__/ink.js
Normal file
18
tests/__mocks__/ink.js
Normal file
@@ -0,0 +1,18 @@
|
||||
// Mock Ink components for testing
|
||||
const React = require("react");
|
||||
|
||||
const Box = ({ children, ...props }) =>
|
||||
React.createElement("div", props, children);
|
||||
const Text = ({ children, ...props }) =>
|
||||
React.createElement("span", props, children);
|
||||
|
||||
const useInput = jest.fn();
|
||||
const useApp = jest.fn(() => ({ exit: jest.fn() }));
|
||||
|
||||
module.exports = {
|
||||
Box,
|
||||
Text,
|
||||
useInput,
|
||||
useApp,
|
||||
render: jest.fn(),
|
||||
};
|
||||
Reference in New Issue
Block a user