Skip to content

Commit

Permalink
unit test shared colors functions.
Browse files Browse the repository at this point in the history
  • Loading branch information
azurepolarbear committed May 26, 2024
1 parent 6664c64 commit 8708cd7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,5 @@

// import {BRITTNI} from 'palettes';

// TODO - look at all TODOs
// TODO - brittni unit tests
// TODO - misc map unit tests
9 changes: 5 additions & 4 deletions src/test/shared/color.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ import {SketchContext} from 'context';

const p5: P5Lib = SketchContext.p5;

const hexPattern: RegExp = /^#[A-F|0-9]{6}$/;
const hexWithAlphaPattern: RegExp = /^#[A-F|0-9]{8}$/;

export const red: Color = new Color(p5.color(255, 0, 0));
export const green: Color = new Color(p5.color(0, 255, 0));
export const blue: Color = new Color(p5.color(0, 0, 255));
Expand Down Expand Up @@ -75,13 +78,11 @@ export function p5ColorToColorComponents(color: P5Lib.Color): ColorComponents {
}

export function checkForValidHexColorString(hex: string): void {
const hexRegExp: RegExp = /^#[A-F|0-9]{6}$/;
const isValid = hexRegExp.test(hex);
const isValid: boolean = hexPattern.test(hex);
expect(isValid).toBeTruthy();
}

export function checkForValidHexColorStringWithAlpha(hex: string): void {
const hexRegExp: RegExp = /^#[A-F|0-9]{8}$/;
const isValid = hexRegExp.test(hex);
const isValid: boolean = hexWithAlphaPattern.test(hex);
expect(isValid).toBeTruthy();
}

0 comments on commit 8708cd7

Please sign in to comment.