Skip to content

Commit

Permalink
document some functions. fix a test
Browse files Browse the repository at this point in the history
  • Loading branch information
oatkiller committed Aug 11, 2020
1 parent 4763965 commit 998a664
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ export function timestampSafeVersion(event: SafeResolverEvent): string | undefin
: firstNonNullValue(event?.['@timestamp']);
}

/**
* The `@timestamp` for the event, as a `Date` object.
* If `@timestamp` couldn't be parsed as a `Date`, returns `undefined`.
*/
export function timestampAsDateSafeVersion(event: SafeResolverEvent): Date | undefined {
const value = timestampSafeVersion(event);
if (value === undefined) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,13 @@ export class Simulator {
);
}

public processNodeSubmenu(): ReactWrapper {
return this.domNodes('[data-test-subj="resolver:map:node-submenu"]');
/**
* The items in the submenu that is opened by expanding a node in the map.
*/
public processNodeSubmenuItems(): ReactWrapper {
return this.domNodes('[data-test-subj="resolver:map:node-submenu-item"]');
}

/**
* Return the selected node query string values.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,14 +164,8 @@ describe('Resolver, when analyzing a tree that has two related events for the or
});
it('should open the submenu', async () => {
await expect(
/* eslint-disable array-callback-return */
simulator.map(() => {
const wrapper = simulator.processNodeSubmenu();
if (wrapper.exists()) {
return simulator.processNodeSubmenu().text();
}
})
).toYieldEqualTo('2 registry');
simulator.map(() => simulator.processNodeSubmenuItems().map((node) => node.text()))
).toYieldEqualTo(['2 registry']);
});
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,17 @@ const OptionList = React.memo(
label: string;
prepend?: ReactNode;
} => {
const dataTestSubj = 'resolver:map:node-submenu-item';
return opt.prefix
? {
label: opt.optionTitle,
prepend: <span>{opt.prefix} </span>,
'data-test-subj': dataTestSubj,
}
: {
label: opt.optionTitle,
prepend: <span />,
'data-test-subj': dataTestSubj,
};
})
);
Expand Down Expand Up @@ -114,7 +117,6 @@ const OptionList = React.memo(
options={options}
{...selectableProps}
isLoading={isLoading}
data-test-subj="resolver:map:node-submenu"
>
{(list) => <OptionListItem>{list}</OptionListItem>}
</EuiSelectable>
Expand Down

0 comments on commit 998a664

Please sign in to comment.