type
stringclasses 7
values | content
stringlengths 4
9.55k
| repo
stringlengths 7
96
| path
stringlengths 4
178
| language
stringclasses 1
value |
|---|---|---|---|---|
ArrowFunction
|
(actionType: GistActionType) => {
this.setState({ actionType });
}
|
FAWLKTZ/fiddle
|
src/renderer/components/commands-action-button.tsx
|
TypeScript
|
ArrowFunction
|
(toast: IToastProps) => {
this.toaster.show(toast);
}
|
FAWLKTZ/fiddle
|
src/renderer/components/commands-action-button.tsx
|
TypeScript
|
ArrowFunction
|
(values: EditorValues) => {
return {
[INDEX_HTML_NAME]: {
content: values.html || EMPTY_EDITOR_CONTENT.html,
},
[MAIN_JS_NAME]: {
content: values.main || EMPTY_EDITOR_CONTENT.js,
},
[RENDERER_JS_NAME]: {
content: values.renderer || EMPTY_EDITOR_CONTENT.js,
},
[PRELOAD_JS_NAME]: {
content: values.preload || EMPTY_EDITOR_CONTENT.js,
},
[STYLES_CSS_NAME]: {
content: values.css || EMPTY_EDITOR_CONTENT.css,
},
};
}
|
FAWLKTZ/fiddle
|
src/renderer/components/commands-action-button.tsx
|
TypeScript
|
InterfaceDeclaration
|
export interface GistActionButtonProps {
appState: AppState;
}
|
FAWLKTZ/fiddle
|
src/renderer/components/commands-action-button.tsx
|
TypeScript
|
InterfaceDeclaration
|
interface IGistActionButtonState {
readonly isUpdating: boolean;
readonly isDeleting: boolean;
readonly actionType: GistActionType;
}
|
FAWLKTZ/fiddle
|
src/renderer/components/commands-action-button.tsx
|
TypeScript
|
MethodDeclaration
|
public componentDidMount() {
ipcRendererManager.on(IpcEvents.FS_SAVE_FIDDLE_GIST, this.handleClick);
}
|
FAWLKTZ/fiddle
|
src/renderer/components/commands-action-button.tsx
|
TypeScript
|
MethodDeclaration
|
public componentWillUnmount() {
ipcRendererManager.off(IpcEvents.FS_SAVE_FIDDLE_GIST, this.handleClick);
}
|
FAWLKTZ/fiddle
|
src/renderer/components/commands-action-button.tsx
|
TypeScript
|
MethodDeclaration
|
/**
* When the user clicks the publish button, we either show the
* authentication dialog or publish right away.
*
* If we're showing the authentication dialog, we wait for it
* to be closed again (or a GitHub token to show up) before
* we publish
*
* @returns {Promise<void>}
* @memberof GistActionButton
*/
public async handleClick(): Promise<void> {
const { appState } = this.props;
if (!appState.gitHubToken) {
appState.toggleAuthDialog();
}
// Wait for the dialog to be closed again
await when(() => !!appState.gitHubToken || !appState.isTokenDialogShowing);
if (appState.gitHubToken) {
return this.performGistAction();
}
}
|
FAWLKTZ/fiddle
|
src/renderer/components/commands-action-button.tsx
|
TypeScript
|
MethodDeclaration
|
public async getFiddleDescriptionFromUser(): Promise<string | null> {
const { appState } = this.props;
// Reset potentially non-null last description.
appState.genericDialogLastInput = null;
appState.setGenericDialogOptions({
type: GenericDialogType.confirm,
label: 'Please provide a brief description for your Fiddle Gist',
wantsInput: true,
ok: 'Publish',
cancel: 'Cancel',
placeholder: 'Electron Fiddle Gist',
});
appState.isGenericDialogShowing = true;
await when(() => !appState.isGenericDialogShowing);
const cancelled = !appState.genericDialogLastResult;
return cancelled
? null
: appState.genericDialogLastInput ?? 'Electron Fiddle Gist';
}
|
FAWLKTZ/fiddle
|
src/renderer/components/commands-action-button.tsx
|
TypeScript
|
MethodDeclaration
|
private async publishGist(description: string) {
const { appState } = this.props;
const octo = await getOctokit(this.props.appState);
const { gitHubPublishAsPublic } = this.props.appState;
const options = { includeDependencies: true, includeElectron: true };
const values = await window.ElectronFiddle.app.getEditorValues(options);
try {
const gist = await octo.gists.create({
public: !!gitHubPublishAsPublic,
description,
files: this.gistFilesList(values) as any, // Note: GitHub messed up, GistsCreateParamsFiles is an incorrect interface
});
appState.gistId = gist.data.id;
appState.localPath = undefined;
console.log(`Publish Button: Publishing complete`, { gist });
this.renderToast({ message: 'Publishing completed successfully!' });
// Only set action type to update if publish completed successfully.
this.setActionType(GistActionType.update);
} catch (error) {
console.warn(`Could not publish gist`, { error });
const messageBoxOptions: Electron.MessageBoxOptions = {
message:
'Publishing Fiddle to GitHub failed. Are you connected to the Internet?',
detail: `GitHub encountered the following error: ${error.message}`,
};
ipcRendererManager.send(IpcEvents.SHOW_WARNING_DIALOG, messageBoxOptions);
}
}
|
FAWLKTZ/fiddle
|
src/renderer/components/commands-action-button.tsx
|
TypeScript
|
MethodDeclaration
|
/**
* Publish a new GitHub gist.
*/
public async handlePublish() {
const { appState } = this.props;
appState.activeGistAction = GistActionState.publishing;
const description = await this.getFiddleDescriptionFromUser();
if (description) {
await this.publishGist(description);
appState.isUnsaved = false;
}
appState.genericDialogLastInput = null;
appState.activeGistAction = GistActionState.none;
}
|
FAWLKTZ/fiddle
|
src/renderer/components/commands-action-button.tsx
|
TypeScript
|
MethodDeclaration
|
/**
* Update an existing GitHub gist.
*/
public async handleUpdate() {
const { appState } = this.props;
const octo = await getOctokit(this.props.appState);
const options = { includeDependencies: true, includeElectron: true };
const values = await window.ElectronFiddle.app.getEditorValues(options);
appState.activeGistAction = GistActionState.updating;
try {
const gist = await octo.gists.update({
gist_id: appState.gistId!,
files: this.gistFilesList(values) as any,
});
appState.isUnsaved = false;
console.log('Updating: Updating done', { gist });
this.renderToast({ message: 'Successfully updated gist!' });
} catch (error) {
console.warn(`Could not update gist`, { error });
const messageBoxOptions: Electron.MessageBoxOptions = {
message:
'Updating Fiddle Gist failed. Are you connected to the Internet and is this your Gist?',
detail: `GitHub encountered the following error: ${error.message}`,
};
ipcRendererManager.send(IpcEvents.SHOW_WARNING_DIALOG, messageBoxOptions);
}
appState.activeGistAction = GistActionState.none;
this.setActionType(GistActionType.update);
}
|
FAWLKTZ/fiddle
|
src/renderer/components/commands-action-button.tsx
|
TypeScript
|
MethodDeclaration
|
/**
* Delete an existing GitHub gist.
*/
public async handleDelete() {
const { appState } = this.props;
const octo = await getOctokit(this.props.appState);
appState.activeGistAction = GistActionState.deleting;
try {
const gist = await octo.gists.delete({
gist_id: appState.gistId!,
});
appState.isUnsaved = true;
console.log('Deleting: Deleting done', { gist });
this.renderToast({ message: 'Successfully deleted gist!' });
} catch (error) {
console.warn(`Could not delete gist`, { error });
const messageBoxOptions: Electron.MessageBoxOptions = {
message:
'Deleting Fiddle Gist failed. Are you connected to the Internet, is this your Gist, and have you loaded it?',
detail: `GitHub encountered the following error: ${error.message}`,
};
ipcRendererManager.send(IpcEvents.SHOW_WARNING_DIALOG, messageBoxOptions);
}
appState.gistId = undefined;
appState.activeGistAction = GistActionState.none;
this.setActionType(GistActionType.publish);
}
|
FAWLKTZ/fiddle
|
src/renderer/components/commands-action-button.tsx
|
TypeScript
|
MethodDeclaration
|
/**
* Connect with GitHub, perform a publish/update/delete action,
* and update all related properties in the app state.
*/
public async performGistAction(): Promise<void> {
const { gistId } = this.props.appState;
const { actionType } = this.state;
if (gistId) {
switch (actionType) {
case GistActionType.publish:
await this.handlePublish();
break;
case GistActionType.update:
await this.handleUpdate();
break;
case GistActionType.delete:
await this.handleDelete();
break;
}
} else {
await this.handlePublish();
}
}
|
FAWLKTZ/fiddle
|
src/renderer/components/commands-action-button.tsx
|
TypeScript
|
MethodDeclaration
|
/**
* Publish fiddles as private.
*
* @memberof GistActionButton
*/
public setPrivate() {
this.setPrivacy(false);
}
|
FAWLKTZ/fiddle
|
src/renderer/components/commands-action-button.tsx
|
TypeScript
|
MethodDeclaration
|
/**
* Publish fiddles as public.
*
* @memberof GistActionButton
*/
public setPublic() {
this.setPrivacy(true);
}
|
FAWLKTZ/fiddle
|
src/renderer/components/commands-action-button.tsx
|
TypeScript
|
MethodDeclaration
|
public render() {
const { gistId, activeGistAction } = this.props.appState;
const { actionType } = this.state;
const getTextForButton = () => {
let text;
if (gistId) {
text = actionType;
} else if (activeGistAction === GistActionState.updating) {
text = 'Updating...';
} else if (activeGistAction === GistActionState.publishing) {
text = 'Publishing...';
} else if (activeGistAction === GistActionState.deleting) {
text = 'Deleting...';
} else {
text = 'Publish';
}
return text;
};
const getActionIcon = () => {
switch (actionType) {
case GistActionType.publish:
return 'upload';
case GistActionType.update:
return 'refresh';
case GistActionType.delete:
return 'delete';
}
};
const isPerformingAction = activeGistAction !== GistActionState.none;
return (
<>
<fieldset disabled={isPerformingAction}>
<ButtonGroup className="button-gist-action">
{this.renderPrivacyMenu()}
<Button
onClick={this.handleClick}
loading={isPerformingAction}
icon={getActionIcon()}
text={getTextForButton()}
/>
{this.renderGistActionMenu()}
</ButtonGroup>
</fieldset>
<Toaster
position={Position.BOTTOM_RIGHT}
ref={this.refHandlers.toaster}
/>
</>
);
}
|
FAWLKTZ/fiddle
|
src/renderer/components/commands-action-button.tsx
|
TypeScript
|
MethodDeclaration
|
getActionIcon()
|
FAWLKTZ/fiddle
|
src/renderer/components/commands-action-button.tsx
|
TypeScript
|
MethodDeclaration
|
getTextForButton()
|
FAWLKTZ/fiddle
|
src/renderer/components/commands-action-button.tsx
|
TypeScript
|
ClassDeclaration
|
export default class NewExpression extends NodeBase {
type: NodeType.NewExpression;
callee: ExpressionNode;
arguments: ExpressionNode[];
private callOptions: CallOptions;
hasEffects(options: ExecutionPathOptions): boolean {
for (const argument of this.arguments) {
if (argument.hasEffects(options)) return true;
}
return this.callee.hasEffectsWhenCalledAtPath(
[],
this.callOptions,
options.getHasEffectsWhenCalledOptions()
);
}
hasEffectsWhenAccessedAtPath(path: ObjectPath, _options: ExecutionPathOptions) {
return path.length > 1;
}
initialise() {
this.included = false;
this.callOptions = CallOptions.create({
withNew: true,
args: this.arguments,
callIdentifier: this
});
}
}
|
GoJetty/rollup
|
src/ast/nodes/NewExpression.ts
|
TypeScript
|
MethodDeclaration
|
hasEffects(options: ExecutionPathOptions): boolean {
for (const argument of this.arguments) {
if (argument.hasEffects(options)) return true;
}
return this.callee.hasEffectsWhenCalledAtPath(
[],
this.callOptions,
options.getHasEffectsWhenCalledOptions()
);
}
|
GoJetty/rollup
|
src/ast/nodes/NewExpression.ts
|
TypeScript
|
MethodDeclaration
|
hasEffectsWhenAccessedAtPath(path: ObjectPath, _options: ExecutionPathOptions) {
return path.length > 1;
}
|
GoJetty/rollup
|
src/ast/nodes/NewExpression.ts
|
TypeScript
|
MethodDeclaration
|
initialise() {
this.included = false;
this.callOptions = CallOptions.create({
withNew: true,
args: this.arguments,
callIdentifier: this
});
}
|
GoJetty/rollup
|
src/ast/nodes/NewExpression.ts
|
TypeScript
|
ArrowFunction
|
({ name, schemaGroup, optionIndexes, selected, matchesFilter, onSelect, renderContent }): React.ReactElement => {
const hasNestedItems = hasSchemaGroupNestedItems(schemaGroup, optionIndexes);
return (
<div
className={classNames({
"jsonschema-inspector-item": true,
"has-nested-items": hasNestedItems,
selected,
"matching-filter": matchesFilter,
"not-matching-filter": isDefined(matchesFilter) && !matchesFilter
}
|
CarstenWickner/react-jsonschema-inspector
|
src/component/InspectorItem.tsx
|
TypeScript
|
MethodDeclaration
|
classNames({
"jsonschema-inspector-item": true,
"has-nested-items": hasNestedItems,
selected,
"matching-filter": matchesFilter,
"not-matching-filter": isDefined
|
CarstenWickner/react-jsonschema-inspector
|
src/component/InspectorItem.tsx
|
TypeScript
|
ClassDeclaration
|
export class UpdateAgentDto extends PartialType(CreateAgentDto) {}
|
SomphorsMB/find-dream-home-backend
|
src/agent/dto/update-agent.dto.ts
|
TypeScript
|
InterfaceDeclaration
|
/**
* {@docCategory DetailsList}
*/
export interface IDetailsColumnProps extends React.ClassAttributes<DetailsColumnBase> {
/**
* The theme object to respect during render.
*/
theme?: ITheme;
/**
* The component styles to respect during render.
*/
styles?: IStyleFunctionOrObject<IDetailsColumnStyleProps, IDetailsColumnStyles>;
/**
* A reference to the component instance.
*/
componentRef?: () => void;
/**
* The column definition for the component instance.
*/
column: IColumn;
/**
* The column index for the component instance.
*/
columnIndex: number;
/**
* Parent ID used for accessibility label(s).
*/
parentId?: string;
/**
* Render function for providing a column header tooltip.
*/
onRenderColumnHeaderTooltip?: IRenderFunction<ITooltipHostProps>;
/**
* Callback fired when click event occurs.
*/
onColumnClick?: (ev: React.MouseEvent<HTMLElement>, column: IColumn) => void;
/**
* Callback fired on contextual menu event to provide contextual menu UI.
*/
onColumnContextMenu?: (column: IColumn, ev: React.MouseEvent<HTMLElement>) => void;
/**
* The drag and drop helper for the component instance.
*/
dragDropHelper?: IDragDropHelper | null;
/**
* Whether or not the column can be re-ordered via drag and drop.
*/
isDraggable?: boolean;
/**
* @deprecated use `updateDragInfo`
*/
setDraggedItemIndex?: (itemIndex: number) => void;
/**
* Callback on drag and drop event.
*/
updateDragInfo?: (props: {
itemIndex: number;
}, event?: MouseEvent) => void;
/**
* Whether or not the column has been dropped via drag and drop.
*/
isDropped?: boolean;
/**
* Custom styles for cell rendering.
*/
cellStyleProps?: ICellStyleProps;
/**
* Whether to use fast icon and check components. The icons can't be targeted by customization
* but are still customizable via class names.
* @defaultvalue true
*/
useFastIcons?: boolean;
}
|
GhostMachineSoftware/SPFx_GetListItems
|
node_modules/office-ui-fabric-react/lib-amd/components/DetailsList/DetailsColumn.types.d.ts
|
TypeScript
|
InterfaceDeclaration
|
/**
* {@docCategory DetailsList}
*/
export interface IDetailsColumnStyles {
/**
* Styleable root region.
*/
root: IStyle;
/**
* Styleable resize glyph region.
*/
gripperBarVerticalStyle: IStyle;
/**
* Styleable cell tooltip region.
*/
cellTooltip: IStyle;
/**
* Styleable cell title region.
*/
cellTitle: IStyle;
/**
* Styleable cell name region.
*/
cellName: IStyle;
/**
* Styleable icon region.
*/
iconClassName: IStyle;
/**
* Styleable margin by icon region.
*/
nearIcon: IStyle;
/**
* Styleable label region.
*/
accessibleLabel: IStyle;
/**
* Styleable column sort icon region.
*/
sortIcon: IStyle;
/**
* Styleable filter glyph.
*/
filterChevron: IStyle;
/**
* Styleable border region after drag & drop.
*/
borderAfterDropping: IStyle;
/**
* Transparent no border region after drag & drop to avoid content shift.
*/
noBorderAfterDropping: IStyle;
/**
* Styleable border while drag & drop occurs.
*/
borderWhileDragging: IStyle;
/**
* Transparent no border region while drag & drop occurs to avoid content shift.
*/
noBorderWhileDragging: IStyle;
}
|
GhostMachineSoftware/SPFx_GetListItems
|
node_modules/office-ui-fabric-react/lib-amd/components/DetailsList/DetailsColumn.types.d.ts
|
TypeScript
|
TypeAliasDeclaration
|
/**
* {@docCategory DetailsList}
*/
export declare type IDetailsColumnStyleProps = Required<Pick<IDetailsColumnProps, 'theme' | 'cellStyleProps'>> & {
/**
* Classname to provide for header region.
*/
headerClassName?: string;
/**
* Whether or not the column is actionable.
*/
isActionable?: boolean;
/**
* Whether or not the column contains contents.
*/
isEmpty?: boolean;
/**
* Whether or not the column has a visible icon.
*/
isIconVisible?: boolean;
/**
* Whether or not the column is padded.
*/
isPadded?: boolean;
/**
* Whether or not the column has icon only content/
*/
isIconOnly?: boolean;
/**
* Classname to provide for the header's icon region.
*/
iconClassName?: string;
/**
* CSS transition duration on drag event.
*/
transitionDurationDrag?: number;
/**
* CSS transition duration on drop event.
*/
transitionDurationDrop?: number;
};
|
GhostMachineSoftware/SPFx_GetListItems
|
node_modules/office-ui-fabric-react/lib-amd/components/DetailsList/DetailsColumn.types.d.ts
|
TypeScript
|
ClassDeclaration
|
// @FIXME ideally we want to update Item to be an abstract class
// so we don't have to typecast later on
// but unfortunately the specification/Goblin does not allow us
export class UpdateableItem extends Item {
protected minQuality = 0;
protected maxQuality = 50;
protected sellInLimit = 0; // @FIXME think of better naming?
protected defaultDeprecationRate = 1;
handleUpdate(): Item {
return this as Item;
}
protected decreaseSellIn() {
this.sellIn = this.sellIn - 1;
}
}
|
timbakkum/GildedRose-TypeScript-Refactor
|
TypeScript/app/item/updateable-item.ts
|
TypeScript
|
MethodDeclaration
|
handleUpdate(): Item {
return this as Item;
}
|
timbakkum/GildedRose-TypeScript-Refactor
|
TypeScript/app/item/updateable-item.ts
|
TypeScript
|
MethodDeclaration
|
protected decreaseSellIn() {
this.sellIn = this.sellIn - 1;
}
|
timbakkum/GildedRose-TypeScript-Refactor
|
TypeScript/app/item/updateable-item.ts
|
TypeScript
|
ArrowFunction
|
(evt: any) => {
log.info("terminating on " + evt);
services.DATA.kill(evt); // Prozess wird automatisch beendet?
services.db.mongo.close().then((mesg) => {
log.info(mesg);
LoggerService.shutdown();
process.exit(0);
});
}
|
hb42/farc-server
|
src/server.ts
|
TypeScript
|
ArrowFunction
|
(mesg) => {
log.info(mesg);
LoggerService.shutdown();
process.exit(0);
}
|
hb42/farc-server
|
src/server.ts
|
TypeScript
|
FunctionDeclaration
|
export function Content() {
const {movies, handleClickButton, selectedGenre} = useMovies();
return (
<div className="container">
<header>
<span className="category">Categoria:<span> {selectedGenre.title}</span></span>
</header>
<main>
<div className="movies-list">
{movies.map(movie => (
<MovieCard key = {movie.imdbID} title={movie.Title} poster={movie.Poster} runtime={movie.Runtime} rating={movie.Ratings[0].Value} />
))}
</div>
</main>
</div>
)
}
|
Nikholau/componentizando-aplicacao
|
src/components/Content.tsx
|
TypeScript
|
ArrowFunction
|
movie => (
<MovieCard key = {movie.imdbID}
|
Nikholau/componentizando-aplicacao
|
src/components/Content.tsx
|
TypeScript
|
ClassDeclaration
|
@Controller('bookings')
export class BookingsController {
constructor(private readonly bookingService: BookingsService) {}
@Get()
async index() {}
@Post()
create(@Body() createBookingDto: CreateBookingDto) {
return this.bookingService.create(createBookingDto)
}
}
|
dliluashvili/booking-app
|
src/bookings/bookings.controller.ts
|
TypeScript
|
MethodDeclaration
|
@Get()
async index() {}
|
dliluashvili/booking-app
|
src/bookings/bookings.controller.ts
|
TypeScript
|
MethodDeclaration
|
@Post()
create(@Body() createBookingDto: CreateBookingDto) {
return this.bookingService.create(createBookingDto)
}
|
dliluashvili/booking-app
|
src/bookings/bookings.controller.ts
|
TypeScript
|
FunctionDeclaration
|
export function TaskList() {
const [tasks, setTasks] = useState<Task[]>([]);
const [newTaskTitle, setNewTaskTitle] = useState("");
function handleCreateNewTask() {
// Crie uma nova task com um id random, não permita criar caso o título seja vazio.
newTaskTitle &&
setTasks([
...tasks,
{
id: new Date().getTime(),
isComplete: false,
title: newTaskTitle,
},
]);
}
function handleToggleTaskCompletion(id: number) {
// Altere entre `true` ou `false` o campo `isComplete` de uma task com dado ID
const tasksupdate = [...tasks];
const index = tasks.findIndex((task) => task.id === id);
tasksupdate[index].isComplete = !tasks[index].isComplete;
setTasks(tasksupdate);
}
function handleRemoveTask(id: number) {
// Remova uma task da listagem pelo ID
let tasksupdate = [...tasks];
const index = tasksupdate.findIndex((task) => task.id === id);
tasksupdate.splice(index, 1);
setTasks(tasksupdate);
}
return (
<section className="task-list container">
<header>
<h2>Minhas tasks</h2>
<div className="input-group">
<input
type="text"
placeholder="Adicionar novo todo"
onChange={(e) => setNewTaskTitle(e.target.value)}
|
raihard/ignite-desafio-todo
|
src/components/TaskList.tsx
|
TypeScript
|
FunctionDeclaration
|
function handleCreateNewTask() {
// Crie uma nova task com um id random, não permita criar caso o título seja vazio.
newTaskTitle &&
setTasks([
...tasks,
{
id: new Date().getTime(),
isComplete: false,
title: newTaskTitle,
},
]);
}
|
raihard/ignite-desafio-todo
|
src/components/TaskList.tsx
|
TypeScript
|
FunctionDeclaration
|
function handleToggleTaskCompletion(id: number) {
// Altere entre `true` ou `false` o campo `isComplete` de uma task com dado ID
const tasksupdate = [...tasks];
const index = tasks.findIndex((task) => task.id === id);
tasksupdate[index].isComplete = !tasks[index].isComplete;
setTasks(tasksupdate);
}
|
raihard/ignite-desafio-todo
|
src/components/TaskList.tsx
|
TypeScript
|
FunctionDeclaration
|
function handleRemoveTask(id: number) {
// Remova uma task da listagem pelo ID
let tasksupdate = [...tasks];
const index = tasksupdate.findIndex((task) => task.id === id);
tasksupdate.splice(index, 1);
setTasks(tasksupdate);
}
|
raihard/ignite-desafio-todo
|
src/components/TaskList.tsx
|
TypeScript
|
ArrowFunction
|
(task) => task.id === id
|
raihard/ignite-desafio-todo
|
src/components/TaskList.tsx
|
TypeScript
|
ArrowFunction
|
(task) => (
<li key={task.id}>
<div
className
|
raihard/ignite-desafio-todo
|
src/components/TaskList.tsx
|
TypeScript
|
InterfaceDeclaration
|
interface Task {
id: number;
title: string;
isComplete: boolean;
}
|
raihard/ignite-desafio-todo
|
src/components/TaskList.tsx
|
TypeScript
|
ArrowFunction
|
() => {
beforeAll(() => {
fetchMock.enableMocks();
});
afterAll(() => {
fetchMock.disableMocks();
});
beforeEach(() => {
mockSubmitData = { ...MOCK_FORM_DATA };
mutationMock = mockUpdateExperimentAudienceMutation(
{ ...mockSubmitData, id: experiment.id },
{},
);
});
it("renders as expected", async () => {
render(<Subject />);
await waitFor(() => {
expect(screen.queryByTestId("PageEditAudience")).toBeInTheDocument();
});
});
it("handles form next button", async () => {
render(<Subject mocks={[mock, mutationMock]} />);
await screen.findByTestId("PageEditAudience");
await act(async () => void fireEvent.click(screen.getByTestId("next")));
expect(mockSubmit).toHaveBeenCalled();
expect(navigate).toHaveBeenCalledWith("../request-review");
});
it("handles form submission", async () => {
render(<Subject mocks={[mock, mutationMock]} />);
await screen.findByTestId("PageEditAudience");
await act(async () => void fireEvent.click(screen.getByTestId("submit")));
expect(mockSubmit).toHaveBeenCalled();
});
it("handles experiment form submission with server-side validation errors", async () => {
const expectedErrors = {
channel: { message: "this is garbage" },
};
mutationMock.result.data.updateExperiment.message = expectedErrors;
render(<Subject mocks={[mock, mutationMock]} />);
let submitButton: HTMLButtonElement;
await waitFor(() => {
submitButton = screen.getByTestId("submit") as HTMLButtonElement;
});
await act(async () => {
fireEvent.click(submitButton);
});
expect(screen.getByTestId("submitErrors")).toHaveTextContent(
JSON.stringify(expectedErrors),
);
});
it("handles form submission with bad server data", async () => {
// @ts-ignore - intentionally breaking this type for error handling
delete mutationMock.result.data.updateExperiment;
render(<Subject mocks={[mock, mutationMock]} />);
let submitButton: HTMLButtonElement;
await waitFor(() => {
submitButton = screen.getByTestId("submit") as HTMLButtonElement;
});
await act(async () => {
fireEvent.click(submitButton);
});
expect(screen.getByTestId("submitErrors")).toHaveTextContent(
JSON.stringify({ "*": SUBMIT_ERROR }),
);
});
}
|
Exhorder6/experimenter
|
app/experimenter/nimbus-ui/src/components/PageEditAudience/index.test.tsx
|
TypeScript
|
ArrowFunction
|
() => {
fetchMock.enableMocks();
}
|
Exhorder6/experimenter
|
app/experimenter/nimbus-ui/src/components/PageEditAudience/index.test.tsx
|
TypeScript
|
ArrowFunction
|
() => {
fetchMock.disableMocks();
}
|
Exhorder6/experimenter
|
app/experimenter/nimbus-ui/src/components/PageEditAudience/index.test.tsx
|
TypeScript
|
ArrowFunction
|
() => {
mockSubmitData = { ...MOCK_FORM_DATA };
mutationMock = mockUpdateExperimentAudienceMutation(
{ ...mockSubmitData, id: experiment.id },
{},
);
}
|
Exhorder6/experimenter
|
app/experimenter/nimbus-ui/src/components/PageEditAudience/index.test.tsx
|
TypeScript
|
ArrowFunction
|
async () => {
render(<Subject />);
await waitFor(() => {
expect(screen.queryByTestId("PageEditAudience")).toBeInTheDocument();
});
}
|
Exhorder6/experimenter
|
app/experimenter/nimbus-ui/src/components/PageEditAudience/index.test.tsx
|
TypeScript
|
ArrowFunction
|
() => {
expect(screen.queryByTestId("PageEditAudience")).toBeInTheDocument();
}
|
Exhorder6/experimenter
|
app/experimenter/nimbus-ui/src/components/PageEditAudience/index.test.tsx
|
TypeScript
|
ArrowFunction
|
async () => {
render(<Subject mocks={[mock, mutationMock]} />);
await screen.findByTestId("PageEditAudience");
await act(async () => void fireEvent.click(screen.getByTestId("next")));
expect(mockSubmit).toHaveBeenCalled();
expect(navigate).toHaveBeenCalledWith("../request-review");
}
|
Exhorder6/experimenter
|
app/experimenter/nimbus-ui/src/components/PageEditAudience/index.test.tsx
|
TypeScript
|
ArrowFunction
|
async () => void fireEvent.click(screen.getByTestId("next"))
|
Exhorder6/experimenter
|
app/experimenter/nimbus-ui/src/components/PageEditAudience/index.test.tsx
|
TypeScript
|
ArrowFunction
|
async () => {
render(<Subject mocks={[mock, mutationMock]} />);
await screen.findByTestId("PageEditAudience");
await act(async () => void fireEvent.click(screen.getByTestId("submit")));
expect(mockSubmit).toHaveBeenCalled();
}
|
Exhorder6/experimenter
|
app/experimenter/nimbus-ui/src/components/PageEditAudience/index.test.tsx
|
TypeScript
|
ArrowFunction
|
async () => void fireEvent.click(screen.getByTestId("submit"))
|
Exhorder6/experimenter
|
app/experimenter/nimbus-ui/src/components/PageEditAudience/index.test.tsx
|
TypeScript
|
ArrowFunction
|
async () => {
const expectedErrors = {
channel: { message: "this is garbage" },
};
mutationMock.result.data.updateExperiment.message = expectedErrors;
render(<Subject mocks={[mock, mutationMock]} />);
let submitButton: HTMLButtonElement;
await waitFor(() => {
submitButton = screen.getByTestId("submit") as HTMLButtonElement;
});
await act(async () => {
fireEvent.click(submitButton);
});
expect(screen.getByTestId("submitErrors")).toHaveTextContent(
JSON.stringify(expectedErrors),
);
}
|
Exhorder6/experimenter
|
app/experimenter/nimbus-ui/src/components/PageEditAudience/index.test.tsx
|
TypeScript
|
ArrowFunction
|
() => {
submitButton = screen.getByTestId("submit") as HTMLButtonElement;
}
|
Exhorder6/experimenter
|
app/experimenter/nimbus-ui/src/components/PageEditAudience/index.test.tsx
|
TypeScript
|
ArrowFunction
|
async () => {
fireEvent.click(submitButton);
}
|
Exhorder6/experimenter
|
app/experimenter/nimbus-ui/src/components/PageEditAudience/index.test.tsx
|
TypeScript
|
ArrowFunction
|
async () => {
// @ts-ignore - intentionally breaking this type for error handling
delete mutationMock.result.data.updateExperiment;
render(<Subject mocks={[mock, mutationMock]} />);
let submitButton: HTMLButtonElement;
await waitFor(() => {
submitButton = screen.getByTestId("submit") as HTMLButtonElement;
});
await act(async () => {
fireEvent.click(submitButton);
});
expect(screen.getByTestId("submitErrors")).toHaveTextContent(
JSON.stringify({ "*": SUBMIT_ERROR }),
);
}
|
Exhorder6/experimenter
|
app/experimenter/nimbus-ui/src/components/PageEditAudience/index.test.tsx
|
TypeScript
|
ArrowFunction
|
({
mocks = [mock],
}: {
mocks?: MockedResponse<Record<string, any>>[];
}) => {
return (
<RouterSlugProvider {...{ mocks }}>
<PageEditAudience />
</RouterSlugProvider>
);
}
|
Exhorder6/experimenter
|
app/experimenter/nimbus-ui/src/components/PageEditAudience/index.test.tsx
|
TypeScript
|
ArrowFunction
|
() => ({
...(jest.requireActual("@reach/router") as any),
navigate: jest.fn(),
})
|
Exhorder6/experimenter
|
app/experimenter/nimbus-ui/src/components/PageEditAudience/index.test.tsx
|
TypeScript
|
ArrowFunction
|
() => ({
__esModule: true,
default: (props: React.ComponentProps<typeof FormAudience>) => {
const handleSubmit = (ev: React.FormEvent) => {
ev.preventDefault();
mockSubmit();
props.onSubmit(mockSubmitData, false);
};
const handleNext = (ev: React.FormEvent) => {
ev.preventDefault();
mockSubmit();
props.onSubmit(mockSubmitData, true);
};
return (
<div data-testid="FormOverview">
<div data-testid="submitErrors">
{JSON.stringify(props.submitErrors)}
</div>
<button data-testid="submit" onClick={handleSubmit} />
<button data-testid="next" onClick={handleNext} />
</div>
)
|
Exhorder6/experimenter
|
app/experimenter/nimbus-ui/src/components/PageEditAudience/index.test.tsx
|
TypeScript
|
ArrowFunction
|
(props: React.ComponentProps<typeof FormAudience>) => {
const handleSubmit = (ev: React.FormEvent) => {
ev.preventDefault();
mockSubmit();
props.onSubmit(mockSubmitData, false);
};
const handleNext = (ev: React.FormEvent) => {
ev.preventDefault();
mockSubmit();
props.onSubmit(mockSubmitData, true);
};
return (
<div data-testid="FormOverview">
<div data-testid="submitErrors">
{JSON.stringify(props.submitErrors)}
</div>
<button data-testid="submit" onClick={handleSubmit} />
<button data-testid="next" onClick={handleNext} />
</div>
|
Exhorder6/experimenter
|
app/experimenter/nimbus-ui/src/components/PageEditAudience/index.test.tsx
|
TypeScript
|
ArrowFunction
|
(ev: React.FormEvent) => {
ev.preventDefault();
mockSubmit();
props.onSubmit(mockSubmitData, false);
}
|
Exhorder6/experimenter
|
app/experimenter/nimbus-ui/src/components/PageEditAudience/index.test.tsx
|
TypeScript
|
ArrowFunction
|
(ev: React.FormEvent) => {
ev.preventDefault();
mockSubmit();
props.onSubmit(mockSubmitData, true);
}
|
Exhorder6/experimenter
|
app/experimenter/nimbus-ui/src/components/PageEditAudience/index.test.tsx
|
TypeScript
|
ArrowFunction
|
(
input: Partial<ExperimentInput>,
{
message = "success",
}: {
message?: string | Record<string, any>;
},
) => {
const updateExperiment: updateExperiment_updateExperiment = {
message,
};
return {
request: {
query: UPDATE_EXPERIMENT_MUTATION,
variables: {
input,
},
},
result: {
errors: undefined as undefined | any[],
data: {
updateExperiment,
},
},
};
}
|
Exhorder6/experimenter
|
app/experimenter/nimbus-ui/src/components/PageEditAudience/index.test.tsx
|
TypeScript
|
ArrowFunction
|
(): void => {
const registry = new TypeRegistry();
const a = [new U32(registry, 123), new U32(registry, 456), new U32(registry, 789)];
it('returns false when second param is a non-array', (): void => {
expect(
compareArray(a, 123)
).toBe(false);
});
it('compares array of codec agains primitive', (): void => {
expect(
compareArray(a, [123, 456, 789])
).toBe(true);
});
it('compares array of codec agains codec', (): void => {
expect(
compareArray(a, [new U32(registry, 123), new U32(registry, 456), new U32(registry, 789)])
).toBe(true);
});
it('compares primitive against primitive', (): void => {
expect(
compareArray(
[123, 456], [123, 456]
)
).toBe(true);
});
it('returns false when lengths are not matching', (): void => {
expect(
compareArray(a, [123])
).toBe(false);
});
it('returns false when value mismatches', (): void => {
expect(
compareArray(a, [123, 456, 999])
).toBe(false);
});
}
|
alfredgit220/darwinia-apps
|
packages/types/src/codec/utils/compareArray.spec.ts
|
TypeScript
|
ArrowFunction
|
(): void => {
expect(
compareArray(a, 123)
).toBe(false);
}
|
alfredgit220/darwinia-apps
|
packages/types/src/codec/utils/compareArray.spec.ts
|
TypeScript
|
ArrowFunction
|
(): void => {
expect(
compareArray(a, [123, 456, 789])
).toBe(true);
}
|
alfredgit220/darwinia-apps
|
packages/types/src/codec/utils/compareArray.spec.ts
|
TypeScript
|
ArrowFunction
|
(): void => {
expect(
compareArray(a, [new U32(registry, 123), new U32(registry, 456), new U32(registry, 789)])
).toBe(true);
}
|
alfredgit220/darwinia-apps
|
packages/types/src/codec/utils/compareArray.spec.ts
|
TypeScript
|
ArrowFunction
|
(): void => {
expect(
compareArray(
[123, 456], [123, 456]
)
).toBe(true);
}
|
alfredgit220/darwinia-apps
|
packages/types/src/codec/utils/compareArray.spec.ts
|
TypeScript
|
ArrowFunction
|
(): void => {
expect(
compareArray(a, [123])
).toBe(false);
}
|
alfredgit220/darwinia-apps
|
packages/types/src/codec/utils/compareArray.spec.ts
|
TypeScript
|
ArrowFunction
|
(): void => {
expect(
compareArray(a, [123, 456, 999])
).toBe(false);
}
|
alfredgit220/darwinia-apps
|
packages/types/src/codec/utils/compareArray.spec.ts
|
TypeScript
|
ArrowFunction
|
(name, scene) => {
return () => new VRDeviceOrientationFreeCamera(name, Vector3.Zero(), scene);
}
|
10088/Babylon.js
|
src/Cameras/VR/vrDeviceOrientationFreeCamera.ts
|
TypeScript
|
ArrowFunction
|
() => new VRDeviceOrientationFreeCamera(name, Vector3.Zero(), scene)
|
10088/Babylon.js
|
src/Cameras/VR/vrDeviceOrientationFreeCamera.ts
|
TypeScript
|
ClassDeclaration
|
/**
* Camera used to simulate VR rendering (based on FreeCamera)
* @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
*/
export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
/**
* Creates a new VRDeviceOrientationFreeCamera
* @param name defines camera name
* @param position defines the start position of the camera
* @param scene defines the scene the camera belongs to
* @param compensateDistortion defines if the camera needs to compensate the lens distortion
* @param vrCameraMetrics defines the vr metrics associated to the camera
*/
constructor(name: string, position: Vector3, scene: Scene, compensateDistortion = true, vrCameraMetrics: VRCameraMetrics = VRCameraMetrics.GetDefault()) {
super(name, position, scene);
vrCameraMetrics.compensateDistortion = compensateDistortion;
this.setCameraRigMode(Camera.RIG_MODE_VR, { vrCameraMetrics: vrCameraMetrics });
}
/**
* Gets camera class name
* @returns VRDeviceOrientationFreeCamera
*/
public getClassName(): string {
return "VRDeviceOrientationFreeCamera";
}
protected _setRigMode = setVRRigMode.bind(null, this);
}
|
10088/Babylon.js
|
src/Cameras/VR/vrDeviceOrientationFreeCamera.ts
|
TypeScript
|
MethodDeclaration
|
/**
* Gets camera class name
* @returns VRDeviceOrientationFreeCamera
*/
public getClassName(): string {
return "VRDeviceOrientationFreeCamera";
}
|
10088/Babylon.js
|
src/Cameras/VR/vrDeviceOrientationFreeCamera.ts
|
TypeScript
|
ArrowFunction
|
async () => {
resetCleanupScheduleForTests()
// Unfortunately, Jest fake timers don't mock out Date.now, so we fake
// that out in parallel to Jest useFakeTimers
let fakeNow = Date.now()
jest.useFakeTimers()
jest.spyOn(Date, "now").mockImplementation(() => fakeNow)
const store = mobx.observable({ count1: 0, count2: 0 })
// Track whether counts are observed
let count1IsObserved = false
let count2IsObserved = false
mobx.onBecomeObserved(store, "count1", () => (count1IsObserved = true))
mobx.onBecomeUnobserved(store, "count1", () => (count1IsObserved = false))
mobx.onBecomeObserved(store, "count2", () => (count2IsObserved = true))
mobx.onBecomeUnobserved(store, "count2", () => (count2IsObserved = false))
const TestComponent1 = () => useObserver(() => <div>{store.count1}</div>)
const TestComponent2 = () => useObserver(() => <div>{store.count2}</div>)
// Render, then remove only #2
const rendering = render(
<React.StrictMode>
<TestComponent1 />
<TestComponent2 />
</React.StrictMode>
)
rendering.rerender(
<React.StrictMode>
<TestComponent1 />
</React.StrictMode>
)
// Allow any reaction-disposal cleanup timers to run
const skip = Math.max(CLEANUP_LEAKED_REACTIONS_AFTER_MILLIS, CLEANUP_TIMER_LOOP_MILLIS)
fakeNow += skip
jest.advanceTimersByTime(skip)
// count1 should still be being observed by Component1,
// but count2 should have had its reaction cleaned up.
expect(count1IsObserved).toBeTruthy()
expect(count2IsObserved).toBeFalsy()
}
|
1mike12/mobx
|
packages/mobx-react-lite/__tests__/strictAndConcurrentModeUsingTimers.test.tsx
|
TypeScript
|
ArrowFunction
|
() => fakeNow
|
1mike12/mobx
|
packages/mobx-react-lite/__tests__/strictAndConcurrentModeUsingTimers.test.tsx
|
TypeScript
|
ArrowFunction
|
() => (count1IsObserved = true)
|
1mike12/mobx
|
packages/mobx-react-lite/__tests__/strictAndConcurrentModeUsingTimers.test.tsx
|
TypeScript
|
ArrowFunction
|
() => (count1IsObserved = false)
|
1mike12/mobx
|
packages/mobx-react-lite/__tests__/strictAndConcurrentModeUsingTimers.test.tsx
|
TypeScript
|
ArrowFunction
|
() => (count2IsObserved = true)
|
1mike12/mobx
|
packages/mobx-react-lite/__tests__/strictAndConcurrentModeUsingTimers.test.tsx
|
TypeScript
|
ArrowFunction
|
() => (count2IsObserved = false)
|
1mike12/mobx
|
packages/mobx-react-lite/__tests__/strictAndConcurrentModeUsingTimers.test.tsx
|
TypeScript
|
ArrowFunction
|
() => useObserver(() => <div>{store.count1}</div>)
|
1mike12/mobx
|
packages/mobx-react-lite/__tests__/strictAndConcurrentModeUsingTimers.test.tsx
|
TypeScript
|
ArrowFunction
|
() => <div>{store.count1}</div>)
|
1mike12/mobx
|
packages/mobx-react-lite/__tests__/strictAndConcurrentModeUsingTimers.test.tsx
|
TypeScript
|
ArrowFunction
|
() => useObserver(() => <div>{store.count2}</div>)
|
1mike12/mobx
|
packages/mobx-react-lite/__tests__/strictAndConcurrentModeUsingTimers.test.tsx
|
TypeScript
|
ArrowFunction
|
() => <div>{store.count2}</div>)
|
1mike12/mobx
|
packages/mobx-react-lite/__tests__/strictAndConcurrentModeUsingTimers.test.tsx
|
TypeScript
|
ArrowFunction
|
() => {
// If we're not careful with timings, it's possible to get the
// following scenario:
// 1. Component instance A is being created; it renders, we put its reaction R1 into the cleanup list
// 2. Strict/Concurrent mode causes that render to be thrown away
// 3. Component instance A is being created; it renders, we put its reaction R2 into the cleanup list
// 4. The MobX reaction timer from 5 seconds ago kicks in and cleans up all reactions from uncommitted
// components, including R1 and R2
// 5. The commit phase runs for component A, but reaction R2 has already been disposed. Game over.
// This unit test attempts to replicate that scenario:
resetCleanupScheduleForTests()
// Unfortunately, Jest fake timers don't mock out Date.now, so we fake
// that out in parallel to Jest useFakeTimers
const fakeNow = Date.now()
jest.useFakeTimers()
jest.spyOn(Date, "now").mockImplementation(() => fakeNow)
const store = mobx.observable({ count: 0 })
// Track whether the count is observed
let countIsObserved = false
mobx.onBecomeObserved(store, "count", () => (countIsObserved = true))
mobx.onBecomeUnobserved(store, "count", () => (countIsObserved = false))
const TestComponent1 = () => useObserver(() => <div>{store.count}</div>)
// We're going to render directly using ReactDOM, not react-testing-library, because we want
// to be able to get in and do nasty things before everything (including useEffects) have completed,
// and react-testing-library waits for all that, using act().
const rootNode = document.createElement("div")
ReactDOM.render(
// We use StrictMode here, but it would be helpful to switch this to use real
// concurrent mode: we don't have a true async render right now so this test
// isn't as thorough as it could be.
<React.StrictMode>
<TestComponent1 />
</React.StrictMode>,
rootNode
)
// We need to trigger our cleanup timer to run. We can't do this simply
// by running all jest's faked timers as that would allow the scheduled
// `useEffect` calls to run, and we want to simulate our cleanup timer
// getting in between those stages.
// We force our cleanup loop to run even though enough time hasn't _really_
// elapsed. In theory, it won't do anything because not enough time has
// elapsed since the reactions were queued, and so they won't be disposed.
forceCleanupTimerToRunNowForTests()
// Advance time enough to allow any timer-queued effects to run
jest.advanceTimersByTime(500)
// Now allow the useEffect calls to run to completion.
act(() => {
// no-op, but triggers effect flushing
})
// count should still be observed
expect(countIsObserved).toBeTruthy()
}
|
1mike12/mobx
|
packages/mobx-react-lite/__tests__/strictAndConcurrentModeUsingTimers.test.tsx
|
TypeScript
|
ArrowFunction
|
() => (countIsObserved = true)
|
1mike12/mobx
|
packages/mobx-react-lite/__tests__/strictAndConcurrentModeUsingTimers.test.tsx
|
TypeScript
|
ArrowFunction
|
() => (countIsObserved = false)
|
1mike12/mobx
|
packages/mobx-react-lite/__tests__/strictAndConcurrentModeUsingTimers.test.tsx
|
TypeScript
|
ArrowFunction
|
() => useObserver(() => <div>{store.count}</div>)
|
1mike12/mobx
|
packages/mobx-react-lite/__tests__/strictAndConcurrentModeUsingTimers.test.tsx
|
TypeScript
|
ArrowFunction
|
() => <div>{store.count}</div>)
|
1mike12/mobx
|
packages/mobx-react-lite/__tests__/strictAndConcurrentModeUsingTimers.test.tsx
|
TypeScript
|
ArrowFunction
|
() => {
// no-op, but triggers effect flushing
}
|
1mike12/mobx
|
packages/mobx-react-lite/__tests__/strictAndConcurrentModeUsingTimers.test.tsx
|
TypeScript
|
ArrowFunction
|
() => {
// There _may_ be very strange cases where the reaction gets tidied up
// but is actually still needed. This _really_ shouldn't happen.
// e.g. if we're using Suspense and the component starts to render,
// but then gets paused for 60 seconds, and then comes back to life.
// With the implementation of React at the time of writing this, React
// will actually fully re-render that component (discarding previous
// hook slots) before going ahead with a commit, but it's unwise
// to depend on such an implementation detail. So we must cope with
// the component having had its reaction tidied and still going on to
// be committed. In that case we recreate the reaction and force
// an update.
// This unit test attempts to replicate that scenario:
resetCleanupScheduleForTests()
// Unfortunately, Jest fake timers don't mock out Date.now, so we fake
// that out in parallel to Jest useFakeTimers
let fakeNow = Date.now()
jest.useFakeTimers()
jest.spyOn(Date, "now").mockImplementation(() => fakeNow)
const store = mobx.observable({ count: 0 })
// Track whether the count is observed
let countIsObserved = false
mobx.onBecomeObserved(store, "count", () => (countIsObserved = true))
mobx.onBecomeUnobserved(store, "count", () => (countIsObserved = false))
const TestComponent1 = () => useObserver(() => <div>{store.count}</div>)
// We're going to render directly using ReactDOM, not react-testing-library, because we want
// to be able to get in and do nasty things before everything (including useEffects) have completed,
// and react-testing-library waits for all that, using act().
const rootNode = document.createElement("div")
ReactDOM.render(
<React.StrictMode>
<TestComponent1 />
</React.StrictMode>,
rootNode
)
// We need to trigger our cleanup timer to run. We don't want
// to allow Jest's effects to run, however: we want to simulate the
// case where the component is rendered, then the reaction gets cleaned up,
// and _then_ the component commits.
// Force everything to be disposed.
const skip = Math.max(CLEANUP_LEAKED_REACTIONS_AFTER_MILLIS, CLEANUP_TIMER_LOOP_MILLIS)
fakeNow += skip
forceCleanupTimerToRunNowForTests()
// The reaction should have been cleaned up.
expect(countIsObserved).toBeFalsy()
// Whilst nobody's looking, change the observable value
store.count = 42
// Now allow the useEffect calls to run to completion,
// re-awakening the component.
jest.advanceTimersByTime(500)
act(() => {
// no-op, but triggers effect flushing
})
// count should be observed once more.
expect(countIsObserved).toBeTruthy()
// and the component should have rendered enough to
// show the latest value, which was set whilst it
// wasn't even looking.
expect(rootNode.textContent).toContain("42")
}
|
1mike12/mobx
|
packages/mobx-react-lite/__tests__/strictAndConcurrentModeUsingTimers.test.tsx
|
TypeScript
|
ClassDeclaration
|
class DeleteUserUseCase {
constructor(private userRepository: IUserRepository) {}
async execute(id: number) {
await this.userRepository.delete(id);
}
}
|
RobsonCrLira/crud-aws
|
src/useCase/DeleteUser/DeleteUserUseCase.ts
|
TypeScript
|
MethodDeclaration
|
async execute(id: number) {
await this.userRepository.delete(id);
}
|
RobsonCrLira/crud-aws
|
src/useCase/DeleteUser/DeleteUserUseCase.ts
|
TypeScript
|
ArrowFunction
|
async (name: string): Promise<string> => {
log.debug(`ssm.getParameter: name: ${name}`);
const result = await ssm
.getParameter({
Name: `/iidx-routine/production/${name}`,
WithDecryption: true,
})
.promise();
if (result.Parameter == undefined || result.Parameter.Value == undefined) {
throw new Error(`failed to get the ssm parameter. name: ${name}`);
}
return result.Parameter.Value;
}
|
shuymn/iidx-routine
|
src/lib/secrets.ts
|
TypeScript
|
ArrowFunction
|
(): Promise<string> => getParameter("konami-id")
|
shuymn/iidx-routine
|
src/lib/secrets.ts
|
TypeScript
|
ArrowFunction
|
(): Promise<string> => getParameter("konami-password")
|
shuymn/iidx-routine
|
src/lib/secrets.ts
|
TypeScript
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.