0
0
Fork 0

feat: randomize functions and example

This commit is contained in:
Javier Segarra 2024-11-24 17:01:54 +01:00
parent 6276843613
commit c4f2ea032c
2 changed files with 21 additions and 3 deletions

View File

@ -1,3 +1,5 @@
const { randomNumber, randomString } = require('../../support');
describe('VnLocation', () => {
const locationOptions = '[role="listbox"] > div.q-virtual-scroll__content > .q-item';
const dialogInputs = '.q-dialog label input';
@ -115,9 +117,9 @@ describe('VnLocation', () => {
checkVnLocation(postCode, province);
});
it('Create city', () => {
const postCode = '9011';
const province = 'Saskatchew';
it.only('Create city', () => {
const postCode = randomNumber();
const province = randomString({ length: 4 });
cy.get(createLocationButton).click();
cy.get(dialogInputs).eq(0).type(postCode);
cy.get(

View File

@ -15,3 +15,19 @@
import './commands';
function randomString(options = { length: 10 }) {
let possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
return randomizeValue(possible, options);
}
function randomNumber(options = { length: 10 }) {
let possible = '0123456789';
return randomizeValue(possible, options);
}
function randomizeValue(characterSet, options) {
return Array.from({ length: options.length }, () =>
characterSet.charAt(Math.floor(Math.random() * characterSet.length))
).join('');
}
export { randomString, randomNumber, randomizeValue };