-
Notifications
You must be signed in to change notification settings - Fork 965
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
Added Spanish FromNow strings #146
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
using System; | ||
using Humanizer.Localisation; | ||
using Xunit; | ||
using Xunit.Extensions; | ||
|
||
|
@@ -9,63 +10,123 @@ public class DateHumanizeTests : AmbientCulture | |
public DateHumanizeTests() : base("es-ES") { } | ||
|
||
[Theory] | ||
[InlineData(-10, "hace 10 días")] | ||
[InlineData(-3, "hace 3 días")] | ||
[InlineData(-2, "hace 2 días")] | ||
[InlineData(-1, "ayer")] | ||
public void DaysAgo(int days, string expected) | ||
[InlineData(1, "hace un segundo")] | ||
[InlineData(10, "hace 10 segundos")] | ||
[InlineData(59, "hace 59 segundos")] | ||
[InlineData(60, "hace un minuto")] | ||
public void SecondsAgo(int seconds, string expected) | ||
{ | ||
Assert.Equal(expected, DateTime.UtcNow.AddDays(days).Humanize()); | ||
DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Past); | ||
} | ||
|
||
[Theory] | ||
[InlineData(-10, "hace 10 horas")] | ||
[InlineData(-3, "hace 3 horas")] | ||
[InlineData(-2, "hace 2 horas")] | ||
[InlineData(-1, "hace una hora")] | ||
public void HoursAgo(int hours, string expected) | ||
[InlineData(1, "un segundo desde ahora")] | ||
[InlineData(10, "10 segundos desde ahora")] | ||
[InlineData(59, "59 segundos desde ahora")] | ||
[InlineData(60, "un minuto desde ahora")] | ||
public void SecondsFromNow(int seconds, string expected) | ||
{ | ||
Assert.Equal(expected, DateTime.UtcNow.AddHours(hours).Humanize()); | ||
DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Future); | ||
} | ||
|
||
[Theory] | ||
[InlineData(-10, "hace 10 minutos")] | ||
[InlineData(-3, "hace 3 minutos")] | ||
[InlineData(-2, "hace 2 minutos")] | ||
[InlineData(-1, "hace un minuto")] | ||
public void MinutesAgo(int minutes, string expected) | ||
[InlineData(1, "hace un minuto")] | ||
[InlineData(10, "hace 10 minutos")] | ||
[InlineData(44, "hace 44 minutos")] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I had to test all edge cases and boundary values in the base DateTimeHumanize tests. You shouldn't need to test these when you test your translation. Please remove the cases that aren't specific to your translation. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In this instance I should be testing only 1 singular and 1 plural? Am I understanding what you are saying correctly? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, I think you should only need a singular and a plural. Please apply this to all other tests too. Thanks. |
||
[InlineData(45, "hace una hora")] | ||
[InlineData(119, "hace una hora")] | ||
[InlineData(120, "hace 2 horas")] | ||
public void MinutesAgo(int minutes, string expected) | ||
{ | ||
Assert.Equal(expected, DateTime.UtcNow.AddMinutes(minutes).Humanize()); | ||
DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Past); | ||
} | ||
|
||
[Theory] | ||
[InlineData(-10, "hace 10 meses")] | ||
[InlineData(-3, "hace 3 meses")] | ||
[InlineData(-2, "hace 2 meses")] | ||
[InlineData(-1, "hace un mes")] | ||
public void MonthsAgo(int months, string expected) | ||
[InlineData(1, "un minuto desde ahora")] | ||
[InlineData(10, "10 minutos desde ahora")] | ||
[InlineData(44, "44 minutos desde ahora")] | ||
[InlineData(45, "una hora desde ahora")] | ||
[InlineData(119, "una hora desde ahora")] | ||
[InlineData(120, "2 horas desde ahora")] | ||
public void MinutesFromNow(int minutes, string expected) | ||
{ | ||
Assert.Equal(expected, DateTime.UtcNow.AddMonths(months).Humanize()); | ||
DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Future); | ||
} | ||
|
||
[Theory] | ||
[InlineData(-10, "hace 10 segundos")] | ||
[InlineData(-3, "hace 3 segundos")] | ||
[InlineData(-2, "hace 2 segundos")] | ||
[InlineData(-1, "hace un segundo")] | ||
public void SecondsAgo(int seconds, string expected) | ||
[InlineData(1, "hace una hora")] | ||
[InlineData(10, "hace 10 horas")] | ||
[InlineData(23, "hace 23 horas")] | ||
[InlineData(24, "ayer")] | ||
public void HoursAgo(int hours, string expected) | ||
{ | ||
Assert.Equal(expected, DateTime.UtcNow.AddSeconds(seconds).Humanize()); | ||
DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Past); | ||
} | ||
|
||
[Theory] | ||
[InlineData(-10, "hace 10 años")] | ||
[InlineData(-3, "hace 3 años")] | ||
[InlineData(-2, "hace 2 años")] | ||
[InlineData(-1, "hace un año")] | ||
public void YearsAgo(int years, string expected) | ||
[InlineData(1, "una hora desde ahora")] | ||
[InlineData(10, "10 horas desde ahora")] | ||
[InlineData(23, "23 horas desde ahora")] | ||
[InlineData(24, "mañana")] | ||
public void HoursFromNow(int hours, string expected) | ||
{ | ||
Assert.Equal(expected, DateTime.UtcNow.AddYears(years).Humanize()); | ||
DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Future); | ||
} | ||
|
||
[Theory] | ||
[InlineData(1, "ayer")] | ||
[InlineData(10, "hace 10 días")] | ||
[InlineData(28, "hace 28 días")] | ||
[InlineData(32, "hace un mes")] | ||
public void DaysAgo(int days, string expected) | ||
{ | ||
DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Past); | ||
} | ||
|
||
[Theory] | ||
[InlineData(1, "mañana")] | ||
[InlineData(10, "10 días desde ahora")] | ||
[InlineData(28, "28 días desde ahora")] | ||
[InlineData(32, "un mes desde ahora")] | ||
public void DaysFromNow(int days, string expected) | ||
{ | ||
DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Future); | ||
} | ||
|
||
[Theory] | ||
[InlineData(1, "hace un mes")] | ||
[InlineData(10, "hace 10 meses")] | ||
[InlineData(11, "hace 11 meses")] | ||
[InlineData(12, "hace un año")] | ||
public void MonthsAgo(int months, string expected) | ||
{ | ||
DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Past); | ||
} | ||
|
||
[Theory] | ||
[InlineData(1, "un mes desde ahora")] | ||
[InlineData(10, "10 meses desde ahora")] | ||
[InlineData(11, "11 meses desde ahora")] | ||
[InlineData(12, "un año desde ahora")] | ||
public void MonthsFromNow(int months, string expected) | ||
{ | ||
DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Future); | ||
} | ||
|
||
[Theory] | ||
[InlineData(1, "hace un año")] | ||
[InlineData(2, "hace 2 años")] | ||
public void YearsAgo(int years, string expected) | ||
{ | ||
DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Past); | ||
} | ||
|
||
[Theory] | ||
[InlineData(1, "un año desde ahora")] | ||
[InlineData(2, "2 años desde ahora")] | ||
public void YearsFromNow(int years, string expected) | ||
{ | ||
DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future); | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for replacing these! :)