From d4db499554c57a944ae2022d67f5ff819c81b04f Mon Sep 17 00:00:00 2001 From: Imamuzzaki Abu Salam <imamuzzaki@gmail.com> Date: Tue, 21 Nov 2023 19:40:36 +0700 Subject: [PATCH] test: add ignore utility test (#25891) --- lib/util/ignore.spec.ts | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 lib/util/ignore.spec.ts diff --git a/lib/util/ignore.spec.ts b/lib/util/ignore.spec.ts new file mode 100644 index 0000000000..c9b483aeca --- /dev/null +++ b/lib/util/ignore.spec.ts @@ -0,0 +1,33 @@ +import { logger } from '../logger'; +import { isSkipComment } from './ignore'; + +jest.mock('../logger', () => ({ + logger: { + debug: jest.fn(), + }, +})); + +describe('util/ignore', () => { + it('returns true for "renovate:ignore" comments', () => { + expect(isSkipComment('renovate:ignore')).toBe(true); + }); + + it('returns false for comments not starting with "renovate:" or "pyup:"', () => { + expect(isSkipComment('other:ignore')).toBe(false); + }); + + it('returns false for "renovate:" comments without "ignore"', () => { + expect(isSkipComment('renovate:update')).toBe(false); + }); + + it('logs unknown command for "renovate:" comments without "ignore"', () => { + isSkipComment('renovate:update'); + expect(logger.debug).toHaveBeenCalledWith( + 'Unknown comment command: update', + ); + }); + + it('returns false when comment is undefined', () => { + expect(isSkipComment()).toBe(false); + }); +}); -- GitLab