Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: getWarningInfo test #239

Merged
merged 1 commit into from
Jan 7, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion test/lib/manage-hierarchy.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,25 @@ describe('lib/manage-hierarchy.ts', () => {
});

describe('getWarningInfo', () => {
let clock;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@paulpascal , this will fix the tests, but it will be different in the app. Is it ok like that? If not, I will suggest to move to another library for the relatives... javascript-time-ago is used here...

What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @inromualdo - Yes you are right this will only fix the test, lets handle that properly in another PR.

cc: @kennsippell


// Mocking the system clock to set the current date to June 15, 2024 (quite middle).
// This ensures consistent test behavior for relative date calculations.
// Related issue: https://github.com/medic/cht-user-management/issues/238
beforeEach(() => {
const fixedDate = DateTime.local(2024, 6, 15).toJSDate();
clock = sinon.useFakeTimers(fixedDate.getTime());
});

afterEach(() => {
// Restore the original system clock behavior after tests.
clock.restore();
});


const fakeJob: JobParams = { jobName: 'foo', jobData: { sourceId: 'abc' }};

it('below thrsholds', async () => {
it('below thresholds', async () => {
const chtApi = mockChtApi();
chtApi.countContactsUnderPlace = sinon.stub().resolves(5);
chtApi.lastSyncAtPlace = sinon.stub().resolves(DateTime.now().minus({ days: 100 }));
Expand Down
Loading