Skip to content

Commit

Permalink
usebruno#2806: add tests for search filter
Browse files Browse the repository at this point in the history
  • Loading branch information
N-Ziermann committed Aug 11, 2024
1 parent 2b3bcbc commit c4833db
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
10 changes: 10 additions & 0 deletions packages/bruno-app/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const { compilerOptions } = require('./jsconfig.json');
const { pathsToModuleNameMapper } = require('ts-jest');

/** @type {import('ts-jest').JestConfigWithTsJest} */
module.exports = {
preset: 'ts-jest',
modulePaths: [compilerOptions.baseUrl],
moduleNameMapper: pathsToModuleNameMapper(compilerOptions.paths),
transform: { '^.+\\.(js|jsx)$': 'babel-jest' }
};
17 changes: 17 additions & 0 deletions packages/bruno-app/src/utils/collections/search.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
const { doesRequestMatchSearchText } = require('./search');

const sampleRequest = { name: 'MyRequestName', request: { url: '{{myServer}}/api/v1/user/:userId' } };

describe('Collection Utils - Search - doesRequestMatchSearchText', () => {
it('should match when no searchText is given', () => {
expect(doesRequestMatchSearchText(sampleRequest)).toBeTruthy();
});

it('should match the requests name (case-insensitive)', () => {
expect(doesRequestMatchSearchText(sampleRequest, 'equestNam')).toBeTruthy();
});

it('should match the requests url (case-insensitive)', () => {
expect(doesRequestMatchSearchText(sampleRequest, '/USER/:userid')).toBeTruthy();
});
});

0 comments on commit c4833db

Please sign in to comment.