|
| 1 | +/* |
| 2 | + * Copyright 2017-2022 Allegro.pl |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | + |
| 17 | +import { expect, use } from "chai"; |
| 18 | +import { VisStrategy } from "../../models/essence/essence"; |
| 19 | +import { measureSeries } from "../../models/series/series.fixtures"; |
| 20 | +import { numberSplitCombine, timeSplitCombine } from "../../models/split/split.fixtures"; |
| 21 | +import { totals, visualizationManifestResolvers } from "../test-utils"; |
| 22 | +import { LINE_CHART_MANIFEST } from "./line-chart"; |
| 23 | + |
| 24 | +use(visualizationManifestResolvers); |
| 25 | + |
| 26 | +const emptyLineChart = totals |
| 27 | + .set("visualization", LINE_CHART_MANIFEST as any) |
| 28 | + .addSeries(measureSeries("added")); |
| 29 | + |
| 30 | +const timeLineChart = totals |
| 31 | + .addSeries(measureSeries("added")) |
| 32 | + .addSplit(timeSplitCombine("time"), VisStrategy.FairGame); |
| 33 | + |
| 34 | +describe("Visualization Manifests", () => { |
| 35 | + describe("Line Chart", () => { |
| 36 | + describe("Starting from Totals", () => { |
| 37 | + it("should switch to line chart with single time split", () => { |
| 38 | + const essence = totals.addSplit( |
| 39 | + timeSplitCombine("time"), |
| 40 | + VisStrategy.FairGame |
| 41 | + ); |
| 42 | + |
| 43 | + expect(essence).to.be.resolvedTo("line-chart"); |
| 44 | + }); |
| 45 | + }); |
| 46 | + |
| 47 | + describe("Starting from Line Chart", () => { |
| 48 | + it("should stick to line chart with change to number split", () => { |
| 49 | + const essence = timeLineChart.changeSplit( |
| 50 | + numberSplitCombine("commentLength"), |
| 51 | + VisStrategy.FairGame |
| 52 | + ); |
| 53 | + |
| 54 | + expect(essence).to.be.resolvedTo("line-chart"); |
| 55 | + }); |
| 56 | + }); |
| 57 | + |
| 58 | + describe("Starting from unresolved Line Chart", () => { |
| 59 | + it("should stick to line chart with single time split", () => { |
| 60 | + const essence = emptyLineChart.addSplit( |
| 61 | + timeSplitCombine("time"), |
| 62 | + VisStrategy.FairGame |
| 63 | + ); |
| 64 | + |
| 65 | + expect(essence).to.be.resolvedTo("line-chart"); |
| 66 | + }); |
| 67 | + |
| 68 | + it("should stick to line chart with single number split", () => { |
| 69 | + const essence = emptyLineChart.addSplit( |
| 70 | + numberSplitCombine("commentLength"), |
| 71 | + VisStrategy.FairGame |
| 72 | + ); |
| 73 | + |
| 74 | + expect(essence).to.be.resolvedTo("line-chart"); |
| 75 | + }); |
| 76 | + }); |
| 77 | + }); |
| 78 | +}); |
0 commit comments