You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import*asSugarfrom"sugar";Sugar.Date.getLocale("en").addFormat("the {edge} of the year {yyyy}");exportfunctionfailingBehaivor(date: string,comparisonDate: string){console.log("date, comparisonDate:",date,comparisonDate);constparsedDate=Sugar.Date.create(date);letparsedComparisonDate=Sugar.Date.get(parsedDate,comparisonDate);console.log("parsedComparisonDate:",parsedComparisonDate);returnparsedComparisonDate;}
jest test file: something.test.ts
import{failingBehaivor}from".";describe.only("test-fail",()=>{test("test1",()=>{constdate="1/26/2016 21:30";constresult=failingBehaivor(date,"the end of next year");expect(`${result}`).not.toBe("Invalid Date");});test("test2",()=>{constdate="2020-11-04T05:00:00.000Z";constresult=failingBehaivor(date,"the end of the year 2022");expect(`${result}`).not.toBe("Invalid Date");});});
when running the tests separately the console.log("parsedComparisonDate:", parsedComparisonDate); prints a correct value.
however when running both tests the console.log("parsedComparisonDate:", parsedComparisonDate); prints Invalid Date.
Am I doing something wrong?
The text was updated successfully, but these errors were encountered:
output for the first run: the formats that been added via ".addFormat" are at the top of the ".compiledFormats" array.
but in the second test the format regex moved to third place, and for the sentence "the end of the year 2022" it catches the first default format:
Sugar.Date.getLocale().addFormat("the {edge} {weekday} of {shift} {unit} {month} {year}"); isn't working well.
by the regex it should catch the date. however it's not.
combination of {unit} {year} in the format fails the format
something.ts
jest test file:
something.test.ts
when running the tests separately the
console.log("parsedComparisonDate:", parsedComparisonDate);
prints a correct value.however when running both tests the
console.log("parsedComparisonDate:", parsedComparisonDate);
prints Invalid Date.Am I doing something wrong?
The text was updated successfully, but these errors were encountered: