Skip to content

Commit

Permalink
mock electron-store
Browse files Browse the repository at this point in the history
  • Loading branch information
shlokamin committed Mar 5, 2024
1 parent 343c769 commit e779b20
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 20 deletions.
17 changes: 14 additions & 3 deletions __mocks__/electron-store.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
// mock electron-store
'use strict'
import { vi } from 'vitest'

Check warning on line 3 in __mocks__/electron-store.js

View workflow job for this annotation

GitHub Actions / js checks

'vi' is defined but never used

Check warning on line 3 in __mocks__/electron-store.js

View workflow job for this annotation

GitHub Actions / js checks

'vi' is defined but never used
module.exports = vi.mock(
'../app-shell/node_modules/electron-store'
)
import { DEFAULTS_V12 } from '../app-shell-odd/src/config/migrate'

const Store = function () {
// this.get = () => ({
// DEFAULTS_V12,
// })
this.store = () => ({
DEFAULTS_V12,
})
this.get = property => {
return DEFAULTS_V12[property]
}
}
export default Store

Check failure on line 17 in __mocks__/electron-store.js

View workflow job for this annotation

GitHub Actions / js checks

Prefer named exports

Check failure on line 17 in __mocks__/electron-store.js

View workflow job for this annotation

GitHub Actions / js checks

Prefer named exports
1 change: 0 additions & 1 deletion __mocks__/electron-updater.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// mock electron-updater
'use strict'
import { vi } from 'vitest'

const EventEmitter = require('events')
const autoUpdater = new EventEmitter()

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
// TODO(mc, 2020-06-11): test all release-files functions
import { vi, describe, it, expect, afterAll } from 'vitest'

Check failure on line 2 in app-shell-odd/src/system-update/__tests__/release-files.test.ts

View workflow job for this annotation

GitHub Actions / js checks

'/home/runner/work/opentrons/opentrons/node_modules/vitest/dist/index.js' imported multiple times

Check failure on line 2 in app-shell-odd/src/system-update/__tests__/release-files.test.ts

View workflow job for this annotation

GitHub Actions / js checks

'/home/runner/work/opentrons/opentrons/node_modules/vitest/dist/index.js' imported multiple times
import path from 'path'
import { describe, afterAll, it } from 'vitest'

Check failure on line 4 in app-shell-odd/src/system-update/__tests__/release-files.test.ts

View workflow job for this annotation

GitHub Actions / js checks

'describe' is already defined

Check failure on line 4 in app-shell-odd/src/system-update/__tests__/release-files.test.ts

View workflow job for this annotation

GitHub Actions / js checks

'afterAll' is already defined

Check failure on line 4 in app-shell-odd/src/system-update/__tests__/release-files.test.ts

View workflow job for this annotation

GitHub Actions / js checks

'it' is already defined

Check failure on line 4 in app-shell-odd/src/system-update/__tests__/release-files.test.ts

View workflow job for this annotation

GitHub Actions / js checks

'/home/runner/work/opentrons/opentrons/node_modules/vitest/dist/index.js' imported multiple times

Check failure on line 4 in app-shell-odd/src/system-update/__tests__/release-files.test.ts

View workflow job for this annotation

GitHub Actions / js checks

'describe' is already defined

Check failure on line 4 in app-shell-odd/src/system-update/__tests__/release-files.test.ts

View workflow job for this annotation

GitHub Actions / js checks

'afterAll' is already defined

Check failure on line 4 in app-shell-odd/src/system-update/__tests__/release-files.test.ts

View workflow job for this annotation

GitHub Actions / js checks

'it' is already defined

Check failure on line 4 in app-shell-odd/src/system-update/__tests__/release-files.test.ts

View workflow job for this annotation

GitHub Actions / js checks

'/home/runner/work/opentrons/opentrons/node_modules/vitest/dist/index.js' imported multiple times
import { promises as fs } from 'fs'
import fse from 'fs-extra'
import tempy from 'tempy'

import { cleanupReleaseFiles } from '../release-files'
vi.mock('electron-store')

describe('system release files utilities', () => {
const tempDirs: string[] = []
Expand All @@ -15,8 +17,8 @@ describe('system release files utilities', () => {
return dir
}

afterAll(() => {
return Promise.all(tempDirs.map(d => fse.remove(d)))
afterAll(async () => {
await Promise.all(tempDirs.map(d => fse.remove(d)))
})

describe('cleanupReleaseFiles', () => {
Expand Down
14 changes: 0 additions & 14 deletions app-shell/__mocks__/usb-detection.js

This file was deleted.

2 changes: 2 additions & 0 deletions setup-vitest.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { cleanup } from '@testing-library/react'
import { vi, afterEach } from 'vitest'

vi.mock('protocol-designer/src/labware-defs/utils')
vi.mock('electron-store')
vi.mock('electron-updater')
vi.mock('electron')

process.env.OT_PD_VERSION = 'fake_PD_version'
Expand Down

0 comments on commit e779b20

Please sign in to comment.