diff --git a/modules/brainyBidAdapter.js b/modules/brainyBidAdapter.js
index 3274b10b97d..e8e5bda9f37 100644
--- a/modules/brainyBidAdapter.js
+++ b/modules/brainyBidAdapter.js
@@ -126,6 +126,29 @@ export const spec = {
});
return bidResponses;
+ },
+
+ /**
+ * SyncURLがある場合にレスポンスを解析してURLを返す
+ * @param {object} syncOptions Syncの設定
+ * @param {object} serverResponses SSPからのレスポンス
+ * @return {object} 表示タイプとURLが入ったオブジェクト
+ */
+ getUserSyncs: function(syncOptions, serverResponses) {
+ const syncs = [];
+ if (syncOptions.pixelEnabled) {
+ const brainyResponseObj = serverResponses[0].body;
+ if (!brainyResponseObj) {
+ return [];
+ }
+ if (brainyResponseObj.syncUrl && brainyResponseObj.syncUrl != 'null' && brainyResponseObj.syncUrl.length > 0) {
+ syncs.push({
+ type: 'image',
+ url: brainyResponseObj.syncUrl
+ });
+ }
+ }
+ return syncs;
}
};
registerBidder(spec);
diff --git a/test/spec/modules/brainyBidAdapter_spec.js b/test/spec/modules/brainyBidAdapter_spec.js
index 8dc74435263..157356e82db 100644
--- a/test/spec/modules/brainyBidAdapter_spec.js
+++ b/test/spec/modules/brainyBidAdapter_spec.js
@@ -31,16 +31,39 @@ const bidReq = [{
const correctReq = {
accountID: '12345',
slotID: '12345'
-}
+};
const bidResponse = {
ad_id: '1036e9746c-d186-49ae-90cb-2796d0f9b223',
adm: '',
+ syncUrl: '//testparm.com/ssp-sync/p/sync?uid=2110180601155125000059&buyer=2&slot=34',
cpm: 100,
height: 250,
width: 300
};
+const bidSyncResponse = [{
+ body: {
+ ad_id: '1036e9746c-d186-49ae-90cb-2796d0f9b223',
+ adm: '',
+ syncUrl: '//testparm.com/ssp-sync/p/sync?uid=2110180601155125000059&buyer=2&slot=34',
+ cpm: 100,
+ height: 250,
+ width: 300
+ }
+}];
+
+const invalidSyncBidResponse = [{
+ body: {
+ ad_id: '1036e9746c-d186-49ae-90cb-2796d0f9b223',
+ adm: '',
+ syncUrl: 'null',
+ cpm: 100,
+ height: 250,
+ width: 300
+ }
+}];
+
describe('brainy Adapter', () => {
describe('request', () => {
it('should validate bid request', () => {
@@ -77,4 +100,29 @@ describe('brainy Adapter', () => {
expect(bid.height).to.equal(bidResponse.height);
});
});
+
+ describe('spec.getUserSyncs', () => {
+ let syncOptions
+ beforeEach(() => {
+ syncOptions = {
+ enabledBidders: ['brainy'],
+ pixelEnabled: true
+ }
+ });
+ it('sucess with usersync url', () => {
+ const result = [];
+ result.push({type: 'image', url: '//testparm.com/ssp-sync/p/sync?uid=2110180601155125000059&buyer=2&slot=34'});
+ expect(spec.getUserSyncs(syncOptions, bidSyncResponse)).to.deep.equal(result);
+ });
+
+ it('sucess without usersync url', () => {
+ const result = [];
+ expect(spec.getUserSyncs(syncOptions, invalidSyncBidResponse)).to.deep.equal(result);
+ });
+ it('empty response', () => {
+ const serverResponse = [{body: {}}];
+ const result = [];
+ expect(spec.getUserSyncs(syncOptions, serverResponse)).to.deep.equal(result);
+ });
+ });
});