/
tag.cy.tsx
121 lines (103 loc) · 2.88 KB
/
tag.cy.tsx
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
import React from 'react'
import Tag from './tag'
describe('Tag', () => {
const aliases = [
'route',
'agent',
'primitive',
'dom',
]
const statuses = [
'successful-status',
'warned-status',
'failed-status',
]
const misc = [
'count',
]
const MockCommandContainer = ({ children }) => (
<div style={{ backgroundColor: '#171926', minHeight: '20px' }}>
{children}
</div>
)
it('types', () => {
cy.mount(
<MockCommandContainer>
<h1 style={{ fontSize: '16px', paddingBottom: '5px' }}>Tag Types</h1>
<h2 style={{ paddingBottom: '5px' }}>Alias Tags:</h2>
{aliases.map((type) => (
<div key={type} style={{ height: '20px' }}>
<Tag content={type} type={type} />
</div>
))}
<h2 style={{ paddingBottom: '5px' }}>Status Tags:</h2>
{statuses.map((type) => (
<div key={type} style={{ height: '20px' }}>
<Tag content={type} type={type} />
</div>
))}
<h2 style={{ paddingBottom: '5px' }}>Misc Tags:</h2>
{misc.map((type) => (
<div key={type} style={{ height: '20px' }}>
<Tag content={type} type={type} />
</div>
))}
</MockCommandContainer>,
)
aliases.concat(statuses).forEach((type) => {
cy.contains(type)
})
cy.contains('dom').realHover()
cy.get('.cy-tooltip').should('not.exist')
cy.percySnapshot()
})
it('with count', () => {
cy.mount(
<MockCommandContainer>
<h1 style={{ fontSize: '16px', paddingBottom: '5px' }}>Tag Types</h1>
<h2 style={{ paddingBottom: '5px' }}>Alias Tags:</h2>
{aliases.map((type, index) => (
<div key={type} style={{ height: '20px' }}>
<Tag content={type} type={type} count={index} />
</div>
))}
</MockCommandContainer>,
)
aliases.forEach((type, index) => {
if (index === 0) {
return cy.contains(type).should('not.contain', index)
}
return cy.contains(type).siblings().contains(index)
})
cy.percySnapshot()
})
it('with tooltip', () => {
cy.mount(
<MockCommandContainer>
<Tag
content={<span>Alias</span>}
type='primitive'
tooltipMessage={'Alias was referenced!'}
/>
</MockCommandContainer>,
)
cy.contains('Alias').realHover()
cy.get('.cy-tooltip').contains('Alias was referenced!')
cy.percySnapshot()
})
it('with customClassName', () => {
cy.mount(
<MockCommandContainer>
<Tag
content="Alias"
type='primitive'
count={3}
customClassName="command-alias"
/>
</MockCommandContainer>,
)
cy.get('.reporter-tag').should('have.class', 'command-alias')
cy.get('.reporter-tag-count').should('have.class', 'command-alias-count')
cy.percySnapshot()
})
})