Skip to content

Commit

Permalink
Fix unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cmdcolin committed Jul 1, 2021
1 parent b03d68c commit e24c2af
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 22 deletions.
24 changes: 14 additions & 10 deletions plugins/breakpoint-split-view/src/BreakpointSplitView.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,25 +23,29 @@ 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 => ({
afterCreate() {
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({
Expand Down
23 changes: 13 additions & 10 deletions plugins/breakpoint-split-view/src/model.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,26 @@ 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 => ({
afterCreate() {
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(
Expand Down
5 changes: 3 additions & 2 deletions plugins/breakpoint-split-view/src/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand Down

0 comments on commit e24c2af

Please sign in to comment.