Skip to content

Commit 1964772

Browse files
committed
refactor: 🏷️ update types
lots of optional chaining
1 parent 1e1c996 commit 1964772

19 files changed

+71
-55
lines changed

src/lib/components/anchor-fm.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ describe('AnchorFm', () => {
3535
})
3636
const iframe = container.querySelector('iframe')
3737

38-
expect(iframe.parentElement.style.height).toBe('200px')
39-
expect(iframe.parentElement.style.width).toBe('50%')
38+
expect(iframe?.parentElement?.style.height).toBe('200px')
39+
expect(iframe?.parentElement?.style.width).toBe('50%')
4040
})
4141

4242
it('renders with a GeneralObserver', async () => {

src/lib/components/buzzsprout.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ describe('Buzzsprout', () => {
3434
})
3535
const iframe = container.querySelector('iframe')
3636

37-
expect(iframe.parentElement.style.height).toBe('200px')
38-
expect(iframe.parentElement.style.width).toBe('50%')
37+
expect(iframe?.parentElement?.style.height).toBe('200px')
38+
expect(iframe?.parentElement?.style.width).toBe('50%')
3939
})
4040

4141
it('renders with a GeneralObserver', async () => {

src/lib/components/code-pen.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ describe('CodePen', () => {
4646
disable_observer: true,
4747
})
4848
const iframe = container.querySelector('iframe')
49-
expect(iframe.getAttribute('style')).toContain('height: 200px')
50-
expect(iframe.getAttribute('style')).toContain('width: 50%')
49+
expect(iframe?.getAttribute('style')).toContain('height: 200px')
50+
expect(iframe?.getAttribute('style')).toContain('width: 50%')
5151
})
5252

5353
it('renders with a GeneralObserver', async () => {

src/lib/components/deezer.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ describe('Deezer', () => {
3838
})
3939
const iframe = container.querySelector('iframe')
4040

41-
expect(iframe.getAttribute('style')).toContain(`height: 200px`)
42-
expect(iframe.getAttribute('style')).toContain(`width: 50%`)
41+
expect(iframe?.getAttribute('style')).toContain(`height: 200px`)
42+
expect(iframe?.getAttribute('style')).toContain(`width: 50%`)
4343
})
4444

4545
it('renders with a GeneralObserver', async () => {

src/lib/components/general-observer.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@
1414
1515
const hasIntersectionObserver =
1616
typeof IntersectionObserver !== 'undefined'
17-
let observer =
17+
let observer: IntersectionObserver | null =
1818
hasIntersectionObserver && !disable_observer
1919
? new IntersectionObserver(
2020
entries => {
2121
entries.forEach(entry => {
2222
if (entry.intersectionRatio >= threshold) {
2323
loaded = true
24-
observer.disconnect()
24+
observer!.disconnect()
2525
}
2626
})
2727
},

src/lib/components/generic-embed.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ describe('GenericEmbed', () => {
4141
})
4242
const iframe = container.querySelector('iframe')
4343

44-
expect(iframe.getAttribute('height')).toBe('200px')
45-
expect(iframe.getAttribute('width')).toBe('50%')
44+
expect(iframe?.getAttribute('height')).toBe('200px')
45+
expect(iframe?.getAttribute('width')).toBe('50%')
4646
})
4747

4848
it('renders with a GeneralObserver', async () => {

src/lib/components/gist.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ describe('Gist', () => {
3131
})
3232
const iframe = container.querySelector('iframe')
3333

34-
expect(iframe.getAttribute('style')).toContain(`height: 200px`)
35-
expect(iframe.getAttribute('style')).toContain(`width: 50%`)
34+
expect(iframe?.getAttribute('style')).toContain(`height: 200px`)
35+
expect(iframe?.getAttribute('style')).toContain(`width: 50%`)
3636
})
3737

3838
it('renders with a GeneralObserver', async () => {

src/lib/components/guild.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ describe('Guild', () => {
3434
})
3535
const iframe = container.querySelector('iframe')
3636

37-
expect(iframe.parentElement.style.height).toBe('350px')
38-
expect(iframe.parentElement.style.width).toBe('80%')
37+
expect(iframe?.parentElement?.style.height).toBe('350px')
38+
expect(iframe?.parentElement?.style.width).toBe('80%')
3939
})
4040

4141
it('renders with a GeneralObserver', async () => {

src/lib/components/relive.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ describe('Relive', () => {
2929
disable_observer: true,
3030
})
3131
const iframe = container.querySelector('iframe')
32-
const div = iframe.parentElement
33-
expect(div.style.width).toBe('80%')
32+
const div = iframe?.parentElement
33+
expect(div?.style.width).toBe('80%')
3434
})
3535

3636
it('renders with a GeneralObserver', async () => {

src/lib/components/slides.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ describe('Slides', () => {
3838
})
3939
const iframe = container.querySelector('iframe')
4040

41-
expect(iframe.getAttribute('width')).toBe('80%')
42-
expect(iframe.getAttribute('height')).toBe('300px')
41+
expect(iframe?.getAttribute('width')).toBe('80%')
42+
expect(iframe?.getAttribute('height')).toBe('300px')
4343
})
4444

4545
it('renders with a GeneralObserver', async () => {

0 commit comments

Comments
 (0)