2018-03-10 08:42:59 +08:00
|
|
|
let NewD3 = function () {
|
2022-09-05 01:00:47 +05:30
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
2021-11-18 19:17:00 +01:00
|
|
|
function returnThis() {
|
|
|
|
return this;
|
2019-07-23 21:33:03 -07:00
|
|
|
}
|
2018-03-10 08:42:59 +08:00
|
|
|
return {
|
|
|
|
append: function () {
|
2021-11-18 19:17:00 +01:00
|
|
|
return NewD3();
|
2019-07-23 21:28:48 -07:00
|
|
|
},
|
2019-07-23 21:33:03 -07:00
|
|
|
lower: returnThis,
|
|
|
|
attr: returnThis,
|
|
|
|
style: returnThis,
|
|
|
|
text: returnThis,
|
2018-03-10 08:42:59 +08:00
|
|
|
0: {
|
|
|
|
0: {
|
|
|
|
getBBox: function () {
|
|
|
|
return {
|
|
|
|
height: 10,
|
2021-11-18 19:17:00 +01:00
|
|
|
width: 20,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
};
|
2018-03-10 08:42:59 +08:00
|
|
|
|
|
|
|
export const select = function () {
|
2021-11-18 19:17:00 +01:00
|
|
|
return new NewD3();
|
|
|
|
};
|
2018-03-10 08:42:59 +08:00
|
|
|
|
|
|
|
export const selectAll = function () {
|
2021-11-18 19:17:00 +01:00
|
|
|
return new NewD3();
|
|
|
|
};
|
2018-03-17 23:19:13 +08:00
|
|
|
|
2021-11-18 19:17:00 +01:00
|
|
|
export const curveBasis = 'basis';
|
|
|
|
export const curveLinear = 'linear';
|
|
|
|
export const curveCardinal = 'cardinal';
|
2019-07-23 19:11:31 -07:00
|
|
|
|
|
|
|
export const MockD3 = (name, parent) => {
|
2021-11-18 19:17:00 +01:00
|
|
|
const children = [];
|
2019-07-23 19:11:31 -07:00
|
|
|
const elem = {
|
2021-11-18 19:17:00 +01:00
|
|
|
get __children() {
|
|
|
|
return children;
|
|
|
|
},
|
|
|
|
get __name() {
|
|
|
|
return name;
|
|
|
|
},
|
|
|
|
get __parent() {
|
|
|
|
return parent;
|
|
|
|
},
|
|
|
|
};
|
2019-07-23 19:11:31 -07:00
|
|
|
elem.append = (name) => {
|
2021-11-18 19:17:00 +01:00
|
|
|
const mockElem = MockD3(name, elem);
|
|
|
|
children.push(mockElem);
|
|
|
|
return mockElem;
|
|
|
|
};
|
|
|
|
elem.lower = jest.fn(() => elem);
|
|
|
|
elem.attr = jest.fn(() => elem);
|
|
|
|
elem.text = jest.fn(() => elem);
|
|
|
|
elem.style = jest.fn(() => elem);
|
|
|
|
return elem;
|
|
|
|
};
|