Skip to content

Commit

Permalink
Update straggling test
Browse files Browse the repository at this point in the history
  • Loading branch information
kimlisa committed Jan 8, 2024
1 parent feefd54 commit a606110
Showing 1 changed file with 12 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,13 @@ describe('onProceed correctly deduplicates, removes static traits, updates meta,
.spyOn(discoverCtx, 'updateAgentMeta')
.mockImplementation(x => x);

const { result, waitFor, waitForNextUpdate } = renderHook(
() => useUserTraits(),
{
wrapper: wrapperFn(discoverCtx, teleCtx),
}
);
const { result, waitFor } = renderHook(() => useUserTraits(), {
wrapper: wrapperFn(discoverCtx, teleCtx),
});

await waitFor(() =>
expect(result.current.staticTraits.kubeUsers).toHaveLength(2)
);
await waitForNextUpdate();

const staticTraits = result.current.staticTraits;
const dynamicTraits = result.current.dynamicTraits;
Expand Down Expand Up @@ -157,17 +153,13 @@ describe('onProceed correctly deduplicates, removes static traits, updates meta,
.spyOn(discoverCtx, 'updateAgentMeta')
.mockImplementation(x => x);

const { result, waitFor, waitForNextUpdate } = renderHook(
() => useUserTraits(),
{
wrapper: wrapperFn(discoverCtx, teleCtx),
}
);
const { result, waitFor } = renderHook(() => useUserTraits(), {
wrapper: wrapperFn(discoverCtx, teleCtx),
});

await waitFor(() =>
expect(result.current.staticTraits.databaseNames).toHaveLength(2)
);
await waitForNextUpdate();

const staticTraits = result.current.staticTraits;
const dynamicTraits = result.current.dynamicTraits;
Expand Down Expand Up @@ -314,17 +306,13 @@ describe('onProceed correctly deduplicates, removes static traits, updates meta,
.spyOn(discoverCtx, 'updateAgentMeta')
.mockImplementation(x => x);

const { result, waitFor, waitForNextUpdate } = renderHook(
() => useUserTraits(),
{
wrapper: wrapperFn(discoverCtx, teleCtx),
}
);
const { result, waitFor } = renderHook(() => useUserTraits(), {
wrapper: wrapperFn(discoverCtx, teleCtx),
});

await waitFor(() =>
expect(result.current.staticTraits.logins).toHaveLength(2)
);
await waitForNextUpdate();

const staticTraits = result.current.staticTraits;
const dynamicTraits = result.current.dynamicTraits;
Expand Down Expand Up @@ -400,13 +388,12 @@ describe('static and dynamic traits are correctly separated and correctly create
...getMeta(resourceKind),
};

const { result, waitFor } = renderHook(() => useUserTraits(), {
const { result, waitForNextUpdate } = renderHook(() => useUserTraits(), {
wrapper: wrapperFn(discoverCtx, teleCtx),
});

await waitFor(() =>
expect(teleCtx.userService.fetchUser).toHaveBeenCalled()
);
await waitForNextUpdate();
expect(teleCtx.userService.fetchUser).toHaveBeenCalled();

// Test correct making of dynamic traits.
const dynamicTraits = result.current.dynamicTraits;
Expand Down

0 comments on commit a606110

Please sign in to comment.