Unverified Commit 2b28b349 authored by Mark Stenglein's avatar Mark Stenglein
Browse files

FormatType Spec: Streamline test cases



This commit makes the tests on the Formattype isregname a bit more
intuitive and way less confusing. By using a forEach and constructing
each case instead of manually typing it it is now way simpler to add
tests as well.
Signed-off-by: Mark Stenglein's avatarMark Stenglein <mark@stengle.in>
parent 45331c7d
Pipeline #1239 passed with stages
in 1 minute and 15 seconds
......@@ -103,52 +103,12 @@ describe("FormatType:", () => {
describe("Static Methods", () => {
describe("isregName:", () => {
it("Passes Alpha", () => {
expect(FormatType.isRegName("AlPhA")).to.be.true;
});
it("Passes Digits", () => {
expect(FormatType.isRegName("0123456789")).to.be.true;
});
it("Passes !", () => {
expect(FormatType.isRegName("!")).to.be.true;
});
it("Passes #", () => {
expect(FormatType.isRegName("#")).to.be.true;
});
it("Passes $", () => {
expect(FormatType.isRegName("$")).to.be.true;
});
it("Passes &", () => {
expect(FormatType.isRegName("&")).to.be.true;
});
it("Passes .", () => {
expect(FormatType.isRegName(".")).to.be.true;
});
it("Passes +", () => {
expect(FormatType.isRegName("+")).to.be.true;
});
it("Passes -", () => {
expect(FormatType.isRegName("-")).to.be.true;
});
it("Passes ^", () => {
expect(FormatType.isRegName("^")).to.be.true;
});
it("Passes _", () => {
expect(FormatType.isRegName("_")).to.be.true;
});
it("Passes All types at once", () => {
expect(FormatType.isRegName("Aa0123456789!#$&.+-^_")).to.be.true;
["AlPhA", "0123456789", "!", "#", "$", "&",
".", "+", "-" , "^", "-", "Aa0123456789!#$&.+-^_"].forEach(testChar => {
it(`Passes ${testChar}`, () => {
expect(FormatType.isRegName(testChar)).to.be.true;
});
});
it("Passes 127 Characters", () => {
......@@ -159,10 +119,6 @@ describe("FormatType:", () => {
expect(FormatType.isRegName(testValue)).to.be.true;
});
it("Fails 0 characters", () => {
expect(FormatType.isRegName("")).to.be.false;
});
it("Fails 128 characters", () => {
const testValue: string = "CPbCdgIJzLgSrrZOKJDofOuIFhxgbnccXB"
+ "pGrwPZcaQxDNLtHqWKopzsJaTAzCnOKHhlxQBOKkObQjcPHXalKBNn"
......@@ -171,12 +127,10 @@ describe("FormatType:", () => {
expect(FormatType.isRegName(testValue)).to.be.false;
});
it("Fails <", () => {
expect(FormatType.isRegName("<")).to.be.false;
});
it("Fails /", () => {
expect(FormatType.isRegName("/")).to.be.false;
["", "<", "/"].forEach(testChar => {
it(`Passes ${testChar}`, () => {
expect(FormatType.isRegName(testChar)).to.be.false;
});
});
});
});
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment