|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148 |
- import getFormValues from '../../src'
- import * as utils from '../utils'
-
- describe('text', () => {
- describe('basic', () => {
- beforeEach(utils.setup(`
- <!DOCTYPE html>
- <html lang="en-PH">
- <head>
- <meta charset="UTF-8">
- <title>Text/Basic</title>
- </head>
- <body>
- <form>
- <label>
- <span>Hello</span>
- <input type="text" name="hello" value="Hi" />
- </label>
- <button type="submit">Submit</button>
- </form>
- </body>
- </html>
- `))
-
- it('should have single form value', () => {
- utils.test(
- (cy: any) => cy.get('[type="submit"]'),
- (form: HTMLFormElement, submitter: any, search: any) => {
- const before = utils.makeSearchParams(getFormValues(form, {submitter})).toString();
- const after = utils.makeSearchParams(search).toString();
- expect(before).toEqual(after);
- },
- {
- hello: 'Hi',
- }
- );
- });
- })
-
- describe('disabled', () => {
- beforeEach(utils.setup(`
- <!DOCTYPE html>
- <html lang="en-PH">
- <head>
- <meta charset="UTF-8">
- <title>Text/Disabled</title>
- </head>
- <body>
- <form>
- <label>
- <span>Hello</span>
- <input
- type="text" name="hello" value="Hi"
- disabled
- />
- </label>
- <button type="submit">Submit</button>
- </form>
- </body>
- </html>
- `))
-
- it('should have blank form value', () => {
- utils.test(
- (cy: any) => cy.get('[type="submit"]'),
- (form: HTMLFormElement, submitter: any, search: any) => {
- const before = utils.makeSearchParams(getFormValues(form, {submitter})).toString();
- const after = utils.makeSearchParams(search).toString();
- expect(before).toEqual(after);
- },
- {}
- );
- });
- })
-
- describe('outside', () => {
- beforeEach(utils.setup(`
- <!DOCTYPE html>
- <html lang="en-PH">
- <head>
- <meta charset="UTF-8">
- <title>Text/Outside</title>
- </head>
- <body>
- <form id="form">
- <button type="submit">Submit</button>
- </form>
- <label>
- <span>Hello</span>
- <input type="text" name="hello" value="Hi" form="form" />
- </label>
- </body>
- </html>
- `))
-
- it('should have single form value', () => {
- utils.test(
- (cy: any) => cy.get('[type="submit"]'),
- (form: HTMLFormElement, submitter: any, search: any) => {
- const before = utils.makeSearchParams(getFormValues(form, {submitter})).toString();
- const after = utils.makeSearchParams(search).toString();
- expect(before).toEqual(after);
- },
- {
- hello: 'Hi',
- }
- );
- });
- })
-
- describe('readonly', () => {
- beforeEach(utils.setup(`
- <!DOCTYPE html>
- <html lang="en-PH">
- <head>
- <meta charset="UTF-8">
- <title>Text/Readonly</title>
- </head>
- <body>
- <form>
- <label>
- <span>Hello</span>
- <input
- type="text" name="hello" value="Hi"
- readonly
- />
- </label>
- <button type="submit">Submit</button>
- </form>
- </body>
- </html>
- `))
-
- it('should have single form value', () => {
- utils.test(
- (cy: any) => cy.get('[type="submit"]'),
- (form: HTMLFormElement, submitter: any, search: any) => {
- const before = utils.makeSearchParams(getFormValues(form, {submitter})).toString();
- const after = utils.makeSearchParams(search).toString();
- expect(before).toEqual(after);
- },
- {
- hello: 'Hi',
- }
- );
- });
- })
- })
|