Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 | 13x 20x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 1x 2x 2x 2x 2x 2x 2x 2x 2x 13x 13x 13x 13x 13x | import { vi } from 'vitest';
/**
* d3js select method mock.
* @param id element id
* @returns selected element
*/
const select = (id: string) => {
const el = document.getElementById(id);
return {
...el,
remove: () => null,
selectAll: (id0: string) => select(id0),
select: (id1: string) => select(id1),
append: (tag: string) => {
const child = document.createElement(tag);
el?.appendChild(child);
return select(id);
},
attr: (name: string, value: string) => {
el?.setAttribute(name, value);
return select(id);
},
style: (name: string, value: string) => {
const style = el?.style;
if (typeof style !== 'undefined') {
Object.defineProperty(style, name, { value });
}
return select(id);
},
data: (range: number[]) => select(id),
enter: () => select(id),
text: (callback: (data: number, index: number) => number) => select(id),
call: (fn: (svgText: unknown, width: number) => undefined, wrapWidth: number) => void 0,
on: (event: string, callback: unknown) => select(id),
};
};
/**
* d3js lineRadial method mock.
* @param fn function
* @returns object
*/
const lineRadial = (fn: unknown) => ({
angle: (fn0: unknown) => 0,
radius: (fn1: unknown) => 0,
});
/**
* d3js scaleOrdinal method mock.
* @param range input data
* @returns
*/
const scaleOrdinal = (range: string) => (original: string) => original;
/**
* d3js scaleLinear method mock.
* @param num input data
* @returns
*/
const scaleLinear = (num: [number, number]) => ({ domain: (dnum: [number, number]) => 0 });
/**
* d3js max method mock.
* @param data input data
* @returns max value
*/
const max = (data: number[]) => Math.max(...data);
/**
* d3js range method mock.
* @param args input data
* @returns range
*/
const range = (...args: number[]) => [...args];
/**
* d3js mock value.
*/
const d3MockValue = {
scaleOrdinal,
max,
scaleLinear,
select,
range,
lineRadial,
};
/**
* Sets up the d3js library mock.
*/
export function setupD3JsMock() {
vi.mock('d3', () => d3MockValue);
}
|