I have this snapshot test:
test("Confirm renders", () => {
const { toJSON } = render(
<Confirm
terms={true}
payment={[]}
onAccept={jest.fn()}
amount={10}
limit={500}
store={{
isInNetwork: false
}}
navigation={navMock}
/>
);
expect(toJSON()).toMatchSnapshot();
});
Unfortunately, the test is failing here:
"color": "#13131F",
},
]
}
>
- Oct 31
+ Nov 06
</Text>
</View>
</View>
</View>
</View>
/>
);
expect(toJSON()).toMatchSnapshot();
^
});
It fails on the date check.
On the object that has the dates here I do:
const order = {
merchant: {
tradingName: store.name
},
payments: [
{
id: 1,
paymentStatus: 3,
date: moment(),
amount: amount / 4
},
{
id: 2,
paymentStatus: 0,
date: moment().add(2, "weeks"),
amount: amount / 4
},
{
id: 3,
paymentStatus: 0,
date: moment().add(4, "weeks"),
amount: amount / 4
},
{
id: 4,
paymentStatus: 0,
date: moment().add(6, "weeks"),
amount: amount / 4
}
]
};
Proper exact date check is insignificant, I just need to check that a date is returned. How should I properly setup my snapshot test in this scenario then? How I use snapshot tests with dates?