Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

46 changes: 46 additions & 0 deletions test/unit/accessibility/color_namer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
suite('accessibility/color_namer', function () {
let myp5;

setup(function () {
myp5 = new p5(function () {});
});

teardown(function () {
myp5.remove();
});

test('should be a function', function () {
assert.ok(myp5._rgbColorName);
assert.typeOf(myp5._rgbColorName, 'function');
});

test('should return black for black rgba', function () {
const name = myp5._rgbColorName([0, 0, 0, 255]);
assert.equal(name, 'black');
});

test('should return white for white rgba', function () {
const name = myp5._rgbColorName([255, 255, 255, 255]);
assert.equal(name, 'white');
});

test('should return red for red rgba', function () {
const name = myp5._rgbColorName([255, 0, 0, 255]);
assert.equal(name, 'red');
});

test('should return green for green rgba', function () {
const name = myp5._rgbColorName([0, 255, 0, 255]);
assert.equal(name, 'green');
});

test('should return blue for blue rgba', function () {
const name = myp5._rgbColorName([0, 0, 255, 255]);
assert.equal(name, 'blue');
});

test('should handle gray color exception correctly', function () {
const name = myp5._rgbColorName([211, 211, 211, 255]);
assert.equal(name, 'gray');
});
});