Skip to content
This repository has been archived by the owner on Mar 12, 2020. It is now read-only.

Commit

Permalink
fix live blog with correct data structure (#51)
Browse files Browse the repository at this point in the history
  • Loading branch information
andygnewman authored Dec 8, 2016
1 parent dd9ea9c commit 8708729
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions src/presenters/teaser-presenter.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ const TeaserPresenter = class TeaserPresenter {

//returns publishedDate, status, classModifier
get timeObject () {
if (this.data.liveBlog && this.data.liveBlog.status) {
if (this.data.status) {
return this.liveBlog();
} else {
return {
Expand Down Expand Up @@ -151,9 +151,9 @@ const TeaserPresenter = class TeaserPresenter {
// returns publishedDate, status, classModifier
liveBlog () {
return {
publishedDate: this.data.liveBlog.latestUpdate && this.data.liveBlog.latestUpdate.date,
status: LIVEBLOG_MAPPING[this.data.liveBlog.status],
classModifier: this.data.liveBlog.status
publishedDate: this.data.updates && this.data.updates[0].date,
status: LIVEBLOG_MAPPING[this.data.status.toLowerCase()],
classModifier: this.data.status.toLowerCase()
}
}

Expand Down
6 changes: 3 additions & 3 deletions tests/presenters/teaser-presenter.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -277,21 +277,21 @@ describe('Teaser Presenter', () => {
context('status mapping', () => {

it('returns status \'last post\' when \'inprogress\'', () => {
const content = { liveBlog: { status: 'inprogress' } };
const content = { status: 'InProgress' };
subject = new Presenter(content);
expect(subject.liveBlog().status).to.equal('last post');
expect(subject.liveBlog().classModifier).to.equal('inprogress');
});

it('returns status \'coming soon\' when \'comingsoon\'', () => {
const content = { liveBlog: { status: 'comingsoon' } };
const content = { status: 'ComingSoon' };
subject = new Presenter(content);
expect(subject.liveBlog().status).to.equal('coming soon');
expect(subject.liveBlog().classModifier).to.equal('comingsoon');
});

it('returns status \'liveblog closed\' when \'closed\'', () => {
const content = { liveBlog: { status: 'closed' } };
const content = { status: 'Closed' };
subject = new Presenter(content);
expect(subject.liveBlog().status).to.equal('liveblog closed');
expect(subject.liveBlog().classModifier).to.equal('closed');
Expand Down

0 comments on commit 8708729

Please sign in to comment.