From 734632280ee0950572c89582cc8cc9bbbe3f588b Mon Sep 17 00:00:00 2001 From: Lucas Fernandes de Oliveira <lfo14@inf.ufpr.br> Date: Fri, 25 Aug 2017 09:31:25 -0300 Subject: [PATCH] Issue #40: Sort metrics, dimensions and views by alphabetical order in tests Signed-off-by: Lucas Fernandes de Oliveira <lfo14@inf.ufpr.br> --- src/core/engine.spec.ts | 18 +++--------------- test/scenario.ts | 24 ++++++++++++++++++++---- 2 files changed, 23 insertions(+), 19 deletions(-) diff --git a/src/core/engine.spec.ts b/src/core/engine.spec.ts index 95812055..05367a2c 100644 --- a/src/core/engine.spec.ts +++ b/src/core/engine.spec.ts @@ -30,21 +30,9 @@ import { engineScenario } from "../../test/scenario"; describe("engine class", () => { const engine = new Engine(); - const met = engineScenario.metrics.sort((a, b) => { - const aValue = parseInt(a.name.split(":")[1], 10); - const bValue = parseInt(b.name.split(":")[1], 10); - return aValue - bValue; - }); - const dim = engineScenario.dimensions.sort((a, b) => { - const aValue = parseInt(a.name.split(":")[1], 10); - const bValue = parseInt(b.name.split(":")[1], 10); - return aValue - bValue; - }); - const subdim = engineScenario.subDimensions.sort((a, b) => { - const aValue = parseInt(a.name.split(":")[1], 10); - const bValue = parseInt(b.name.split(":")[1], 10); - return aValue - bValue; - }); + const met = engineScenario.metrics; + const dim = engineScenario.dimensions; + const subdim = engineScenario.subDimensions; const views = engineScenario.views; met.forEach((item) => engine.addMetric(item)); diff --git a/test/scenario.ts b/test/scenario.ts index 0a48d94e..af10dd2e 100644 --- a/test/scenario.ts +++ b/test/scenario.ts @@ -63,9 +63,21 @@ interface DataCtrlScenario { const config = ConfigParser.parse("config/test.yaml"); -const mets = config.metrics; -const dims = config.dimensions; -const views = config.views; +const mets = config.metrics.sort((a, b) => { + const aValue = parseInt(a.name.split(":")[1], 10); + const bValue = parseInt(b.name.split(":")[1], 10); + return aValue - bValue; +}); +const dims = config.dimensions.sort((a, b) => { + const aValue = parseInt(a.name.split(":")[1], 10); + const bValue = parseInt(b.name.split(":")[1], 10); + return aValue - bValue; +}); +const views = config.buildViews.sort((a, b) => { + const aValue = parseInt(a.alias.split(" ")[1], 10); + const bValue = parseInt(b.alias.split(" ")[1], 10); + return aValue - bValue; +}).map((item) => item.view); const filters: { [key: string]: Filter } = { "dim:0:0" : new Filter({ @@ -166,7 +178,11 @@ const subdims = [ parent: dims[1], relation: RelationType.DAY }) -]; +].sort((a, b) => { + const aValue = parseInt(a.name.split(":")[1], 10); + const bValue = parseInt(b.name.split(":")[1], 10); + return aValue - bValue; +}); const dateSubDim = [ new Dimension ({ -- GitLab