forked from jpkleemans/vite-svg-loader
/
spec.js
55 lines (47 loc) · 1.29 KB
/
spec.js
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
describe('Vite SVG Loader', () => {
it('successfully loads test page', () => {
cy.visit('/')
cy.contains('Hello Vue 3 + Vite')
})
it('loads svg file', () => {
cy.get('#component svg')
.should('exist')
.and(($svg) => {
expect($svg[0].width.baseVal.value).to.equal(467)
})
})
it('accepts classes', () => {
cy.get('#component svg.test-svg').should('exist')
})
it('accepts other attributes', () => {
cy.get('#component svg[data-animal="bird"]').should('exist')
cy.get('#component svg[aria-hidden="true"]').should('exist')
})
it('loads svg file via <img>', () => {
cy.get('#image img')
.should('exist')
.and(($img) => {
expect($img[0].naturalWidth).to.equal(467)
})
})
it('supports async components', () => {
cy.get('#async svg')
.should('exist')
.and(($svg) => {
expect($svg[0].width.baseVal.value).to.equal(400)
})
})
it('supports ?url param', () => {
cy.get('#url').contains(/^\/assets\/test\..+\.svg/)
})
it('supports ?raw param', () => {
cy.get('#raw').contains('<?xml version="1.0"?>')
})
it('ignores root files references', () => {
cy.get('#root img')
.should('exist')
.and(($img) => {
expect($img[0].width).to.equal(355)
})
})
})