test: Add getPalette() tets

This commit is contained in:
Lokesh Dhakar
2019-05-02 09:04:23 -07:00
parent eef8742c0b
commit 7a4e672b8c
2 changed files with 24 additions and 3 deletions

View File

@@ -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))
})

View File

@@ -22,7 +22,7 @@
<script id="color-tpl" type="text/x-mustache"> <script id="color-tpl" type="text/x-mustache">
<div class="color"> <div class="color">
<h3>Dominant Color</h3> <h3>getColor(img)</h3>
<div class="swatches"> <div class="swatches">
<div class="swatch" style="background-color: rgb({{color.0}}, {{color.1}}, {{color.2}})"></div> <div class="swatch" style="background-color: rgb({{color.0}}, {{color.1}}, {{color.2}})"></div>
</div> </div>
@@ -34,8 +34,8 @@
</script> </script>
<script id="palette-tpl" type="text/x-mustache"> <script id="palette-tpl" type="text/x-mustache">
<div class="palette"> <div class="palette" data-count="{{count}}">
<h3>Palette {{ count }}</h3> <h3>getPalette(img, {{count}})</h3>
<div class="swatches"> <div class="swatches">
{{#palette}} {{#palette}}
<div class="swatch" style="background-color: rgb({{0}}, {{1}}, {{2}})"></div> <div class="swatch" style="background-color: rgb({{0}}, {{1}}, {{2}})"></div>