-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: format-checkers regex to support
:emoji:
format (#97)
* fix invalid regex https://github.com/ES-Community/bot/assets/5005154/02494c78-25d3-4a80-be93-77309e211816 * add some unit tests * change `FunctionChecker` type use string instead Message for testing, all checks use `cleanContent` from `Message` * test: disable WorkChronicles test if CI
- Loading branch information
Showing
6 changed files
with
87 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
import { describe, test, expect } from 'vitest'; | ||
import Link from '../../src/format-checkers/Link.js'; | ||
import { pino, transport } from 'pino'; | ||
import { randomUUID } from 'node:crypto'; | ||
|
||
describe('Link', () => { | ||
const logger = pino(transport({ target: 'pino-pretty' })).child({ | ||
id: randomUUID(), | ||
type: 'FormatChecker', | ||
checkerName: 'Link', | ||
}); | ||
|
||
test('valid without emoji', () => { | ||
const message = `[**SUJET**] Votre description ici - https://github.com/es-community`; | ||
const isValid = Link.isMessageValid(message, logger); | ||
|
||
expect(isValid).toBe(true); | ||
}); | ||
|
||
test('valid with unicode emoji', () => { | ||
const message = `[👍] Votre description ici - https://github.com/es-community`; | ||
const isValid = Link.isMessageValid(message, logger); | ||
|
||
expect(isValid).toBe(true); | ||
}); | ||
|
||
test('valid with multiple unicode emojis', () => { | ||
const message = `[👍👌] Votre description ici - https://github.com/es-community`; | ||
const isValid = Link.isMessageValid(message, logger); | ||
|
||
expect(isValid).toBe(true); | ||
}); | ||
|
||
test('valid with discord emoji', () => { | ||
const message = `[<:adonis:793993785712312361>] Breadcrumbs automatiques pour les routes sur Adonis V6 - https://adonis-breadcrumbs.pages.dev`; | ||
const isValid = Link.isMessageValid(message, logger); | ||
|
||
expect(isValid).toBe(true); | ||
}); | ||
|
||
test('valid with multiple discord emojis', () => { | ||
const message = `[<:adonis:793993785712312361><:firefox:793993785712312369>] Breadcrumbs automatiques pour les routes sur Adonis V6 - https://adonis-breadcrumbs.pages.dev`; | ||
const isValid = Link.isMessageValid(message, logger); | ||
|
||
expect(isValid).toBe(true); | ||
}); | ||
|
||
test('valid with multiple discord emojis mixed with unicode emojis', () => { | ||
const message = `[<:adonis:793993785712312361>🌈<:firefox:793993785712312369>👍👌] Breadcrumbs automatiques pour les routes sur Adonis V6 - https://adonis-breadcrumbs.pages.dev`; | ||
const isValid = Link.isMessageValid(message, logger); | ||
|
||
expect(isValid).toBe(true); | ||
}); | ||
|
||
test('valid with discord dismissed emoji', () => { | ||
const message = `[:adonis:] Breadcrumbs automatiques pour les routes sur Adonis V6 - https://adonis-breadcrumbs.pages.dev`; | ||
const isValid = Link.isMessageValid(message, logger); | ||
|
||
expect(isValid).toBe(true); | ||
}); | ||
|
||
test('invalid, link is missing', () => { | ||
const message = `[**SUJET**] Votre description ici`; | ||
const isValid = Link.isMessageValid(message, logger); | ||
|
||
expect(isValid).toBe(false); | ||
}); | ||
|
||
test('invalid, separator is missing', () => { | ||
const message = `[**SUJET**] Votre description ici https://github.com/es-community`; | ||
const isValid = Link.isMessageValid(message, logger); | ||
|
||
expect(isValid).toBe(false); | ||
}); | ||
}); |