Ver a proveniência

Update tests

Include month and week input types.
master
ascendente
cometimento
05499e5fdb
2 ficheiros alterados com 80 adições e 43 eliminações
  1. +74
    -41
      cypress/integration/misc.test.ts
  2. +6
    -2
      src/index.ts

+ 74
- 41
cypress/integration/misc.test.ts Ver ficheiro

@@ -46,15 +46,18 @@ describe('misc', () => {
<article>
<h2></h2>
<form>
<div>
<input type="text" placeholder="First Name" name="first_name" />
</div>
<div>
<input type="text" placeholder="Middle Name" name="middle_name" />
</div>
<div>
<input type="text" placeholder="Last Name" name="last_name" />
</div>
<fieldset>
<legend>Name</legend>
<div>
<input type="text" placeholder="First Name" name="first_name" />
</div>
<div>
<input type="text" placeholder="Middle Name" name="middle_name" />
</div>
<div>
<input type="text" placeholder="Last Name" name="last_name" />
</div>
</fieldset>
<fieldset>
<legend>Gender</legend>
<div>
@@ -68,27 +71,51 @@ describe('misc', () => {
</label>
</div>
</fieldset>
<div>
<input type="date" placeholder="Birthday" name="birthday" />
</div>
<div>
<select name="civil_status">
<option value="">Select Civil Status</option>
<option value="single">Single</option>
<option value="married">Married</option>
<option value="divorced">Divorced</option>
<option value="separated">Separated</option>
</select>
</div>
<div>
<label>
<input type="checkbox" name="new_registration" />
New Registration
</label>
</div>
<div>
<input type="datetime-local" placeholder="Appointment Date/Time" name="appointment_datetime" />
</div>
<fieldset>
<legend>Birthday</legend>
<div>
<input type="date" placeholder="Birthday" name="birthday" />
</div>
</fieldset>
<fieldset>
<legend>Civil Status</legend>
<div>
<select name="civil_status">
<option value="">Select Civil Status</option>
<option value="single">Single</option>
<option value="married">Married</option>
<option value="divorced">Divorced</option>
<option value="separated">Separated</option>
</select>
</div>
</fieldset>
<fieldset>
<legend>New Registration</legend>
<div>
<label>
<input type="checkbox" name="new_registration" />
New Registration
</label>
</div>
</fieldset>
<fieldset>
<legend>Last Appointment Date</legend>
<div>
<input type="datetime-local" placeholder="Last Appointment Date" name="last_appointment_datetime" />
</div>
</fieldset>
<fieldset>
<legend>New Appointment Week</legend>
<div>
<input type="week" placeholder="New Appointment Week" name="new_appointment_week" />
</div>
</fieldset>
<fieldset>
<legend>Start Month</legend>
<div>
<input type="month" placeholder="Start Month" name="start_month" />
</div>
</fieldset>
<div>
<label>
<input type="checkbox" value="filipino" name="nationality" />
@@ -121,12 +148,12 @@ describe('misc', () => {
<div>
<textarea name="notes" placeholder="Notes"></textarea>
</div>
<div>
<label>
<fieldset>
<legend>
Quality of Service
<input type="range" min="0" max="10" placeholder="Quality of Service" name="qos" />
</label>
</div>
</legend>
<input type="range" min="0" max="10" step="0.5" placeholder="Quality of Service" name="qos" />
</fieldset>
<div>
<button name="submit" value="Hello" type="submit">Hello</button>
<button name="submit" value="Hi" type="submit">Hi</button>
@@ -168,8 +195,12 @@ describe('misc', () => {
.select('Married')
cy.get('[name="new_registration"]')
.check()
cy.get('[name="appointment_datetime"]')
cy.get('[name="last_appointment_datetime"]')
.type('2001-09-11T06:09')
cy.get('[name="new_appointment_week"]')
.type('2001-W51')
cy.get('[name="start_month"]')
.type('2002-03')
cy.get('[name="nationality"][value="filipino"]')
.check()
cy.get('[name="gross"]')
@@ -193,7 +224,7 @@ describe('misc', () => {
.last()
.type('Josh')
cy.get('[name="qos"]')
.invoke('val', 10)
.invoke('val', 9.5)
.trigger('change')
cy.get('[name="notes"]')
.type('Test content\n\nNew line\n\nAnother line')
@@ -208,7 +239,7 @@ describe('misc', () => {
expect(before)
.toEqual(after);
},
expectedStaticValue: 'first_name=John&middle_name=Marcelo&last_name=Dela+Cruz&gender=m&birthday=1989-06-04&civil_status=married&new_registration=on&appointment_datetime=2001-09-11T06%3A09&nationality=filipino&gross=131072&dependent=Jun&notes=Test+content%0D%0A%0D%0ANew+line%0D%0A%0D%0AAnother+line&qos=10&submit=Hi',
expectedStaticValue: 'first_name=John&middle_name=Marcelo&last_name=Dela+Cruz&gender=m&birthday=1989-06-04&civil_status=married&new_registration=on&last_appointment_datetime=2001-09-11T06%3A09&new_appointment_week=2001-W51&start_month=2002-03&nationality=filipino&gross=131072&dependent=Jun&notes=Test+content%0D%0A%0D%0ANew+line%0D%0A%0D%0AAnother+line&qos=9.5&submit=Hi',
});
});

@@ -232,7 +263,9 @@ describe('misc', () => {
birthday: new Date('1989-06-04'),
civil_status: 'married',
new_registration: 'on',
appointment_datetime: new Date('2001-09-11T06:09:00'),
last_appointment_datetime: new Date('2001-09-11T06:09:00'),
new_appointment_week: '2001-W51',
start_month: '2002-03',
nationality: 'filipino',
gross: 131072,
dependent: 'Jun',
@@ -241,10 +274,10 @@ describe('misc', () => {
New line

Another line`,
qos: 10,
qos: 9.5,
});
},
expectedStaticValue: 'first_name=John&middle_name=Marcelo&last_name=Dela+Cruz&gender=m&birthday=1989-06-04&civil_status=married&new_registration=on&appointment_datetime=2001-09-11T06%3A09&nationality=filipino&gross=131072&dependent=Jun&notes=Test+content%0D%0A%0D%0ANew+line%0D%0A%0D%0AAnother+line&qos=10&submit=Hi',
expectedStaticValue: 'first_name=John&middle_name=Marcelo&last_name=Dela+Cruz&gender=m&birthday=1989-06-04&civil_status=married&new_registration=on&last_appointment_datetime=2001-09-11T06%3A09&new_appointment_week=2001-W51&start_month=2002-03&nationality=filipino&gross=131072&dependent=Jun&notes=Test+content%0D%0A%0D%0ANew+line%0D%0A%0D%0AAnother+line&qos=9.5&submit=Hi',
});
});
})


+ 6
- 2
src/index.ts Ver ficheiro

@@ -661,5 +661,9 @@ export const setFormValues = (
});
};

// Deprecated. Use named export instead. This default export is only for compatibility.
export default getFormValues;
// Default import is deprecated. Use named export instead. This default export is only for
// compatibility.
export default (...args: Parameters<typeof getFormValues>) => {
console.warn('Default import is deprecated. Use named export instead. This default export is only for compatibility.');
return getFormValues(...args);
};

Carregando…
Cancelar
Guardar