From 7a4e672b8c762c7fb22c4d35a427c52fa24973c5 Mon Sep 17 00:00:00 2001 From: Lokesh Dhakar Date: Thu, 2 May 2019 09:04:23 -0700 Subject: [PATCH] test: Add getPalette() tets --- cypress/integration/api_spec.js | 21 +++++++++++++++++++++ index.html | 6 +++--- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/cypress/integration/api_spec.js b/cypress/integration/api_spec.js index 6fc6b71..d741175 100644 --- a/cypress/integration/api_spec.js +++ b/cypress/integration/api_spec.js @@ -50,3 +50,24 @@ describe('getColor()', function() { // }); // }) }) + +function testPaletteCount(num) { + it(`returns ${num} color when colorCount set to ${num}`, function() { + cy.get(`[data-image="rainbow-horizontal.png"] .palette[data-count="${num}"] .output-palette`).should(($el) => { + const count = rgbCount($el.text()) + expect(count).to.equal(num); + }); + }) +} + +describe('getPalette()', function() { + beforeEach(function() { + cy.visit('http://localhost:8080'); + }) + + // FULL TEST LIST = [1, 2, 3, 5, 7, 10, 20]; + + // Non-breaking tests + let testCounts = [5, 7]; + testCounts.forEach((count) => testPaletteCount(count)) +}) diff --git a/index.html b/index.html index f5982f7..fc6d1bd 100755 --- a/index.html +++ b/index.html @@ -22,7 +22,7 @@