Skip to content

Commit

Permalink
chore: prettier format
Browse files Browse the repository at this point in the history
  • Loading branch information
huang-julien committed Feb 15, 2024
1 parent 919cd02 commit 7e20371
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
7 changes: 2 additions & 5 deletions cypress/e2e/type.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,9 @@ describe("cy.realType", () => {
});

it("can type text with emoji and cyrillic characters", () => {
const msg = "cypress-real-events is awesome! ❤️❤️❤️❤️❤️❤️ В"
const msg = "cypress-real-events is awesome! ❤️❤️❤️❤️❤️❤️ В";
cy.realType(msg);

cy.get("input[name=q]").should(
"have.value",
msg,
);
cy.get("input[name=q]").should("have.value", msg);
});
});
8 changes: 5 additions & 3 deletions src/commands/realPress.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,16 @@ export interface RealPressOptions {
}

// Emoji Unicode range
const EMOJI_RE = /[\u{1F600}-\u{1F64F}\u{1F300}-\u{1F5FF}\u{1F680}-\u{1F6FF}\u{1F700}-\u{1F77F}\u{1F780}-\u{1F7FF}\u{1F800}-\u{1F8FF}\u{1F900}-\u{1F9FF}\u{1FA00}-\u{1FA6F}\u{2600}-\u{26FF}\u{2700}-\u{27BF}]/u;
const EMOJI_RE =
/[\u{1F600}-\u{1F64F}\u{1F300}-\u{1F5FF}\u{1F680}-\u{1F6FF}\u{1F700}-\u{1F77F}\u{1F780}-\u{1F7FF}\u{1F800}-\u{1F8FF}\u{1F900}-\u{1F9FF}\u{1FA00}-\u{1FA6F}\u{2600}-\u{26FF}\u{2700}-\u{27BF}]/u;

function isEmoji(char: string) {
return EMOJI_RE.test(char);
}

function getKeyDefinition(key: string) {
const keyDefinition = keyCodeDefinitions[key as keyof typeof keyCodeDefinitions];
const keyDefinition =
keyCodeDefinitions[key as keyof typeof keyCodeDefinitions];

if (!keyDefinition) {
if (key.length === 1 || isEmoji(key)) {
Expand All @@ -34,7 +36,7 @@ function getKeyDefinition(key: string) {
code: `Key${key.toUpperCase()}`,
location: 0,
windowsVirtualKeyCode: key.charCodeAt(0),
}
};
}
throw new Error(`Unsupported key '${key}'.`);
}
Expand Down
1 change: 0 additions & 1 deletion src/commands/realType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ export interface RealTypeOptions {
log?: boolean;
}


/** @ignore this, update documentation for this function at index.d.ts */
export async function realType(text: string, options: RealTypeOptions = {}) {
let log;
Expand Down

0 comments on commit 7e20371

Please sign in to comment.