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

allow clicktracking to fire on liveblog load new articles button #204

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion elements/bulbs-liveblog/bulbs-liveblog.js
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,9 @@ class BulbsLiveblog extends BulbsHTMLElement {
}

removeNewEntriesButton () {
[].forEach.call(this.newEntriesButtons, (button) => button.remove());
setImmediate(() => {
[].forEach.call(this.newEntriesButtons, (button) => button.remove());
});
}

handleBlogFetchError (error) {
Expand Down
14 changes: 10 additions & 4 deletions elements/bulbs-liveblog/bulbs-liveblog.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -409,10 +409,13 @@ describe('<bulbs-liveblog>', () => {
setImmediate(() => done());
});

it('removes the show new entries button', () => {
it('removes the show new entries button', (done) => {
sandbox.spy(subject, 'removeNewEntriesButton');
subject.showNewEntries([entry1]);
expect(subject.removeNewEntriesButton).to.have.been.called;
setImmediate(() => {
expect(subject.removeNewEntriesButton).to.have.been.called;
done();
});
});

it('places the entries in the entries container', () => {
Expand Down Expand Up @@ -522,13 +525,16 @@ describe('<bulbs-liveblog>', () => {
});

describe('removeNewEntriesButton', () => {
it('removes the show new entries button', () => {
it('removes the show new entries button', (done) => {
let button = document.createElement('button');
button.classList.add('liveblog-new-entries');
subject.entriesContainer[0].appendChild(button);
expect(subject.querySelector('button.liveblog-new-entries')).not.to.be.null;
subject.removeNewEntriesButton();
expect(subject.querySelector('button.liveblog-new-entries')).to.be.null;
setImmediate(() => {
expect(subject.querySelector('button.liveblog-new-entries')).to.be.null;
done();
});
});
});
});
Expand Down
29 changes: 19 additions & 10 deletions elements/bulbs-poll/bulbs-poll.test.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,27 @@
import { mount } from 'enzyme';
import React from 'react';
import BulbsPoll from './bulbs-poll';

describe('<bulbs-poll> <BulbsPoll>', function () {
let subject;
let pollEndpoint;
describe('initialDispatch', () => {
let subject;
let pollEndpoint;

beforeEach(() => {
pollEndpoint = 'http://example.tld/api/polls/1';
subject = new BulbsPoll({ src: pollEndpoint });
sinon.spy(subject.store.actions, 'setSrc');
sinon.spy(subject.store.actions, 'fetchPollData');
sinon.spy(subject.store.actions, 'getCachedVoteData');
});
beforeEach(() => {
pollEndpoint = 'http://example.tld/api/polls/1';
subject = new BulbsPoll({ src: pollEndpoint });
subject.store = {
actions: {
setSrc () {},
fetchPollData () {},
getCachedVoteData() {},
},
};
sinon.spy(subject.store.actions, 'setSrc');
sinon.spy(subject.store.actions, 'fetchPollData');
sinon.spy(subject.store.actions, 'getCachedVoteData');
});

describe('initialDispatch', () => {
it('invokes setSrc', function () {
subject.initialDispatch();
expect(subject.store.actions.setSrc).to.have.been.calledWith(pollEndpoint);
Expand Down