mirror of
https://github.com/chanzuckerberg/cellxgene.git
synced 2026-09-17 05:47:58 +08:00
* 1510-smoke-test * config default * update tests * update test config * fix linter errors * more comments * address comments * use npm install in push_tests.yml * use environment.default.json * adding docs * Take care of @mweiden's nits * Save screenshots in the __tests__/screenshots/ directory * typo * docs * Add chart tests (#1580) * merge tests * check if bin creation returned null before rendering charts (#1576) * check if bin creation returned null before rendering charts * refactor chart rendering into functions (#1577) * little fixes from PR * reintroduce fix to check for null values * change getAllByClass to return element * slice instead * new stackedbar test * feedback-1573-test (#1579) * feedback-1573-test * enable whole test set * revert tests Co-authored-by: Timmy Huang <tihuan@users.noreply.github.com> * tweak test to actually render chart * include snapshot * remove async * fix getAllHistograms * properly grab id Co-authored-by: Timmy Huang <tihuan@users.noreply.github.com> Co-authored-by: Matt Weiden <538456+mweiden@users.noreply.github.com> Co-authored-by: Severiano Badajoz <sbadajoz@chanzuckerberg.com>
39 lines
1.3 KiB
JavaScript
39 lines
1.3 KiB
JavaScript
/*
|
|
test controls helpers
|
|
*/
|
|
import { subsetAndResetGeneLists } from "../../../src/util/stateManager/controlsHelpers";
|
|
import * as globals from "../../../src/globals";
|
|
|
|
describe("controls helpers", () => {
|
|
test("subsetAndResetGeneLists", () => {
|
|
const geneList = [];
|
|
const genRandGene = () => Math.random().toString(36).substring(2, 6);
|
|
|
|
// build a unique set of genes
|
|
for (let i = 0; i < 150; i += 1) {
|
|
let randGene = genRandGene();
|
|
while (geneList.includes(randGene)) randGene = genRandGene();
|
|
geneList.push(randGene);
|
|
}
|
|
// insert duplicates
|
|
geneList[0] = "dupl";
|
|
geneList[20] = "dupl";
|
|
const state = {
|
|
userDefinedGenes: geneList.slice(0, 20),
|
|
diffexpGenes: geneList.slice(20),
|
|
};
|
|
const [newUserDefinedGenes, newDiffExpGenes] = subsetAndResetGeneLists(
|
|
state
|
|
);
|
|
const expectedNewUserDefinedGenes = [
|
|
...geneList.slice(0, 20),
|
|
...geneList.slice(21),
|
|
].slice(0, globals.maxGenes);
|
|
expect(globals.maxUserDefinedGenes).toBeLessThan(globals.maxGenes);
|
|
expect(geneList.length).toBeGreaterThan(globals.maxGenes);
|
|
expect(newUserDefinedGenes).toHaveLength(globals.maxGenes);
|
|
expect(newUserDefinedGenes).toStrictEqual(expectedNewUserDefinedGenes);
|
|
expect(newDiffExpGenes).toStrictEqual([]);
|
|
});
|
|
});
|