generated from spatie/package-skeleton-laravel
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✅ add tests for NepaliToEnglish Conversion.
- Loading branch information
1 parent
ed53a36
commit 19ea06d
Showing
5 changed files
with
58 additions
and
19 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 was deleted.
Oops, something went wrong.
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,47 @@ | ||
<?php | ||
|
||
use Anuzpandey\LaravelNepaliDate\LaravelNepaliDate; | ||
|
||
it('can convert to basic nepali date', function (string $date, string $expectedResult) { | ||
$nepaliDate = LaravelNepaliDate::from($date)->toEnglishDate(); | ||
|
||
expect($nepaliDate) | ||
->toBe($expectedResult); | ||
})->with([ | ||
['2053-01-10', '1996-04-22'], | ||
['2029-04-04', '1972-07-19'], | ||
['2022-12-20', '1966-04-02'], | ||
]); | ||
|
||
it('can convert to english date array', function () { | ||
$date = '2053-01-10'; | ||
|
||
$englishDateArray = LaravelNepaliDate::from($date)->toEnglishDateArray(); | ||
|
||
expect($englishDateArray->toArray()) | ||
->toBeArray() | ||
->toMatchArray([ | ||
'year' => '1996', | ||
'month' => '04', | ||
'day' => '22', | ||
'npYear' => '१९९६', | ||
'npDayName' => 'सोमबार', | ||
]); | ||
}); | ||
|
||
it('can convert to nepali formatted result', function (string $format, string $locale, string $expectedResult) { | ||
$date = '2053-01-10'; | ||
|
||
expect(LaravelNepaliDate::from($date)->toFormattedEnglishDate(format: $format, locale: $locale)) | ||
->toBe($expectedResult); | ||
})->with([ | ||
["d F Y, l", "np", "२२ अप्रिल १९९६, सोमबार"], | ||
["d F Y, l", "en", "22 April 1996, Monday"], | ||
["Y-m-d", "np", "१९९६-०४-२२"], | ||
["Y-m-d", "en", "1996-04-22"], | ||
["l, d F Y", "np", "सोमबार, २२ अप्रिल १९९६"], | ||
["l, d F Y", "en", "Monday, 22 April 1996"], | ||
["d F Y", "np", "२२ अप्रिल १९९६"], | ||
["d F Y", "en", "22 April 1996"], | ||
["Y/m/d", "np", "१९९६/०४/२२"] | ||
]); |
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