From e24c2af6d76d5c796349c5a800ee1606bdd5d806 Mon Sep 17 00:00:00 2001 From: Colin Date: Thu, 1 Jul 2021 04:34:20 -0400 Subject: [PATCH] Fix unit tests --- .../src/BreakpointSplitView.test.tsx | 24 +++++++++++-------- .../breakpoint-split-view/src/model.test.tsx | 23 ++++++++++-------- plugins/breakpoint-split-view/src/model.ts | 5 ++-- 3 files changed, 30 insertions(+), 22 deletions(-) diff --git a/plugins/breakpoint-split-view/src/BreakpointSplitView.test.tsx b/plugins/breakpoint-split-view/src/BreakpointSplitView.test.tsx index 298294ba28..8e24762070 100644 --- a/plugins/breakpoint-split-view/src/BreakpointSplitView.test.tsx +++ b/plugins/breakpoint-split-view/src/BreakpointSplitView.test.tsx @@ -23,13 +23,19 @@ const getView = () => { type: 'FakeTrack', configuration: types.frozen(), displays: types.array( - types.model('FakeDisplay', { - type: 'FakeDisplay', - displayId: 'FakeDisplay', - configuration: types.frozen(), - features: types.frozen(), - layoutFeatures: types.frozen(), - }), + types + .model('FakeDisplay', { + type: 'FakeDisplay', + displayId: 'FakeDisplay', + configuration: types.frozen(), + layoutFeatures: types.frozen(), + features: types.frozen(), + }) + .views(self => ({ + getFeatureByID(id: string) { + return self.layoutFeatures[id] + }, + })), ), }) .actions(self => ({ @@ -37,11 +43,9 @@ const getView = () => { self.displays[0].features = new Map( Object.entries(self.displays[0].features), ) - self.displays[0].layoutFeatures = new Map( - Object.entries(self.displays[0].layoutFeatures), - ) }, })) + stubManager.addViewType( () => new ViewType({ diff --git a/plugins/breakpoint-split-view/src/model.test.tsx b/plugins/breakpoint-split-view/src/model.test.tsx index 7982451361..1259af07cd 100644 --- a/plugins/breakpoint-split-view/src/model.test.tsx +++ b/plugins/breakpoint-split-view/src/model.test.tsx @@ -23,13 +23,19 @@ const getView = () => { type: 'FakeTrack', configuration: types.frozen(), displays: types.array( - types.model('FakeDisplay', { - type: 'FakeDisplay', - displayId: 'FakeDisplay', - configuration: types.frozen(), - features: types.frozen(), - layoutFeatures: types.frozen(), - }), + types + .model('FakeDisplay', { + type: 'FakeDisplay', + displayId: 'FakeDisplay', + configuration: types.frozen(), + features: types.frozen(), + layoutFeatures: types.frozen(), + }) + .views(self => ({ + getFeatureByID(id: string) { + return self.layoutFeatures[id] + }, + })), ), }) .actions(self => ({ @@ -37,9 +43,6 @@ const getView = () => { self.displays[0].features = new Map( Object.entries(self.displays[0].features), ) - self.displays[0].layoutFeatures = new Map( - Object.entries(self.displays[0].layoutFeatures), - ) }, })) stubManager.addViewType( diff --git a/plugins/breakpoint-split-view/src/model.ts b/plugins/breakpoint-split-view/src/model.ts index 39872bdef9..d8cadab18e 100644 --- a/plugins/breakpoint-split-view/src/model.ts +++ b/plugins/breakpoint-split-view/src/model.ts @@ -229,8 +229,9 @@ export default function stateModelFactory(pluginManager: any) { // use reverse to search the second track first const tracks = this.getMatchedTracks(trackConfigId) - const calc = (track: any, feat: Feature) => - track.displays[0].getFeatureByID(feat.id()) + const calc = (track: any, feat: Feature) => { + return track.displays[0].getFeatureByID(feat.id()) + } return features.map(c => c.map(feature => {