Skip to content

Commit

Permalink
refactor: use app names for detection (will-stone#593)
Browse files Browse the repository at this point in the history
This should be much faster but currently relies on people not renaming
apps. Will possibly look into users providing their own config...
  • Loading branch information
will-stone authored Dec 10, 2022
1 parent 905681b commit e73624b
Show file tree
Hide file tree
Showing 21 changed files with 245 additions and 366 deletions.
12 changes: 6 additions & 6 deletions __mocks__/electron.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const eventEmitter = new EventTarget()
let clipboard

module.exports = {
app: jest.fn(),
BrowserWindow: function () {
return {
webContents: {
Expand All @@ -21,12 +22,6 @@ module.exports = {
},
}
},
Notification: function () {
return {
show: jest.fn,
}
},
app: jest.fn(),
clipboard: {
readText: () => clipboard,
writeText: (string) => (clipboard = string),
Expand All @@ -47,6 +42,11 @@ module.exports = {
send: jest.fn(),
},
match: jest.fn(),
Notification: function () {
return {
show: jest.fn,
}
},
remote: {
getCurrentWindow() {
return {
Expand Down
30 changes: 15 additions & 15 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"website-css:watch": "npx tailwindcss -i node_modules/tailwindcss/tailwind.css -o ./docs/style.css --content docs/index.html -m --watch"
},
"dependencies": {
"file-icon": "^5.1.0"
"file-icon": "^5.1.1"
},
"devDependencies": {
"@commitlint/cli": "^17.1.2",
Expand All @@ -59,7 +59,7 @@
"@types/react-dom": "^18.0.6",
"@types/react-redux": "^7.1.24",
"@vercel/webpack-asset-relocator-loader": "^1.7.3",
"@will-stone/eslint-config-base": "^4.0.0",
"@will-stone/eslint-config-base": "^5.0.0",
"@will-stone/eslint-config-jest": "^2.2.2",
"@will-stone/eslint-config-node": "^2.0.1",
"@will-stone/eslint-config-prettier": "^2.0.1",
Expand All @@ -78,7 +78,6 @@
"eslint": "^8.24.0",
"eslint-plugin-tailwindcss": "^3.6.2",
"fast-deep-equal": "^3.1.3",
"file-icon": "^5.1.0",
"fork-ts-checker-webpack-plugin": "^7.2.13",
"husky": "^8.0.1",
"immer": "^9.0.15",
Expand Down
10 changes: 1 addition & 9 deletions src/config/apps.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
import { getKeys } from '../shared/utils/get-keys'
import { apps } from './apps'

test.each(getKeys(apps))('%s should have name', (input) => {
expect(apps[input]).toHaveProperty('name')
expect(typeof apps[input].name).toBe('string')
})

test.each(getKeys(apps))(
'%s should not include anything but allowed keys',
(input) => {
Expand All @@ -20,10 +15,7 @@ test.each(getKeys(apps))(
)

test('should have apps in alphabetical order by name', () => {
const appNames = Object.values(apps).map((appDetails) =>
appDetails.name.toLowerCase(),
)

const appNames = Object.keys(apps).map((appName) => appName.toLowerCase())
const sortedAppNames = [...appNames].sort()
expect(appNames).toStrictEqual(sortedAppNames)
})
Loading

0 comments on commit e73624b

Please sign in to comment.