Skip to content

Commit

Permalink
test: Add simple test to make yarn test pass
Browse files Browse the repository at this point in the history
`yarn test` requires at least one test to pass but we removed all tests
that were related to Search
  • Loading branch information
Ldoppea committed Nov 5, 2024
1 parent b46435c commit 4199020
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 2 deletions.
1 change: 1 addition & 0 deletions jest-setup.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
import '@testing-library/jest-dom';
import 'cross-fetch/polyfill';
2 changes: 2 additions & 0 deletions jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ export default {
'\\.(css|less|scss|sass)$': '<rootDir>/tests/__mocks__/styleMock.js',
"^@/(.*)$": "<rootDir>/src/$1",
"^manifest.webapp$": ["<rootDir>/manifest.webapp"],
// Force module uuid to resolve with the CJS entry point, because Jest does not support package.json.exports. See https://github.com/uuidjs/uuid/issues/451
"uuid": require.resolve('uuid'),
},
resetMocks: true
};
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
"@types/sharedworker": "^0.0.126",
"@typescript-eslint/eslint-plugin": "^7.1.0",
"@typescript-eslint/parser": "^7.1.0",
"cross-fetch": "^4.0.0",
"eslint": "8.57.1",
"eslint-config-prettier": "9.1.0",
"eslint-plugin-import": "2.29.1",
Expand Down
41 changes: 41 additions & 0 deletions src/helpers/client.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import CozyClient from 'cozy-client'
import PouchLink from 'cozy-pouch-link'
import { LinkPlatform } from 'cozy-pouch-link/types/types'

import { getPouchLink } from '@/helpers/client'

test('should retrieve PouchLink from client', () => {
const pouchLinkOptions = {
doctypes: ['io.cozy.files'],
initialSync: true,
periodicSync: false,
platform: {} as LinkPlatform,
doctypesReplicationOptions: {
'io.cozy.files': {
strategy: 'fromRemote'
}
}
}
const pouchLink = new PouchLink(pouchLinkOptions)
const client = new CozyClient({
links: [pouchLink]
})

const result = getPouchLink(client)

expect(result).toBe(pouchLink)
})

test('should return null if no client', () => {
const result = getPouchLink(undefined)

expect(result).toBe(null)
})

test('should return null if no PouchLink found', () => {
const client = new CozyClient()

const result = getPouchLink(client)

expect(result).toBe(null)
})
2 changes: 1 addition & 1 deletion src/helpers/client.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import CozyClient from 'cozy-client'
import PouchLink from 'cozy-pouch-link'

export const getPouchLink = (client: CozyClient): PouchLink | null => {
export const getPouchLink = (client?: CozyClient): PouchLink | null => {
if (!client) {
return null
}
Expand Down
9 changes: 8 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2382,6 +2382,13 @@ create-require@^1.1.0:
resolved "https://registry.yarnpkg.com/create-require/-/create-require-1.1.1.tgz#c1d7e8f1e5f6cfc9ff65f9cd352d37348756c333"
integrity sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==

cross-fetch@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/cross-fetch/-/cross-fetch-4.0.0.tgz#f037aef1580bb3a1a35164ea2a848ba81b445983"
integrity sha512-e4a5N8lVvuLgAWgnCrLr2PP0YyDOTHa9H/Rj54dirp61qXnNq46m82bRhNqIA5VccJtWBvPTFRV3TtvHUKPB1g==
dependencies:
node-fetch "^2.6.12"

cross-spawn@^6.0.5:
version "6.0.5"
resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-6.0.5.tgz#4a5ec7c64dfae22c3a14124dbacdee846d80cbc4"
Expand Down Expand Up @@ -4807,7 +4814,7 @@ [email protected]:
dependencies:
whatwg-url "^5.0.0"

node-fetch@^2.6.1:
node-fetch@^2.6.1, node-fetch@^2.6.12:
version "2.7.0"
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.7.0.tgz#d0f0fa6e3e2dc1d27efcd8ad99d550bda94d187d"
integrity sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==
Expand Down

0 comments on commit 4199020

Please sign in to comment.