@cimpress/react-components
Version:
React components to support the MCP styleguide
33 lines • 2.05 kB
JavaScript
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
import React from 'react';
import { test, expect } from '@playwright/experimental-ct-react17';
import { TextField } from './TextInput';
import { Button } from './Button';
import { TextFieldControlled } from './TextInput.spec-stories';
test('form integration', (_a) => __awaiter(void 0, [_a], void 0, function* ({ mount, page }) {
yield page.route('*/**/api/form', (route) => __awaiter(void 0, void 0, void 0, function* () {
const formData = yield route.request().postDataJSON();
expect(formData).toEqual({ name: 'John' });
yield route.fulfill({ status: 200 });
}));
const component = yield mount(React.createElement("form", { action: "/api/form", method: "post" },
React.createElement(TextField, { label: "Name", name: "name" }),
React.createElement(Button, { type: "submit" }, "Submit")));
yield component.getByLabel('Name').fill('John');
yield expect(component.getByLabel('Name')).toHaveValue('John');
yield component.getByRole('button', { name: 'Submit' }).click();
}));
test('controlled', (_a) => __awaiter(void 0, [_a], void 0, function* ({ mount }) {
const component = yield mount(React.createElement(TextFieldControlled, null));
yield component.getByLabel('Name').fill('John');
yield expect(component.getByLabel('Name')).toHaveValue('John');
}));
//# sourceMappingURL=TextInput.spec.js.map