feat: randomize functions and example
gitea/salix-front/pipeline/pr-dev This commit looks good
Details
gitea/salix-front/pipeline/pr-dev This commit looks good
Details
This commit is contained in:
parent
6276843613
commit
c4f2ea032c
|
@ -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(
|
||||
|
|
|
@ -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 };
|
||||
|
|
Loading…
Reference in New Issue