Skip to content
This repository has been archived by the owner on Feb 8, 2023. It is now read-only.

Commit

Permalink
Merge pull request #66 from redbadger/event-type
Browse files Browse the repository at this point in the history
Allow users to mark events as conference events.
  • Loading branch information
lpil authored Aug 10, 2016
2 parents 5028e71 + d6f0ebc commit 4bd574e
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 4 deletions.
1 change: 1 addition & 0 deletions lib/fetch/sanitize.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ function sanitizeEventAndNews(item, type) {
id: item.id,
slug: item.slug || null,
tags: item.tags || [],
eventType: get(`${type}.eventType`),
title: get(`${type}.title`),
strapline: get(`${type}.strapline`),
datetime: get(`${type}.timestamp`),
Expand Down
59 changes: 56 additions & 3 deletions lib/fetch/sanitize.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,17 @@ import {
describe('data/sanitize', () => {
describe('sanitizeEvent', () => {
it('should sanitate empty fields', () => {
const event = {
const event = deepFreeze({
id: '123',
data: {},
};
});

const emptyResponse = deepFreeze({
const emptyResponse = {
id: '123',
tags: [],
title: null,
slug: null,
eventType: null,
strapline: null,
featureImageFilename: null,
internalLinks: [],
Expand All @@ -43,8 +44,60 @@ describe('data/sanitize', () => {
longitude: null,
},
},
};

expect(sanitizeEvent(event)).to.deep.equal(emptyResponse);
});

it('should extract real values', () => {
const event = deepFreeze({
id: '123',
slug: 'some-event',
tags: ['tag1', 'tag2'],
data: {
'event.title': { value: 'Event Title' },
'event.eventType': { value: 'Meetup' },
'event.strapline': { value: 'A strapline!' },
'event.event-image': { value: 'foo.png' },
'event.body': { value: ['body'] },
'event.ticketsAvailable': { value: 'ticketsAvailable' },
'event.waitingListOpen': { value: 'waitingListOpen' },
'event.address': { value: 'an address' },
'event.sponsors': { value: ['event', 'sponsor'] },
'event.schedule': { value: ['event', 'schedule'] },
'event.talks': { value: ['event', 'talks'] },
},
});

const emptyResponse = {
id: '123',
tags: ['tag1', 'tag2'],
title: 'Event Title',
slug: 'some-event',
eventType: 'Meetup',
strapline: 'A strapline!',
featureImageFilename: 'foo.png',
internalLinks: [],
externalLinks: [],
datetime: null,
startDateTime: null,
endDateTime: null,
ticketReleaseDate: null,
ticketsAvailable: 'ticketsAvailable',
waitingListOpen: 'waitingListOpen',
body: ['body'],
talks: ['event', 'talks'],
schedule: ['event', 'schedule'],
sponsors: ['event', 'sponsor'],
location: {
address: 'an address',
coordinates: {
latitude: null,
longitude: null,
},
},
};

expect(sanitizeEvent(event)).to.deep.equal(emptyResponse);
});

Expand Down
4 changes: 4 additions & 0 deletions lib/interfaces/event/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ export const eventTypeFields = {
type: new GraphQLNonNull(GraphQLString),
description: 'URL friendly representation of the event title',
},
eventType: {
type: GraphQLString,
description: 'The type of the event. For example "Conference" or "Meetup"',
},
tags: {
type: new GraphQLList(GraphQLString),
description: 'List of tags related the event',
Expand Down
10 changes: 9 additions & 1 deletion prismic/custom-types/events.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
},
"title" : {
"type" : "Text",
"fieldset" : "Title",
"fieldset" : "Details",
"config" : {
"label" : "Title of Event"
}
Expand All @@ -26,6 +26,14 @@
"label" : "Feature Image"
}
},
"eventType" : {
"type" : "Select",
"config" : {
"label" : "Event Type",
"options" : [ "Meetup", "Conference" ],
"placeholder": "Other"
}
},
"body" : {
"type" : "StructuredText",
"fieldset" : "Body",
Expand Down

0 comments on commit 4bd574e

Please sign in to comment.