| "use strict"; |
| Object.defineProperty(exports, "__esModule", { value: true }); |
| const dedup_1 = require("./dedup"); |
| describe('dedup', () => { |
| beforeEach(async () => { |
| await (0, dedup_1.clearDedupCache)(); |
| }); |
| describe('isDuplicateIssue', () => { |
| it('returns false for new issue', async () => { |
| const result = await (0, dedup_1.isDuplicateIssue)('src/index.ts', 'async', 10, 15, 'Missing await on async call'); |
| expect(result).toBe(false); |
| }); |
| it('returns true after registering', async () => { |
| await (0, dedup_1.registerIssue)('src/index.ts', 'async', 10, 15, 'Missing await on async call'); |
| const result = await (0, dedup_1.isDuplicateIssue)('src/index.ts', 'async', 10, 15, 'Missing await on async call'); |
| expect(result).toBe(true); |
| }); |
| it('returns true for semantic duplicate with weak phrases removed', async () => { |
| await (0, dedup_1.registerIssue)('src/utils.ts', 'async', 10, 15, 'The function might be missing an await call'); |
| const result = await (0, dedup_1.isDuplicateIssue)('src/utils.ts', 'async', 10, 15, 'Function missing await call'); |
| expect(result).toBe(true); |
| }); |
| it('does not conflate different types', async () => { |
| await (0, dedup_1.registerIssue)('src/index.ts', 'async', 20, 25, 'Missing await on async call'); |
| const result = await (0, dedup_1.isDuplicateIssue)('src/index.ts', 'bug', 20, 25, 'Missing await on async call'); |
| expect(result).toBe(false); |
| }); |
| }); |
| describe('registerIssue', () => { |
| it('registers exact and semantic keys', async () => { |
| await (0, dedup_1.registerIssue)('src/utils.ts', 'bug', 1, 5, 'Typo in function name'); |
| const exact = await (0, dedup_1.isDuplicateIssue)('src/utils.ts', 'bug', 1, 5, 'Typo in function name'); |
| expect(exact).toBe(true); |
| const semantic = await (0, dedup_1.isDuplicateIssue)('src/utils.ts', 'bug', 1, 5, 'There is a possible typo in the function name'); |
| expect(semantic).toBe(true); |
| }); |
| }); |
| describe('clearDedupCache', () => { |
| it('clears all entries', async () => { |
| await (0, dedup_1.registerIssue)('src/index.ts', 'async', 10, 15, 'Missing await on async call'); |
| await (0, dedup_1.clearDedupCache)(); |
| const result = await (0, dedup_1.isDuplicateIssue)('src/index.ts', 'async', 10, 15, 'Missing await on async call'); |
| expect(result).toBe(false); |
| }); |
| }); |
| }); |
| |