Skip to content

Commit

Permalink
Added more dateLiteral tests (this and next week)
Browse files Browse the repository at this point in the history
  • Loading branch information
rob-baillie-ortoo committed Feb 24, 2022
1 parent ac74a5f commit 9c674fb
Showing 1 changed file with 83 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,92 @@ private without sharing class ortoo_DateLiteralsTest
Date expectedEarliest = Date.newInstance( 2024, 03, 02 );
Date expectedLatest = Date.newInstance( 2024, 03, 03 );

ortoo_Asserts.assertBetweenInclusive( expectedEarliest, expectedLatest, got, 'endOfThisWeek, when referenced, is set to the stendart of this week, based on the configured "today" and the current user locale' );
ortoo_Asserts.assertBetweenInclusive( expectedEarliest, expectedLatest, got, 'endOfThisWeek, when referenced, is set to the end of this week, based on the configured "today" and the current user locale' );
}

@isTest
private static void startOfLastWeek_whenReferenced_returnsStartOfLastWeekBasedOnTheConfiguredTodayAndLocale() // NOPMD: Test method name format
{
ortoo_DateLiterals.today = Date.newInstance( 2024, 02, 29 );

Test.startTest();
Date got = ortoo_DateLiterals.startOfLastWeek;
Test.stopTest();

Date expectedEarliest = Date.newInstance( 2024, 02, 18 );
Date expectedLatest = Date.newInstance( 2024, 02, 19 );

ortoo_Asserts.assertBetweenInclusive( expectedEarliest, expectedLatest, got, 'startOfLastWeek, when referenced, is set to the start of this week, based on the configured "today" and the current user locale' );
}

@isTest
private static void endOfLastWeek_whenReferenced_returnsEndOfLastWeekBasedOnTheConfiguredTodayAndLocale() // NOPMD: Test method name format
{
ortoo_DateLiterals.today = Date.newInstance( 2024, 02, 29 );

Test.startTest();
Date got = ortoo_DateLiterals.endOfLastWeek;
Test.stopTest();

Date expectedEarliest = Date.newInstance( 2024, 02, 24 );
Date expectedLatest = Date.newInstance( 2024, 02, 25 );

ortoo_Asserts.assertBetweenInclusive( expectedEarliest, expectedLatest, got, 'endOfLastWeek, when referenced, is set to the end of this week, based on the configured "today" and the current user locale' );
}

@isTest
private static void endOfLastWeek_whenReferenced_returnsTheDayBeforeTheStartOfThisWeek() // NOPMD: Test method name format
{
ortoo_DateLiterals.today = Date.newInstance( 2024, 02, 29 );

Test.startTest();
Date got = ortoo_DateLiterals.endOfLastWeek;
Test.stopTest();

System.assertEquals( ortoo_DateLiterals.startOfThisWeek.addDays( -1 ), got, 'endOfLastWeek, is set to the day before startOfThisWeek' );
}


@isTest
private static void startOfNextWeek_whenReferenced_returnsStartOfNextWeekBasedOnTheConfiguredTodayAndLocale() // NOPMD: Test method name format
{
ortoo_DateLiterals.today = Date.newInstance( 2024, 02, 29 );

Test.startTest();
Date got = ortoo_DateLiterals.startOfNextWeek;
Test.stopTest();

Date expectedEarliest = Date.newInstance( 2024, 03, 03 );
Date expectedLatest = Date.newInstance( 2024, 03, 04 );

ortoo_Asserts.assertBetweenInclusive( expectedEarliest, expectedLatest, got, 'startOfNextWeek, when referenced, is set to the start of this week, based on the configured "today" and the current user locale' );
}

@isTest
private static void endOfNextWeek_whenReferenced_returnsEndOfNextWeekBasedOnTheConfiguredTodayAndLocale() // NOPMD: Test method name format
{
ortoo_DateLiterals.today = Date.newInstance( 2024, 02, 29 );

Test.startTest();
Date got = ortoo_DateLiterals.endOfNextWeek;
Test.stopTest();

Date expectedEarliest = Date.newInstance( 2024, 03, 09 );
Date expectedLatest = Date.newInstance( 2024, 03, 10 );

ortoo_Asserts.assertBetweenInclusive( expectedEarliest, expectedLatest, got, 'endOfNextWeek, when referenced, is set to the end of this week, based on the configured "today" and the current user locale' );
}

@isTest
private static void startOfNextWeek_whenReferenced_returnsTheDayAfterTheEndOfThisWeek() // NOPMD: Test method name format
{
ortoo_DateLiterals.today = Date.newInstance( 2024, 02, 29 );

Test.startTest();
Date got = ortoo_DateLiterals.startOfNextWeek;
Test.stopTest();

System.assertEquals( ortoo_DateLiterals.endOfThisWeek.addDays( 1 ), got, 'startOfNextWeek, is set to the day after endOfThisWeek' );
}

}

0 comments on commit 9c674fb

Please sign in to comment.