mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-13 07:46:06 +00:00
unit tests for ISO format of event dates
This commit is contained in:
parent
44d6f31574
commit
fdf38af4e9
@ -374,6 +374,31 @@ describe('CreatePost', () => {
|
||||
})
|
||||
})
|
||||
|
||||
describe('with event start in no ISO format', () => {
|
||||
it('throws an error', async () => {
|
||||
const now = new Date()
|
||||
const eventStart = new Date(now.getFullYear(), now.getMonth() - 1).toISOString()
|
||||
await expect(
|
||||
mutate({
|
||||
mutation: createPostMutation(),
|
||||
variables: {
|
||||
...variables,
|
||||
postType: 'Event',
|
||||
eventInput: {
|
||||
eventStart: eventStart.split('T')[0],
|
||||
},
|
||||
},
|
||||
}),
|
||||
).resolves.toMatchObject({
|
||||
errors: [
|
||||
{
|
||||
message: 'Event start date must be in ISO format!',
|
||||
},
|
||||
],
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('with event start date in the past', () => {
|
||||
it('throws an error', async () => {
|
||||
const now = new Date()
|
||||
@ -423,6 +448,32 @@ describe('CreatePost', () => {
|
||||
})
|
||||
})
|
||||
|
||||
describe('with valid start date and not ISO formated end date', () => {
|
||||
it('throws an error', async () => {
|
||||
const now = new Date()
|
||||
const eventEnd = new Date(now.getFullYear(), now.getMonth() + 2).toISOString()
|
||||
await expect(
|
||||
mutate({
|
||||
mutation: createPostMutation(),
|
||||
variables: {
|
||||
...variables,
|
||||
postType: 'Event',
|
||||
eventInput: {
|
||||
eventStart: new Date(now.getFullYear(), now.getMonth() + 1).toISOString(),
|
||||
eventEnd: eventEnd.split('T')[0],
|
||||
},
|
||||
},
|
||||
}),
|
||||
).resolves.toMatchObject({
|
||||
errors: [
|
||||
{
|
||||
message: 'Event end date must be in ISO format!',
|
||||
},
|
||||
],
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('with valid start date and end date before start date', () => {
|
||||
it('throws an error', async () => {
|
||||
const now = new Date()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user