mirror of
https://github.com/chanzuckerberg/cellxgene.git
synced 2026-09-21 23:38:11 +08:00
* load annotations individually * fix type check to be more general * update node CI version from 10 to 12 * node 11 * debug print node version * travis node version to latest * try nvm * remove extraneous node_js statement * remove node version debugging printf * incrementally load all annotations and layout * process annotations and layout as they are loaded * fix tests * sort categories incrementally * incrementally build category view summary; add category loading spinner * add spinner to continuous metadata * configure undoable reducer * incremental crossfilter creation * improve busy layout * more layout cleanup * correctly reconcile categories in schema * refine layout of lsb spinners * more spinner layout work * more spinner layout * always load layout before obs annotations
93 lines
2.6 KiB
JavaScript
93 lines
2.6 KiB
JavaScript
import * as Universe from "../../../src/util/stateManager/universe";
|
|
import * as Dataframe from "../../../src/util/dataframe";
|
|
import * as REST from "./sampleResponses";
|
|
|
|
describe("createUniverseFromResponse", () => {
|
|
/*
|
|
test createUniverseFromResponse - this function converts
|
|
a set of REST 0.2 responses into a "new" Universe.
|
|
|
|
createUniverseFromResponse(
|
|
configResponse,
|
|
schemaResponse,
|
|
annotationsObsResponse,
|
|
annotationsVarResponse,
|
|
layoutObsResponse
|
|
) --> Universe
|
|
|
|
where:
|
|
configResponse: GET /.../config
|
|
schemaResponse: GET /.../schema
|
|
annotationsObsResponse: GET /.../annotations/obs
|
|
annotationsVarResponse: GET /.../annotations/var
|
|
layoutObsResponse: GET /.../layout/obs
|
|
|
|
See spec in docs/REST_API.md.
|
|
*/
|
|
|
|
test("create from test data", () => {
|
|
/*
|
|
create a universe from sample data nad validate its shape & contents
|
|
*/
|
|
const { nObs, nVar } = REST.schema.schema.dataframe;
|
|
let universe = Universe.createUniverseFromResponse(
|
|
REST.config,
|
|
REST.schema
|
|
);
|
|
expect(universe).toBeDefined();
|
|
expect(universe).toMatchObject(
|
|
expect.objectContaining({
|
|
nObs,
|
|
nVar,
|
|
schema: REST.schema.schema,
|
|
obsAnnotations: expect.any(Dataframe.Dataframe),
|
|
varAnnotations: expect.any(Dataframe.Dataframe),
|
|
obsLayout: expect.any(Dataframe.Dataframe),
|
|
varData: expect.any(Dataframe.Dataframe)
|
|
})
|
|
);
|
|
|
|
universe = {
|
|
...universe,
|
|
...Universe.addObsAnnotations(
|
|
universe,
|
|
Universe.matrixFBSToDataframe(REST.annotationsObs)
|
|
),
|
|
...Universe.addVarAnnotations(
|
|
universe,
|
|
Universe.matrixFBSToDataframe(REST.annotationsVar)
|
|
),
|
|
...Universe.addObsLayout(
|
|
universe,
|
|
Universe.matrixFBSToDataframe(REST.layoutObs)
|
|
)
|
|
};
|
|
|
|
expect(universe).toMatchObject(
|
|
expect.objectContaining({
|
|
nObs,
|
|
nVar,
|
|
schema: REST.schema.schema,
|
|
obsAnnotations: expect.any(Dataframe.Dataframe),
|
|
varAnnotations: expect.any(Dataframe.Dataframe),
|
|
obsLayout: expect.any(Dataframe.Dataframe),
|
|
varData: expect.any(Dataframe.Dataframe)
|
|
})
|
|
);
|
|
|
|
expect(universe.obsAnnotations.dims).toEqual([
|
|
nObs,
|
|
REST.schema.schema.annotations.obs.columns.length
|
|
]);
|
|
expect(universe.obsLayout.dims).toEqual([nObs, 2]);
|
|
expect(universe.obsLayout.colIndex.keys()).toEqual(
|
|
universe.schema.layout.obs[0].dims
|
|
);
|
|
expect(universe.varAnnotations.dims).toEqual([
|
|
nVar,
|
|
REST.schema.schema.annotations.var.columns.length
|
|
]);
|
|
expect(universe.varData.isEmpty()).toBeTruthy();
|
|
});
|
|
});
|