diff --git a/packages/playground/src/components/smtp_server.vue b/packages/playground/src/components/smtp_server.vue index 3f91660dda..3896d48cd4 100644 --- a/packages/playground/src/components/smtp_server.vue +++ b/packages/playground/src/components/smtp_server.vue @@ -20,17 +20,23 @@ - + + Discourse needs SMTP service so please configure these settings properly. diff --git a/packages/playground/tests/utils/validators/IsAlphaExpectDashAndUnderscore.test.ts b/packages/playground/tests/utils/validators/IsAlphaExpectDashAndUnderscore.test.ts new file mode 100644 index 0000000000..01d98227fe --- /dev/null +++ b/packages/playground/tests/utils/validators/IsAlphaExpectDashAndUnderscore.test.ts @@ -0,0 +1,45 @@ +import { describe, expect, it } from "vitest"; + +import { IsAlphanumericExpectDashAndUnderscore } from "../../../src/utils/validators"; + +const validator = IsAlphanumericExpectDashAndUnderscore( + "Username should consist of letters, numbers, dashs and underscores only.", +); + +describe("IsAlphanumericExpectDashAndUnderscore", () => { + it("returns an error message for input with spaces", () => { + const result = validator("hello world!"); + expect(result).toEqual({ + message: "Username should consist of letters, numbers, dashs and underscores only.", + requiredTrue: true, + }); + }); + + it("returns an error message for input with special characters", () => { + const result = validator("hello@world"); + expect(result).toEqual({ + message: "Username should consist of letters, numbers, dashs and underscores only.", + requiredTrue: true, + }); + }); + + it("returns undefined for valid username that contains underscore", () => { + const result = validator("hello_world"); + expect(result).toBeUndefined(); + }); + + it("returns undefined for valid username that contains dash", () => { + const result = validator("hello-world"); + expect(result).toBeUndefined(); + }); + + it("returns undefined for valid username", () => { + const result = validator("hello"); + expect(result).toBeUndefined(); + }); + + it("returns undefined for valid username/email that starts with numbers", () => { + const result = validator("4me"); + expect(result).toBeUndefined(); + }); +});