-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ui): scenario execution details
- Loading branch information
Showing
17 changed files
with
455 additions
and
49 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
76 changes: 76 additions & 0 deletions
76
simulator-ui/src/main/webapp/app/core/util/operator.spec.ts
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,76 @@ | ||
import dayjs from 'dayjs/esm'; | ||
|
||
import { sort } from './operators'; | ||
|
||
describe('operator', () => { | ||
describe('sort', () => { | ||
test('sorts messages by number in ascending order', () => { | ||
const messages = [{ id: 3 }, { id: 1 }, { id: 2 }]; | ||
const sortedMessages = sort(messages, 'id'); | ||
|
||
expect(sortedMessages).toEqual([{ id: 1 }, { id: 2 }, { id: 3 }]); | ||
}); | ||
|
||
test('sorts messages by number in descending order', () => { | ||
const messages = [{ id: 3 }, { id: 1 }, { id: 2 }]; | ||
const sortedMessages = sort(messages, 'id', false); | ||
|
||
expect(sortedMessages).toEqual([{ id: 3 }, { id: 2 }, { id: 1 }]); | ||
}); | ||
|
||
test('sorts messages by string in ascending order', () => { | ||
const messages = [{ name: 'Charlie' }, { name: 'Alice' }, { name: 'Bob' }]; | ||
const sortedMessages = sort(messages, 'name'); | ||
|
||
expect(sortedMessages).toEqual([{ name: 'Alice' }, { name: 'Bob' }, { name: 'Charlie' }]); | ||
}); | ||
|
||
test('sorts messages by string in descending order', () => { | ||
const messages = [{ name: 'Charlie' }, { name: 'Alice' }, { name: 'Bob' }]; | ||
const sortedMessages = sort(messages, 'name', false); | ||
|
||
expect(sortedMessages).toEqual([{ name: 'Charlie' }, { name: 'Bob' }, { name: 'Alice' }]); | ||
}); | ||
|
||
test('sorts messages by dayjs date in ascending order', () => { | ||
const messages = [{ timestamp: dayjs('2023-01-03') }, { timestamp: dayjs('2023-01-01') }, { timestamp: dayjs('2023-01-02') }]; | ||
const sortedMessages = sort(messages, 'timestamp'); | ||
|
||
expect(sortedMessages).toEqual([ | ||
{ timestamp: dayjs('2023-01-01') }, | ||
{ timestamp: dayjs('2023-01-02') }, | ||
{ timestamp: dayjs('2023-01-03') }, | ||
]); | ||
}); | ||
|
||
test('sorts messages by dayjs date in descending order', () => { | ||
const messages = [{ timestamp: dayjs('2023-01-03') }, { timestamp: dayjs('2023-01-01') }, { timestamp: dayjs('2023-01-02') }]; | ||
const sortedMessages = sort(messages, 'timestamp', false); | ||
|
||
expect(sortedMessages).toEqual([ | ||
{ timestamp: dayjs('2023-01-03') }, | ||
{ timestamp: dayjs('2023-01-02') }, | ||
{ timestamp: dayjs('2023-01-01') }, | ||
]); | ||
}); | ||
|
||
test('handles null and undefined values gracefully', () => { | ||
const messages = [ | ||
{ name: 'Alice', id: null }, | ||
{ name: null, id: 2 }, | ||
{ name: 'Charlie', id: undefined }, | ||
{ name: 'Bob', id: 1 }, | ||
]; | ||
const sortedMessages = sort(messages, 'id'); | ||
|
||
// Depending on your sort function's implementation to handle null/undefined, | ||
// adjust the expected result accordingly | ||
expect(sortedMessages).toEqual([ | ||
{ name: 'Bob', id: 1 }, | ||
{ name: null, id: 2 }, | ||
{ name: 'Alice', id: null }, | ||
{ name: 'Charlie', id: undefined }, | ||
]); | ||
}); | ||
}); | ||
}); |
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
1 change: 1 addition & 0 deletions
1
simulator-ui/src/main/webapp/app/core/util/sort-parameters.type.ts
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 @@ | ||
export type SortParameters = { predicate: string; ascending: boolean }; |
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
Oops, something went wrong.