Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rewards-integration - new action signal names #82

Merged
@@ -67,7 +67,8 @@ class HotDog extends Component {
const message = {
offerId,
actionId,
origin: 'rewards-hotdog',
origin: 'rewards-hotdog-card',
type: 'offer-action-signal'
};
this.messageBackground('rewardSignal', message);
}
@@ -120,7 +120,8 @@ class OfferCard extends Component {
const message = {
offerId,
actionId,
origin: 'rewards-card',
origin: 'rewards-hotdog-card',
type: (actionId === 'rewards_off') ? 'action-signal' : 'offer-action-signal',
};
this.messageBackground('rewardSignal', message);
}
@@ -67,7 +67,7 @@ class RewardsApp {
}

start() {
if (BROWSER_INFO.name === 'chrome') {
if (document.head.createShadowRoot || document.head.attachShadow) {
this.renderShadow();
} else {
// use iframe to encapsulate CSS - fallback for everything else besides chrome
@@ -82,12 +82,14 @@ export function setOfferRead(id) {
* @return {Object}
*/
export function sendSignal(actionId, offerId) {
return {
const signal = {
type: SEND_SIGNAL,
data: {
actionId,
offerId,
origin: 'rewards-panel'
origin: 'rewards-hub',
type: offerId ? 'offer-action-signal' : 'action-signal'
}
};
return signal;
}
@@ -87,17 +87,43 @@ describe('app/panel/actions/RewardsActions.js', () => {
expect(actions).toEqual([expectedPayload]);
});

test('sendSignal action should return correctly', () => {
test('sendSignal offer-action-signal should return correctly', () => {
const initialState = {};
const store = mockStore(initialState);

const actionId = 'action_id';
const offerId = 'offer_id';
const origin = 'rewards-panel';
const expectedPayload = { data: { actionId, offerId, origin }, type: SEND_SIGNAL };
const origin = 'rewards-hub';
const type = 'offer-action-signal';
const expectedPayload = {
data: {
actionId, offerId, origin, type
},
type: SEND_SIGNAL
};
store.dispatch(rewardsActions.sendSignal(actionId, offerId));

const actions = store.getActions();
expect(actions).toEqual([expectedPayload]);
});

test('sendSignal action-signal should return correctly', () => {
const initialState = {};
const store = mockStore(initialState);

const actionId = 'action_id';
const offerId = undefined;
const origin = 'rewards-hub';
const type = 'action-signal';
const expectedPayload = {
data: {
actionId, offerId, origin, type
},
type: SEND_SIGNAL
};
store.dispatch(rewardsActions.sendSignal(actionId));

const actions = store.getActions();
expect(actions).toEqual([expectedPayload]);
});
});
@@ -50,10 +50,12 @@ class Rewards {
}

sendSignal(message) {
const { offerId, actionId, origin } = message;
const {
offerId, actionId, origin, type
} = message;
const signal = {
type,
origin: origin ? `ghostery-${origin}` : 'ghostery',
type: 'offer-action-signal',
data: {
action_id: actionId,
offer_id: offerId
ProTip! Use n and p to navigate between commits in a pull request.