@navinc/base-react-components
Version:
Nav's Pattern Library
27 lines • 1.78 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 { jsx as _jsx } from "react/jsx-runtime";
import { describe, expect, it } from 'vitest';
import { screen } from '@testing-library/react';
import { PasswordInput as RawPasswordImport } from './password-input.js';
import { renderWithContext, withAppContext } from './tests/with-app-context.js';
import userEvent from '@testing-library/user-event';
const PasswordInput = withAppContext(RawPasswordImport);
describe('<PasswordInput />', () => {
it('changes isPasswordShown from false to true', () => __awaiter(void 0, void 0, void 0, function* () {
renderWithContext(_jsx(PasswordInput, { name: "password", label: "password" }));
yield userEvent.type(screen.getByLabelText(/password/i), 'pa$$w0rd');
expect(screen.getByTestId('icon:feedback/visible')).toBeInTheDocument();
yield userEvent.click(screen.getByTestId('icon:feedback/visible'));
expect(screen.getByTestId('icon:feedback/invisible')).toBeInTheDocument();
expect(screen.getByDisplayValue('pa$$w0rd')).toBeInTheDocument();
}));
});
//# sourceMappingURL=password-input.spec.js.map