Skip to content

Commit

Permalink
feat(jest): resolve undefined snapshots (#4446)
Browse files Browse the repository at this point in the history
* feat(jest): revamp tests

* feat(jest): spy on functions and remove undefined snapshots
  • Loading branch information
drepram committed Aug 25, 2022
1 parent 171db0b commit fac1d65
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 55 deletions.
3 changes: 0 additions & 3 deletions components/mixins/Touch/__snapshots__/index.test.ts.snap

This file was deleted.

5 changes: 4 additions & 1 deletion components/mixins/Touch/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@ import * as index from '~/components/mixins/Touch/index'

describe('index.Touch.created', () => {
test('0', () => {
const localSpy = jest.spyOn(index.Touch, 'created')
const result: any = index.Touch.created()
expect(result).toMatchSnapshot()

expect(localSpy).toHaveBeenCalled()
expect(result).toBe(undefined)
})
})

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`index.UserPermissions.created 0 1`] = `undefined`;

exports[`index.UserPermissions.created 0 2`] = `undefined`;

exports[`index.exportForTesting.formatDevices 0 1`] = `
Array [
Object {
Expand Down
10 changes: 8 additions & 2 deletions components/mixins/UserPermissions/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@ import * as index from '~/components/mixins/UserPermissions/index'

describe('index.UserPermissions.created', () => {
test('0', () => {
const localSpy = jest.spyOn(index.UserPermissions, 'created')
const result: any = index.UserPermissions.created()
expect(result).toMatchSnapshot()

expect(localSpy).toHaveBeenCalled()
expect(result).toBe(undefined)
})
})
describe('index.UserPermissions.methods.getUserPermissions', () => {
Expand Down Expand Up @@ -55,8 +58,11 @@ describe('index.exportForTesting.formatDevices', () => {

describe('index.UserPermissions.created', () => {
test('0', () => {
const localSpy = jest.spyOn(index.UserPermissions, 'created')
const result: any = index.UserPermissions.created()
expect(result).toMatchSnapshot()

expect(localSpy).toHaveBeenCalled()
expect(result).toBe(undefined)
})
})

Expand Down
9 changes: 0 additions & 9 deletions store/sounds/__snapshots__/actions.test.ts.snap

This file was deleted.

10 changes: 4 additions & 6 deletions store/sounds/actions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ describe('Manage sounds', () => {
},
Sounds.CALL,
)

expect(result).toMatchSnapshot()
})

test('sound does not play', () => {
Expand Down Expand Up @@ -68,7 +66,8 @@ describe('Manage sounds', () => {
Sounds.CALL,
)

expect(result).toMatchSnapshot()
const localSpy = jest.spyOn(window.HTMLMediaElement.prototype, 'play')
expect(localSpy).not.toHaveBeenCalled()
})

test('sound stops', () => {
Expand All @@ -88,8 +87,6 @@ describe('Manage sounds', () => {
},
[Sounds.CALL],
)

expect(result).toMatchSnapshot()
})

test('sound does not stop', () => {
Expand All @@ -110,7 +107,8 @@ describe('Manage sounds', () => {
[Sounds.CALL],
)

expect(result).toMatchSnapshot()
const localSpy = jest.spyOn(window.HTMLMediaElement.prototype, 'play')
expect(localSpy).not.toHaveBeenCalled()
})

test('setMuteSounds', () => {
Expand Down
5 changes: 0 additions & 5 deletions store/ui/__snapshots__/types.test.ts.snap

This file was deleted.

25 changes: 0 additions & 25 deletions store/ui/types.test.ts

This file was deleted.

0 comments on commit fac1d65

Please sign in to comment.