import React from '../../src/May'
var ReactDOM = React;
describe('SVG元素', function () {
// this.timeout(200000);
// before(async () => {
// await beforeHook()
// })
// after(async () => {
// await afterHook(false)
// })
var body = document.body,
div
beforeEach(function () {
div = document.createElement('div')
body.appendChild(div)
})
afterEach(function () {
body.removeChild(div)
})
var rsvg = /^\[object SVG\w*Element\]$/
it('circle', async () => {
var s = ReactDOM.render(
, div)
expect(rsvg.test(s.firstChild)).toBe(true)
})
it('ellipse', async() => {
var s = ReactDOM.render(
, div)
expect(rsvg.test(s.firstChild)).toBe(true)
})
it('line', async() => {
var s = ReactDOM.render(
, div)
expect(rsvg.test(s.firstChild)).toBe(true)
})
it('path', async() => {
var s = ReactDOM.render(
, div)
expect(rsvg.test(s.firstChild)).toBe(true)
})
it('polygon', async() => {
var s = ReactDOM.render(
, div)
expect(rsvg.test(s.firstChild)).toBe(true)
})
it('polyline', async() => {
var s = ReactDOM.render(
, div)
expect(rsvg.test(s.firstChild)).toBe(true)
})
it('rect', async() => {
var s = ReactDOM.render(
, div)
expect(rsvg.test(s.firstChild)).toBe(true)
})
it('defs', async() => {
var s = ReactDOM.render(
, div)
expect(rsvg.test(s.firstChild)).toBe(true)
})
//svg一般用的不会太复杂,先支持比较简单的
/*it('attribute throw error', async() => {
var a = {}
a.toString = function () {
throw "xxx"
}
var s = ReactDOM.render(React.createElement('div', {aaa: a}), div)
expect(s.getAttribute('aaa')).toBeNull()
})
it('use元素的xlinkHref', async() => {
function Test() {
return (
)
}
ReactDOM.render(
, div)
var el = div.getElementsByTagName('use')
expect(el.length).toBe(1)
expect(el[0].getAttribute('xlink:href')).toBe('#twitter')
expect(el[0].getAttribute('xlink:role')).toBe('#aaa')
})*/
})