2021-04-07 14:09:45 +02:00
|
|
|
import "jasmine";
|
|
|
|
import {areCharacterLayersValid, isUserNameValid, maxUserNameLength} from "../../../src/Connexion/LocalUser";
|
|
|
|
|
|
|
|
describe("isUserNameValid()", () => {
|
|
|
|
it("should validate name with letters", () => {
|
|
|
|
expect(isUserNameValid('toto')).toBe(true);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("should not validate empty name", () => {
|
|
|
|
expect(isUserNameValid('')).toBe(false);
|
|
|
|
});
|
|
|
|
it("should not validate string with too many letters", () => {
|
|
|
|
let testString = '';
|
|
|
|
for (let i = 0; i < maxUserNameLength + 2; i++) {
|
|
|
|
testString += 'a';
|
|
|
|
}
|
|
|
|
expect(isUserNameValid(testString)).toBe(false);
|
|
|
|
});
|
|
|
|
it("should not validate spaces", () => {
|
|
|
|
expect(isUserNameValid(' ')).toBe(false);
|
|
|
|
});
|
2021-05-26 17:07:07 +02:00
|
|
|
it("should validate special characters", () => {
|
|
|
|
expect(isUserNameValid('%&-')).toBe(true);
|
|
|
|
});
|
|
|
|
it("should validate accents", () => {
|
|
|
|
expect(isUserNameValid('éàëè')).toBe(true);
|
|
|
|
});
|
|
|
|
it("should validate chinese characters", () => {
|
|
|
|
expect(isUserNameValid('中文鍵盤')).toBe(true);
|
2021-04-07 14:09:45 +02:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe("areCharacterLayersValid()", () => {
|
|
|
|
it("should validate default textures array", () => {
|
|
|
|
expect(areCharacterLayersValid(['male1', 'male2'])).toBe(true);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("should not validate an empty array", () => {
|
|
|
|
expect(areCharacterLayersValid([])).toBe(false);
|
|
|
|
});
|
|
|
|
it("should not validate space only strings", () => {
|
|
|
|
expect(areCharacterLayersValid([' ', 'male1'])).toBe(false);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("should not validate empty strings", () => {
|
|
|
|
expect(areCharacterLayersValid(['', 'male1'])).toBe(false);
|
|
|
|
});
|
2021-04-30 10:58:01 +02:00
|
|
|
});
|