-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Survey node defs index: added index by node def name (#251)
* survey: added survey node defs index by name * code cleanup * fixed DeepScan issue * added tests * code cleanup --------- Co-authored-by: Stefano Ricci <[email protected]> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
- Loading branch information
1 parent
3110dfa
commit 9c3bf38
Showing
8 changed files
with
128 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { NodeDefs } from '../../nodeDef' | ||
import { Survey } from '../../survey' | ||
import { SurveyBuilder, SurveyObjectBuilders } from '../../tests/builder/surveyBuilder' | ||
import { createTestAdminUser } from '../../tests/data' | ||
|
||
const { entityDef, integerDef } = SurveyObjectBuilders | ||
|
||
let survey: Survey | ||
|
||
describe('Survey Node Definitionss index', () => { | ||
beforeAll(async () => { | ||
const user = createTestAdminUser() | ||
|
||
survey = new SurveyBuilder( | ||
user, | ||
entityDef('cluster', integerDef('cluster_id').key(), entityDef('plot', integerDef('plot_id').key()).multiple()) | ||
).build() | ||
}, 10000) | ||
|
||
test('root def UUID', () => { | ||
const clusterUuid = survey.nodeDefsIndex?.rootDefUuid | ||
expect(clusterUuid).toBeDefined() | ||
}) | ||
|
||
test('node defs by name', () => { | ||
const { nodeDefUuidByName, rootDefUuid } = survey.nodeDefsIndex ?? {} | ||
const clusterUuid2 = nodeDefUuidByName?.['cluster'] | ||
expect(rootDefUuid).toBe(clusterUuid2) | ||
|
||
// cluster_id | ||
const clusterIdUuid = nodeDefUuidByName?.['cluster_id'] | ||
expect(clusterIdUuid).toBeDefined() | ||
expect(clusterIdUuid).not.toBe(rootDefUuid) | ||
|
||
const clusterIdDef = survey.nodeDefs?.[clusterIdUuid!] | ||
expect(clusterIdDef).toBeDefined() | ||
expect(NodeDefs.getName(clusterIdDef!)).toBe('cluster_id') | ||
|
||
// plot_id | ||
const plotIdUuid = nodeDefUuidByName?.['plot_id'] | ||
expect(plotIdUuid).toBeDefined() | ||
expect(plotIdUuid).not.toBe(rootDefUuid) | ||
|
||
const plotIdDef = survey.nodeDefs?.[plotIdUuid!] | ||
expect(plotIdDef).toBeDefined() | ||
expect(NodeDefs.getName(plotIdDef!)).toBe('plot_id') | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters