Skip to content

Commit

Permalink
Merge pull request #49 from fingerprintjs/tests/improve-coverage
Browse files Browse the repository at this point in the history
Improve tests coverage
  • Loading branch information
Sergey Shelomentsev authored May 2, 2023
2 parents 96d688b + a996fde commit f6928ea
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
10 changes: 9 additions & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,15 @@ module.exports = {
testEnvironment: 'node',
testRegex: '/proxy/.+test.tsx?$|/management/.+test.tsx?$',
passWithNoTests: true,
collectCoverageFrom: ['./proxy/**/**.ts', '!**/index.ts', '!**/config.ts', './management/**/**.ts'],
collectCoverageFrom: [
'./proxy/**/**.ts',
'./management/**/**.ts',
'!**/index.ts',
'!**/errors/**',
'!**/config.ts',
'!**/env.ts',
'!**/handlers/**',
],
coverageReporters: ['lcov', 'json-summary', ['text', { file: 'coverage.txt', path: './' }]],
transform: {
'^.+\\.[tj]sx?$': [
Expand Down
33 changes: 33 additions & 0 deletions proxy/customer-variables/selectors.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { CustomerVariables } from './CustomerVariables'
import { EnvCustomerVariables } from './EnvCustomerVariables'
import { getAgentDownloadUri, getResultUri, getStatusUri } from './selectors'
import { CustomerVariableType } from './types'

describe('customer variables selectors', () => {
describe('from env', () => {
const getHeaderCustomerVariables = (env: typeof process.env) =>
new CustomerVariables([new EnvCustomerVariables(env)])

test('with env variables', async () => {
const env = {
[CustomerVariableType.AgentDownloadPath]: 'greiodsfkljlds',
[CustomerVariableType.RoutePrefix]: 'eifjdsnmzxcn',
[CustomerVariableType.GetResultPath]: 'eiwflsdkadlsjdsa',
}

const customerVariables = getHeaderCustomerVariables(env)

expect(await getAgentDownloadUri(customerVariables)).toBe('eifjdsnmzxcn/greiodsfkljlds')
expect(await getResultUri(customerVariables)).toBe('eifjdsnmzxcn/eiwflsdkadlsjdsa')
expect(await getStatusUri(customerVariables)).toBe('eifjdsnmzxcn/status')
})

test('with empty env', async () => {
const customerVariables = getHeaderCustomerVariables({})

expect(await getAgentDownloadUri(customerVariables)).toBe('fpjs/agent')
expect(await getResultUri(customerVariables)).toBe('fpjs/resultId')
expect(await getStatusUri(customerVariables)).toBe('fpjs/status')
})
})
})

0 comments on commit f6928ea

Please sign in to comment.