From 396c94ba8cb417474e6626c83a42addea210a403 Mon Sep 17 00:00:00 2001 From: Jan Macku Date: Wed, 20 Mar 2024 09:43:29 +0100 Subject: [PATCH] test: `milestone.ts` --- test/unit/milestone.test.ts | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 test/unit/milestone.test.ts diff --git a/test/unit/milestone.test.ts b/test/unit/milestone.test.ts new file mode 100644 index 0000000..fbea462 --- /dev/null +++ b/test/unit/milestone.test.ts @@ -0,0 +1,32 @@ +import { describe, expect, beforeEach, test } from 'vitest'; + +import { Milestone } from '../../src/milestone'; + +describe('Metadata Class', () => { + let milestone: Milestone; + + beforeEach(() => { + milestone = new Milestone({ + html_url: '', + number: 1, + title: 'v255', + description: 'description', + state: 'open', + }); + }); + + test('can be instantiated', () => { + expect(milestone).toBeDefined(); + expect(milestone).toBeInstanceOf(Milestone); + expect(milestone.regex).toBeInstanceOf(RegExp); + expect(milestone.regex.toString()).toBe('/^v255\\S*$/'); + }); + + test('isCompliant()', () => { + expect(milestone.isCompliant('v255-rc1')).toBe(true); + expect(milestone.isCompliant('v255')).toBe(true); + + expect(milestone.isCompliant('v256-rc1')).toBe(false); + expect(milestone.isCompliant('bla-bla')).toBe(false); + }); +});