Skip to content

Commit

Permalink
add test and fix finding diverging
Browse files Browse the repository at this point in the history
  • Loading branch information
sgratzl committed Apr 7, 2020
1 parent 39cfe2d commit 3736108
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 1 deletion.
53 changes: 53 additions & 0 deletions cypress/integration/pr289_color_mapping_reset.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import {withLineUp, waitReady, LineUpJSType, LineUp} from './utils/lineup';
import {generateData} from './utils/data';
import {openMoreDialog, closeDialog, resetDialog} from './utils/ui';

describe('pr275_sort_group', () => {
let lineup: LineUp;
let lineUpJS: LineUpJSType;
before(withLineUp((l, document) => {
lineUpJS = l;
const arr = generateData({
string: 0,
number: 1,
date: 0,
cat: 0
});
lineup = lineUpJS.asLineUp(document.body, arr);
waitReady(lineup);
}));

function openColorMappingDialog() {
// open more menu
openMoreDialog('[data-type=number]');
// open group by dialog
cy.get('.lu-more-options .lu-action-color-mapping').click();
cy.get('.lu-dialog').last().as('dialog');
}

it('reset color mapping', () => {
openColorMappingDialog();
// select another color
cy.get('@dialog').get('.lu-color-line:last .lu-checkbox-color:last').click();
closeDialog();

openColorMappingDialog();
cy.get('@dialog').get('.lu-color-line:last .lu-checkbox-color > input').last().should('be.checked');
resetDialog();
cy.get('@dialog').get('.lu-color-line:first .lu-checkbox-color > input').first().should('be.checked');
closeDialog();
});

it('choose divergent color mapping', () => {
openColorMappingDialog();
// select another color
cy.get('@dialog').contains('Diverging Color').click();
cy.get('@dialog').get('input[value="interpolateBrBG"]').check();
closeDialog();

openColorMappingDialog();
cy.get('@dialog').get('input[value="interpolateBrBG"]').should('be.checked');
resetDialog();
closeDialog();
});
});
4 changes: 4 additions & 0 deletions cypress/integration/utils/ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ export function closeDialog(action: 'cancel' | 'confirm' = 'confirm') {
cy.get('.lu-backdrop').click();
}

export function resetDialog() {
cy.get(`.lu-dialog .lu-dialog-button[type=reset]`).click();
}

export function openMoreDialog(column: string) {
// open more menu
cy.get(`.le-th${column} .lu-action-more`).first().click();
Expand Down
2 changes: 1 addition & 1 deletion src/ui/dialogs/ColorMappingDialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export default class ColorMappingDialog extends ADialog {
h += `<strong data-toggle="${current instanceof DivergentColorFunction || (current instanceof CustomColorMappingFunction && entries.length === 3) ? 'open' : ''}">Diverging Color</strong>`;
h += '<div>';
{
const name = current instanceof SequentialColorFunction ? current.name : '';
const name = current instanceof DivergentColorFunction ? current.name : '';
for (const colors of Object.keys(DivergentColorFunction.FUNCTIONS)) {
h += `<label class="${cssClass('checkbox')} ${cssClass('color-gradient')}"><input name="color" type="radio" value="${colors}" ${colors === name ? 'checked="checked"' : ''}>
<span data-c="${colors}" style="background: ${gradient(DivergentColorFunction.FUNCTIONS[colors], 11)}"></span>
Expand Down

0 comments on commit 3736108

Please sign in to comment.