mirror of
https://github.com/janishutz/color-thief.git
synced 2025-11-25 13:54:25 +00:00
test: Add node tests with Mocha and Chai
This commit is contained in:
24
test/node-test.js
Normal file
24
test/node-test.js
Normal file
@@ -0,0 +1,24 @@
|
||||
const { resolve } = require('path');
|
||||
const ColorThief = require(resolve(process.cwd(), "dist/color-thief-node.js"));
|
||||
const img = resolve(process.cwd(), 'cypress/test-pages/img/rainbow-vertical.png');
|
||||
const chai = require("chai");
|
||||
const expect = chai.expect;
|
||||
chai.use(require("chai-as-promised"));
|
||||
|
||||
|
||||
describe('getColor()', function() {
|
||||
it('returns valid color', function() {
|
||||
return expect(ColorThief.getColor(img)).to.eventually.have.lengthOf(3);
|
||||
});
|
||||
});
|
||||
|
||||
describe('getPalette()', function() {
|
||||
it('returns 5 colors when colorCount set to 5', function() {
|
||||
return expect(ColorThief.getPalette(img, 5)).to.eventually.have.lengthOf(5);
|
||||
});
|
||||
|
||||
it('returns 9 colors when colorCount set to 9', function() {
|
||||
return expect(ColorThief.getPalette(img, 9)).to.eventually.have.lengthOf(9);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user