Add selector utils

provides easy access to forms and tables
This commit is contained in:
Jannis Mattheis 2018-09-14 20:50:05 +02:00
parent 8165534bb6
commit e0d8596e1c
1 changed files with 24 additions and 0 deletions

24
ui/src/tests/selector.ts Normal file
View File

@ -0,0 +1,24 @@
export const heading = () => {
return `main h1`;
};
export const table = (tableSelector: string) => {
return {
selector: () => tableSelector,
rows: () => `${tableSelector} tbody tr`,
row: (index: number) => `${tableSelector} tbody tr:nth-child(${index})`,
cell: (index: number, col: number, suffix = '') =>
`${tableSelector} tbody tr:nth-child(${index}) td:nth-child(${col}) ${suffix}`,
};
};
export const form = (dialogSelector: string) => {
return {
selector: () => dialogSelector,
input: (selector: string) => `${dialogSelector} ${selector} input`,
textarea: (selector: string) => `${dialogSelector} ${selector} textarea[type=text]`,
button: (selector: string) => `${dialogSelector} button${selector}`,
};
};
export const $confirmDialog = form('.confirm-dialog');