Skip to content

Commit c7fc671

Browse files
committed
eslint auto-fixes
1 parent 7ce37b7 commit c7fc671

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

src/portal-popper.spec.jsx

+23
Original file line numberDiff line numberDiff line change
@@ -31,44 +31,51 @@ const popperStub = (popperInstance) => sinon.stub().returns(popperInstance)
3131
describe('<PortalPopper />', () => {
3232
it('renders a <Portal /> with a placement class', () => {
3333
const component = shallow(<PortalPopper {...getProps()} />)
34+
3435
expect(component.find('.tooltip-top')).to.exist
3536
})
3637

3738
it('renders a <Portal /> with default styles', () => {
3839
const component = shallow(<PortalPopper {...getProps()} />)
3940
const style = component.find('.tooltip-top').prop('style')
41+
4042
expect(style.position).to.equal('absolute')
4143
expect(style.transform).to.equal('translate3d(0px, 0px, 0)')
4244
expect(style.WebkitTransform).to.equal('translate3d(0px, 0px, 0)')
4345
})
4446

4547
it('renders the title specified', () => {
4648
const component = shallow(<PortalPopper {...getProps()} />)
49+
4750
expect(component.find('span')).to.have.text('tooltip title')
4851
})
4952

5053
it('renders the tooltip arrow with default styles', () => {
5154
const component = shallow(<PortalPopper {...getProps({})} />)
5255
const style = component.find('.tooltip-arrow').prop('style')
56+
5357
expect(style.left).to.equal(0)
5458
expect(style.top).to.equal(0)
5559
})
5660

5761
it('renders with className specified', () => {
5862
const component = shallow(<PortalPopper {...getProps({ className: 'custom-class' })} />)
63+
5964
expect(component.find('.custom-class')).to.exist
6065
expect(component.find('.custom-class-top')).to.exist
6166
expect(component.find('.custom-class-arrow')).to.exist
6267
})
6368

6469
it('uses last className as prefix if multiple', () => {
6570
const component = shallow(<PortalPopper {...getProps({ className: 'custom-class tooltip' })} />)
71+
6672
expect(component.find('.custom-class').prop('className')).to.equal('custom-class tooltip tooltip-top')
6773
expect(component.find('.tooltip-arrow')).to.exist
6874
})
6975

7076
it('creates Popper instance with the right props', () => {
7177
const Popper = popperStub(popperInstanceStub())
78+
7279
mount(<PortalPopper {...getProps({ Popper, boundary: 'boundary' })} />)
7380
expect(Popper).to.have.been.called
7481
expect(Popper.firstCall.args[0]).to.equal('target node')
@@ -83,13 +90,15 @@ describe('<PortalPopper />', () => {
8390

8491
it('calls scheduleUpdate() on the Popper instance', () => {
8592
const popperInstance = popperInstanceStub()
93+
8694
mount(<PortalPopper {...getProps({ Popper: popperStub(popperInstance) })} />)
8795
expect(popperInstance.scheduleUpdate).to.have.been.called
8896
})
8997

9098
it('destroys the Popper instance on unmount', () => {
9199
const popperInstance = popperInstanceStub()
92100
const component = mount(<PortalPopper {...getProps({ Popper: popperStub(popperInstance) })} />)
101+
93102
component.unmount()
94103
expect(popperInstance.destroy).to.have.been.called
95104
})
@@ -99,9 +108,11 @@ describe('<PortalPopper />', () => {
99108
const popperInstance = popperInstanceStub()
100109
const Popper = popperStub(popperInstance)
101110
const component = mount(<PortalPopper {...getProps({ Popper })} />)
111+
102112
Popper.firstCall.args[2].onUpdate({ offsets: { arrow: { left: 5, top: 10 } } })
103113
component.update()
104114
const style = component.find('.tooltip-arrow').prop('style')
115+
105116
expect(style.left).to.equal(5)
106117
expect(style.top).to.equal(10)
107118
})
@@ -110,9 +121,11 @@ describe('<PortalPopper />', () => {
110121
const popperInstance = popperInstanceStub()
111122
const Popper = popperStub(popperInstance)
112123
const component = mount(<PortalPopper {...getProps({ Popper })} />)
124+
113125
Popper.firstCall.args[2].onUpdate({ offsets: {} })
114126
component.update()
115127
const style = component.find('.tooltip-arrow').prop('style')
128+
116129
expect(style.left).to.equal(0)
117130
expect(style.top).to.equal(0)
118131
})
@@ -121,9 +134,11 @@ describe('<PortalPopper />', () => {
121134
const popperInstance = popperInstanceStub()
122135
const Popper = popperStub(popperInstance)
123136
const component = mount(<PortalPopper {...getProps({ Popper })} />)
137+
124138
Popper.firstCall.args[2].onUpdate({ offsets: { arrow: { top: 20 } } })
125139
component.update()
126140
const style = component.find('.tooltip-arrow').prop('style')
141+
127142
expect(style.left).to.equal(null)
128143
expect(style.top).to.equal(20)
129144
})
@@ -132,9 +147,11 @@ describe('<PortalPopper />', () => {
132147
const popperInstance = popperInstanceStub()
133148
const Popper = popperStub(popperInstance)
134149
const component = mount(<PortalPopper {...getProps({ Popper })} />)
150+
135151
Popper.firstCall.args[2].onUpdate({ offsets: { arrow: { left: 7.2, top: 20.8 } } })
136152
component.update()
137153
const style = component.find('.tooltip-arrow').prop('style')
154+
138155
expect(style.left).to.equal(7)
139156
expect(style.top).to.equal(21)
140157
})
@@ -143,9 +160,11 @@ describe('<PortalPopper />', () => {
143160
const popperInstance = popperInstanceStub()
144161
const Popper = popperStub(popperInstance)
145162
const component = mount(<PortalPopper {...getProps({ Popper })} />)
163+
146164
Popper.firstCall.args[2].onUpdate({ offsets: { popper: { position: 'relative', left: 2, top: 4 } } })
147165
component.update()
148166
const style = component.find('.tooltip-top').prop('style')
167+
149168
expect(style.position).to.equal('relative')
150169
expect(style.transform).to.equal('translate3d(2px, 4px, 0)')
151170
expect(style.WebkitTransform).to.equal('translate3d(2px, 4px, 0)')
@@ -155,9 +174,11 @@ describe('<PortalPopper />', () => {
155174
const popperInstance = popperInstanceStub()
156175
const Popper = popperStub(popperInstance)
157176
const component = mount(<PortalPopper {...getProps({ Popper })} />)
177+
158178
Popper.firstCall.args[2].onUpdate({ offsets: {} })
159179
component.update()
160180
const style = component.find('.tooltip-top').prop('style')
181+
161182
expect(style.position).to.equal('absolute')
162183
expect(style.transform).to.equal('translate3d(0px, 0px, 0)')
163184
expect(style.WebkitTransform).to.equal('translate3d(0px, 0px, 0)')
@@ -167,9 +188,11 @@ describe('<PortalPopper />', () => {
167188
const popperInstance = popperInstanceStub()
168189
const Popper = popperStub(popperInstance)
169190
const component = mount(<PortalPopper {...getProps({ Popper })} />)
191+
170192
Popper.firstCall.args[2].onUpdate({ offsets: { popper: { left: 15.2, top: 2.8 } } })
171193
component.update()
172194
const style = component.find('.tooltip-top').prop('style')
195+
173196
expect(style.transform).to.equal('translate3d(15px, 3px, 0)')
174197
expect(style.WebkitTransform).to.equal('translate3d(15px, 3px, 0)')
175198
})

src/portal.jsx

+3
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,19 @@ class Portal extends Component {
1212
const appendTo = this.props.appendTo
1313
const id = `portal-${Portal.idNum++}`
1414
let element = appendTo.ownerDocument.getElementById(id)
15+
1516
if (!element) {
1617
element = appendTo.ownerDocument.createElement('div')
1718
element.id = id
1819
appendTo.appendChild(element)
1920
}
21+
2022
this._element = element
2123
}
2224

2325
componentWillUnmount () {
2426
const appendTo = this.props.appendTo
27+
2528
appendTo.removeChild(this._element)
2629
}
2730

src/portal.spec.jsx

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ describe('<Portal />', () => {
2424
it('removes the portal div on unmount', () => {
2525
Portal.idNum = 0
2626
const component = mount(<Portal />)
27+
2728
component.unmount()
2829
expect(document.getElementById('portal-0')).not.to.exist
2930
})

0 commit comments

Comments
 (0)