|
| 1 | +import { expect } from 'chai'; |
| 2 | +import { spec } from 'modules/innityBidAdapter'; |
| 3 | + |
| 4 | +describe('innityAdapterTest', () => { |
| 5 | + describe('bidRequestValidity', () => { |
| 6 | + it('bidRequest with pub ID and zone ID param', () => { |
| 7 | + expect(spec.isBidRequestValid({ |
| 8 | + bidder: 'innity', |
| 9 | + params: { |
| 10 | + 'pub': 267, |
| 11 | + 'zone': 62546 |
| 12 | + }, |
| 13 | + })).to.equal(true); |
| 14 | + }); |
| 15 | + |
| 16 | + it('bidRequest with no required params', () => { |
| 17 | + expect(spec.isBidRequestValid({ |
| 18 | + bidder: 'innity', |
| 19 | + params: { |
| 20 | + }, |
| 21 | + })).to.equal(false); |
| 22 | + }); |
| 23 | + }); |
| 24 | + |
| 25 | + describe('bidRequest', () => { |
| 26 | + const bidRequests = [{ |
| 27 | + 'bidder': 'innity', |
| 28 | + 'params': { |
| 29 | + 'pub': 267, |
| 30 | + 'zone': 62546 |
| 31 | + }, |
| 32 | + 'adUnitCode': '/19968336/header-bid-tag-0', |
| 33 | + 'transactionId': 'd7b773de-ceaa-484d-89ca-d9f51b8d61ec', |
| 34 | + 'sizes': [300, 250], |
| 35 | + 'bidId': '51ef8751f9aead', |
| 36 | + 'bidderRequestId': '418b37f85e772c', |
| 37 | + 'auctionId': '18fd8b8b0bd757' |
| 38 | + }]; |
| 39 | + |
| 40 | + const bidderRequest = { |
| 41 | + refererInfo: { |
| 42 | + referer: 'https://example.com' |
| 43 | + } |
| 44 | + }; |
| 45 | + |
| 46 | + it('bidRequest HTTP method', () => { |
| 47 | + const requests = spec.buildRequests(bidRequests, bidderRequest); |
| 48 | + requests.forEach(function(requestItem) { |
| 49 | + expect(requestItem.method).to.equal('GET'); |
| 50 | + }); |
| 51 | + }); |
| 52 | + |
| 53 | + it('bidRequest data', () => { |
| 54 | + const requests = spec.buildRequests(bidRequests, bidderRequest); |
| 55 | + expect(requests[0].data.pub).to.equal(267); |
| 56 | + expect(requests[0].data.zone).to.equal(62546); |
| 57 | + expect(requests[0].data.width).to.equal('300'); |
| 58 | + expect(requests[0].data.height).to.equal('250'); |
| 59 | + expect(requests[0].data.callback_uid).to.equal('51ef8751f9aead'); |
| 60 | + }); |
| 61 | + }); |
| 62 | + |
| 63 | + describe('interpretResponse', () => { |
| 64 | + const bidRequest = { |
| 65 | + 'method': 'GET', |
| 66 | + 'url': 'https://as.innity.com/synd/?', |
| 67 | + 'data': { |
| 68 | + 'ver': 2, |
| 69 | + 'hb': 1, |
| 70 | + 'output': 'js', |
| 71 | + 'pub': 267, |
| 72 | + 'zone': 62546, |
| 73 | + 'width': '300', |
| 74 | + 'height': '250', |
| 75 | + 'callback': 'json', |
| 76 | + 'callback_uid': '51ef8751f9aead', |
| 77 | + 'url': 'https://example.com', |
| 78 | + 'cb': '', |
| 79 | + } |
| 80 | + }; |
| 81 | + |
| 82 | + const bidResponse = { |
| 83 | + body: { |
| 84 | + 'cpm': 100, |
| 85 | + 'width': '300', |
| 86 | + 'height': '250', |
| 87 | + 'creative_id': '148186', |
| 88 | + 'callback_uid': '51ef8751f9aead', |
| 89 | + 'tag': '<script>innity=true;</script>', |
| 90 | + }, |
| 91 | + headers: {} |
| 92 | + }; |
| 93 | + |
| 94 | + it('result is correct', () => { |
| 95 | + const result = spec.interpretResponse(bidResponse, bidRequest); |
| 96 | + expect(result[0].requestId).to.equal('51ef8751f9aead'); |
| 97 | + expect(result[0].cpm).to.equal(1); |
| 98 | + expect(result[0].width).to.equal('300'); |
| 99 | + expect(result[0].height).to.equal('250'); |
| 100 | + expect(result[0].creativeId).to.equal('148186'); |
| 101 | + expect(result[0].currency).to.equal('USD'); |
| 102 | + expect(result[0].ttl).to.equal(60); |
| 103 | + expect(result[0].ad).to.equal('<script src="https://cdn.innity.net/frame_util.js"></script><script>innity=true;</script>'); |
| 104 | + }); |
| 105 | + }); |
| 106 | +}); |
0 commit comments