Exemplo n.º 1
0
      const getDisplayData = async ({ startDate, endDate }) => {
        const campaign = {
          ...fixtures().display,
          start_date: startDate.toDate(),
          end_date: endDate.toDate()
        }

        const display = {
          total: 20,
          count: 4,
          results: [{
            campaigns: [
              campaign,
              campaign,
              campaign,
              campaign,
              campaign
            ]
          }]
        }

        resolvers.__set__('Curation', {
          mongoFetch: sinon.stub().yields(null, display)
        })

        const result = await resolvers.display({}, {}, req, {})
        return result
      }
Exemplo n.º 2
0
 empty(() => {
   fabricate('users', { channel_ids: ['456'] }, (err, user) => {
     if (err) {
       done(err)
     }
     server = app.listen(5000, () => done())
   })
 })
Exemplo n.º 3
0
    it('rejects if SOV is over 100%', async () => {
      const display = {
        total: 20,
        count: 2,
        results: [{
          campaigns: [
            fixtures().display,
            fixtures().display,
            fixtures().display,
            fixtures().display,
            fixtures().display
          ]
        }]
      }
      resolvers.__set__('Curation', { mongoFetch: (sinon.stub().yields(null, display)) })

      await resolvers.display({}, {}, req, {}).catch((e) => {
        e.message.should.containEql('Share of voice sum cannot be greater than 100')
      })
    })
Exemplo n.º 4
0
    it('selects a campaign based on a counter', async () => {
      const display = {
        total: 20,
        count: 4,
        results: [{
          campaigns: [
            { ...fixtures().display, name: 0 },
            { ...fixtures().display, name: 1 },
            { ...fixtures().display, name: 2 },
            { ...fixtures().display, name: 3 },
            { ...fixtures().display, name: 4 }
          ]
        }]
      }
      resolvers.__set__('Curation', { mongoFetch: (sinon.stub().yields(null, display)) })

      const result = await resolvers.display({}, {}, req, {})
      const nextResult = await resolvers.display({}, {}, req, {})
      nextResult.name.should.equal(result.name + 1)
    })
Exemplo n.º 5
0
    it('can fetch campaign data', async () => {
      const display = {
        total: 20,
        count: 4,
        results: [{
          campaigns: [
            fixtures().display,
            fixtures().display,
            fixtures().display,
            fixtures().display
          ]
        }]
      }
      resolvers.__set__('Curation', { mongoFetch: (sinon.stub().yields(null, display)) })

      const result = await resolvers.display({}, {}, req, {})
      result.name.should.equal('Sample Campaign')
      result.canvas.headline.should.containEql('Sample copy')
      result.panel.headline.should.containEql('Euismod Inceptos Quam')
    })
Exemplo n.º 6
0
 beforeEach(() => {
   articles = {
     total: 20,
     count: 1,
     results: [
       _.extend(fixtures().articles, {
         slugs: ['slug-1'],
         tags: ['dog'],
         vertical: { id: '54276766fd4f50996aeca2b3' }
       })
     ]
   }
   article = _.extend({}, fixtures().articles, {
     slugs: ['slug-2'],
     channel_id: '456'
   })
   const authors = { total: 20, count: 1, results: [fixtures().authors] }
   const channels = { total: 20, count: 1, results: [fixtures().channels] }
   const curations = { total: 20, count: 1, results: [fixtures().curations] }
   const tags = { total: 20, count: 1, results: [fixtures().tags] }
   promisedMongoFetch = sinon.stub()
   resolvers.__set__('mongoFetch', sinon.stub().yields(null, articles))
   resolvers.__set__('promisedMongoFetch', promisedMongoFetch)
   resolvers.__set__('Author', { mongoFetch: (sinon.stub().yields(null, authors)) })
   resolvers.__set__('Channel', { mongoFetch: (sinon.stub().yields(null, channels)) })
   resolvers.__set__('Curation', { mongoFetch: (sinon.stub().yields(null, curations)) })
   resolvers.__set__('Tag', { mongoFetch: (sinon.stub().yields(null, tags)) })
 })