(browser: Playwright)
| 1855 | } |
| 1856 | |
| 1857 | export function createMultiDomMatcher(browser: Playwright) { |
| 1858 | /** |
| 1859 | * @param tag - tag name, e.g. 'meta' |
| 1860 | * @param queryKey - query key, e.g. 'property' |
| 1861 | * @param domAttributeField - dom attribute field, e.g. 'content' |
| 1862 | * @param expected - expected object, e.g. { description: 'my description' } |
| 1863 | * @returns {Promise<void>} - promise that resolves when the check is done |
| 1864 | * |
| 1865 | * @example |
| 1866 | * const matchMultiDom = createMultiDomMatcher(browser) |
| 1867 | * await matchMultiDom('meta', 'property', 'content', { |
| 1868 | * description: 'description', |
| 1869 | * 'og:title': 'title', |
| 1870 | * 'twitter:title': 'title' |
| 1871 | * }) |
| 1872 | * |
| 1873 | */ |
| 1874 | return async ( |
| 1875 | tag: string, |
| 1876 | queryKey: string, |
| 1877 | domAttributeField: string, |
| 1878 | expected: Record<string, string | string[] | undefined | null> |
| 1879 | ) => { |
| 1880 | await Promise.all( |
| 1881 | Object.keys(expected).map(async (key) => { |
| 1882 | return checkMeta( |
| 1883 | browser, |
| 1884 | key, |
| 1885 | expected[key], |
| 1886 | queryKey, |
| 1887 | tag, |
| 1888 | domAttributeField |
| 1889 | ) |
| 1890 | }) |
| 1891 | ) |
| 1892 | } |
| 1893 | } |
| 1894 | |
| 1895 | export const checkMetaNameContentPair = ( |
| 1896 | browser: Playwright, |
no test coverage detected