-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1508 from RobAndrewHurst/infoj_order
Infoj Order Correction
- Loading branch information
Showing
4 changed files
with
120 additions
and
19 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { infojTest } from './infoj.test.mjs'; | ||
|
||
export const ui_locations = { infojTest }; |
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,78 @@ | ||
/** | ||
* This function is used as an entry point for the infoj test | ||
* @function injojTest | ||
*/ | ||
export async function infojTest() { | ||
codi.describe('UI Locations: infojTest', async () => { | ||
/** | ||
* ### It should create an infoj with a correct order | ||
* 1. We define an infoj with a combination of different entries with keys, fields and queries | ||
* 2. We assert against the order | ||
* @function it | ||
*/ | ||
await codi.it('It should create an infoj with certain order', async () => { | ||
|
||
const location = { | ||
infoj: [ | ||
{ | ||
field: 'field_1', | ||
key: 'key_1', | ||
label: 'test_1', | ||
value: 'test 1 value' | ||
}, | ||
{ | ||
field: 'field_2', | ||
label: 'test_2', | ||
value: 'value_2' | ||
}, | ||
{ | ||
field: 'field_3', | ||
label: 'test_3', | ||
value: 'value_3' | ||
}, | ||
{ | ||
key: 'key_4', | ||
value: 'value_4' | ||
}, | ||
{ | ||
query: 'query_5', | ||
value: 'value_5', | ||
location: {} | ||
} | ||
] | ||
}; | ||
|
||
const infoj_order = [ | ||
'_field_1', | ||
'field_2', | ||
'field_3', | ||
'key_4', | ||
'query_5', | ||
{ | ||
field: 'field6', | ||
value: 'value_6' | ||
} | ||
]; | ||
|
||
// Get listview element from the infoj object | ||
const infoj = mapp.ui.locations.infoj(location, infoj_order); | ||
|
||
// Get textvalues from location listview elements. | ||
const results = Array.from(infoj.children) | ||
.map(el => el.firstChild.innerText.trim()) | ||
|
||
// Expected results | ||
const expected = [ | ||
'value_2', | ||
'value_3', | ||
'value_4', | ||
'value_5', | ||
'value_6' | ||
]; | ||
|
||
// Asserting we get the expected results and order | ||
codi.assertEqual(results, expected, 'The infoj order needs to be as defined in the expected'); | ||
|
||
}); | ||
}); | ||
} |