UNPKG

paradigm-channels

Version:
825 lines (755 loc) 28.3 kB
const Migrations = require('structure-migrations') const MockHTTPServer = require('../helpers/mock-http-server') const pluginsList = require('../helpers/plugins') const server = new MockHTTPServer() const version = process.env.API_VERSION async function createCategory(orgId, appId, data = {}) { const res = await server .post(`/api/${version}/categories`) .set('organizationid', orgId) .set('applicationid', appId) .send(data) return res.body.pkg } async function createChannel(orgId, appId, data = {}) { const res = await server .post(`/api/${version}/channels`) .set('organizationid', orgId) .set('applicationid', appId) .send(data) return res.body.pkg } async function createDocument(orgId, appId, data = {}) { const res = await server .post(`/api/${version}/documents`) .set('organizationid', orgId) .set('applicationid', appId) .send(data) return res.body.pkg } async function createUser(orgId, appId, data = {}) { const res = await server .post(`/api/${version}/users`) .set('organizationid', orgId) .set('applicationid', appId) .send(data) return res.body.pkg } function getDuplicateIndexes(arr) { const duplicateIndexes = [] const items = new Map() for(let i = 0, l = arr.length; i < l; i++) { const item = arr[i] const current = items.get(item) if(current) { duplicateIndexes.push(current) duplicateIndexes.push(i) } else { items.set(item, i) } } return duplicateIndexes } const createOrgAndApp = async function() { // getting an organization and application Ids var res0 = await new MockHTTPServer() .post(`/api/${process.env.API_VERSION}/organizations`) .send({ title: 'work it' }) const org = res0.body.pkg const orgId = org.id var app = await new MockHTTPServer() .post(`/api/${process.env.API_VERSION}/applications`) .set('organizationid', orgId) .send({ desc: '', title: 'App 45' }) const appId = app.body.pkg.id return {orgId, appId} } describe('Large Channel', function() { beforeEach(function() { this.migration = new Migrations({ db: 'test', items: {tables: [{ action: 'create', table: 'digital_assets', indexes: [ 'applicationId', 'updatedAt' ] }]}, plugins: pluginsList }) return this.migration.process() }) afterEach(function() { return this.migration.purge() }) it('should pass all expectations', async function() { this.timeout(10000) const {orgId, appId} = await createOrgAndApp() const usersPromise = Promise.all([ createUser(orgId, appId, { email: 'margo@b.com', password: 'foo', username: 'margo' }), createUser(orgId, appId, { email: 'mark@b.com', password: 'foo', username: 'mark' }), createUser(orgId, appId, { email: 'must@b.com', password: 'foo', username: 'mustafa' }), createUser(orgId, appId, { email: 'omar@b.com', password: 'foo', username: 'omar' }), createUser(orgId, appId, { email: 'zach@b.com', password: 'foo', username: 'zach' }) ]) const channelsPromise = Promise.all([ createChannel(orgId, appId, { resources: [ { categorySlugs: ['animals'], limit: 5, name: 'latest' } ], slug: 'animals', title: 'Animals' }), createChannel(orgId, appId, { resources: [ { categorySlugs: ['entertainment'], limit: 5, name: 'latest' } ], slug: 'entertainment', title: 'Entertainment' }), createChannel(orgId, appId, { resources: [ { categorySlugs: ['food'], limit: 5, name: 'latest' } ], slug: 'food', title: 'Food' }), createChannel(orgId, appId, { resources: [ { categorySlugs: ['geek'], limit: 5, name: 'latest' } ], slug: 'geek', title: 'Geek' }), createChannel(orgId, appId, { resources: [ { categorySlugs: ['humor'], limit: 5, name: 'latest' } ], slug: 'humor', title: 'Humor' }), createChannel(orgId, appId, { resources: [ { categorySlugs: ['news'], limit: 5, name: 'latest' } ], slug: 'news', title: 'News' }), createChannel(orgId, appId, { resources: [ { categorySlugs: ['relationships'], limit: 5, name: 'latest' } ], slug: 'relationships', title: 'Relationships' }), createChannel(orgId, appId, { resources: [ { categorySlugs: ['trending'], limit: 5, name: 'latest' } ], slug: 'trending', title: 'Trending' }), createChannel(orgId, appId, { resources: [ { categorySlugs: ['videos'], limit: 5, name: 'latest' } ], slug: 'videos', title: 'Videos' }), createChannel(orgId, appId, { resources: [ { categorySlugs: ['trending'], limit: 3, name: 'trending' }, { categorySlugs: ['humor'], limit: 4, name: 'humor' }, { categorySlugs: ['videos'], limit: 2, name: 'videos' }, { // categorySlugs: ['trending'], limit: 5, name: 'latest' } ], slug: 'home', title: 'Home' }), ]) const categoriesPromise = Promise.all([ createCategory(orgId, appId, { slug: 'animals', title: 'Animals' }), createCategory(orgId, appId, { slug: 'entertainment', title: 'Entertainment' }), createCategory(orgId, appId, { slug: 'food', title: 'Food' }), createCategory(orgId, appId, { slug: 'geek', title: 'Geek' }), createCategory(orgId, appId, { slug: 'humor', title: 'Humor' }), createCategory(orgId, appId, { slug: 'news', title: 'News' }), createCategory(orgId, appId, { slug: 'relationships', title: 'Relationships' }), createCategory(orgId, appId, { slug: 'trending', title: 'Trending' }), createCategory(orgId, appId, { slug: 'videos', title: 'Videos' }), ]) const response = await Promise.all([usersPromise, categoriesPromise, channelsPromise]) // console.error('response', response) const users = response[0] const categories = response[1] const categoryAnimals = categories[0] const categoryEntertainment = categories[1] const categoryFood = categories[2] const categoryHumor = categories[4] const categoryNews = categories[5] const categoryRelationships = categories[6] const categoryTrending = categories[7] const categoryVideos = categories[8] await Promise.all([ createDocument(orgId, appId, { categoryIds: [categoryTrending.id, categoryVideos.id], desc: '', fields: [{foo: 'bar'}], publishedAt: new Date('03-15-2017 18:01 UTC').toISOString(), status: 'published', tags: ['snoop', 'dogg', 'trump', 'clown'], title: 'Snoop Dogg Points Gun At Donald Trump Clown In His New Music Video', slug: 'snoop-dogg-points-gun', userId: users[0].id }), createDocument(orgId, appId, { categoryIds: [categoryNews.id], desc: '', fields: [{foo: 'bar'}], status: 'draft', tags: ['tax', 'trump', 'return'], title: 'Trump has not paid taxes since Bush was President', slug: 'trump-has-not-paid-taxes', userId: users[0].id }), createDocument(orgId, appId, { categoryIds: [categoryNews.id], desc: '', fields: [{foo: 'bar'}], publishedAt: new Date('03-15-2017 15:01 UTC').toISOString(), status: 'published', tags: ['tax', 'trump', 'return'], title: 'Rachel Maddow Leaked Donald Trumps Tax Returns And It Was Fairly Anti-Climatic', slug: 'rachel-maddow-leaked', userId: users[0].id }), createDocument(orgId, appId, { categoryIds: [categoryTrending.id], desc: '', fields: [{foo: 'bar'}], publishedAt: new Date('03-14-2017 19:10 UTC').toISOString(), status: 'published', tags: ['bbc'], title: 'The BBC Dad Whose Interview Was Interrupted By His Kids Finally Spoke About It', slug: 'the-bbc-dad', userId: users[1].id }), createDocument(orgId, appId, { categoryIds: [categoryTrending.id], desc: '', fields: [{foo: 'bar'}], publishedAt: new Date('03-14-2017 18:10 UTC').toISOString(), status: 'published', tags: ['parenting'], title: 'This Moms Tribute To Her Ex Sends An Important Message About Coparenting', slug: 'this-moms-tribute', userId: users[1].id }), createDocument(orgId, appId, { categoryIds: [categoryTrending.id, categoryHumor.id], desc: '', fields: [{foo: 'bar'}], publishedAt: new Date('03-14-2017 17:10 UTC').toISOString(), status: 'published', tags: ['obama', 'trump'], title: 'Obamas White House Photographer Just Threw Shade At Trumps Administration', slug: 'obamas-white-house-photographer', userId: users[2].id }), createDocument(orgId, appId, { categoryIds: [categoryTrending.id, categoryHumor.id], desc: '', fields: [{foo: 'bar'}], publishedAt: new Date('03-14-2017 17:10 UTC').toISOString(), status: 'draft', tags: ['obama', 'trump'], title: 'Obama throws shade at the Photographer', slug: 'obamas-thorws-shade', userId: users[2].id }), createDocument(orgId, appId, { categoryIds: [categoryEntertainment.id], desc: '', fields: [{foo: 'bar'}], publishedAt: new Date('03-14-2017 16:10 UTC').toISOString(), status: 'published', tags: ['got', 'hbo'], title: 'Alert: Official Game of Thrones Spin-Off Series Is A Serious Possibility', slug: 'alert-official-game-of-thrones', userId: users[2].id }), createDocument(orgId, appId, { categoryIds: [categoryTrending.id, categoryHumor.id], desc: '', fields: [{foo: 'bar'}], publishedAt: new Date('03-14-2017 15:10 UTC').toISOString(), status: 'published', tags: ['obama', 'biden'], title: 'Joe Biden Revealed His Favorite Obama-Biden Bromance Meme And Its A Classic', slug: 'joe-biden-revealed', userId: users[3].id }), createDocument(orgId, appId, { categoryIds: [categoryTrending.id], desc: '', fields: [{foo: 'bar'}], publishedAt: new Date('03-14-2017 14:10 UTC').toISOString(), status: 'published', tags: ['runner', 'jogger'], title: 'Female Jogger Fights Off Rapist And Locks Him In Bathroom After His Brutal Attack', slug: 'female-jogger', userId: users[3].id }), createDocument(orgId, appId, { categoryIds: [categoryTrending.id], desc: '', fields: [{foo: 'bar'}], publishedAt: new Date('03-14-2017 13:10 UTC').toISOString(), status: 'published', tags: ['party', 'grandma'], title: 'This Grandma Partied With College Kids On Spring Break And Were In Love', slug: 'this-grandma', userId: users[4].id }), createDocument(orgId, appId, { categoryIds: [categoryTrending.id], desc: '', fields: [{foo: 'bar'}], publishedAt: new Date('03-14-2017 12:10 UTC').toISOString(), status: 'published', tags: ['texting', 'starwars'], title: 'This Guys Texting Prank Is A Must-Try If Youre A Star Wars Fan', slug: 'this-guys-texting-prank', userId: users[4].id }), createDocument(orgId, appId, { categoryIds: [categoryTrending.id], desc: '', fields: [{foo: 'bar'}], publishedAt: new Date('03-14-2017 11:10 UTC').toISOString(), status: 'published', tags: ['texting', 'starwars'], title: 'Will Smith Took A Selfie While Bungee Jumping And Is Basically Uncle Phils Twin', slug: 'will-smith-selfie', userId: users[0].id }), createDocument(orgId, appId, { categoryIds: [categoryTrending.id], desc: '', fields: [{foo: 'bar'}], publishedAt: new Date('03-14-2017 10:10 UTC').toISOString(), status: 'published', tags: ['braeking', 'bannon'], title: 'Why Was The Jacuzzi In Steve Bannons Florida Home Allegedly Covered In Acid?', slug: 'why-was-the-jacuzzi', userId: users[0].id }), createDocument(orgId, appId, { categoryIds: [categoryTrending.id, categoryNews.id], desc: '', fields: [{foo: 'bar'}], publishedAt: new Date('03-14-2017 09:10 UTC').toISOString(), status: 'published', tags: ['twitter', 'blizzard'], title: '22 Reactions To Blizzard Stella Thatll Make You Forgot How Cold It Is Outside', slug: '22-reactions-to-blizzard', userId: users[1].id }), createDocument(orgId, appId, { categoryIds: [categoryTrending.id], desc: '', fields: [{foo: 'bar'}], publishedAt: new Date('03-13-2017 16:47 UTC').toISOString(), status: 'published', tags: ['funny'], title: 'This Moms List Of Toilet Rules To Try And Get Some Peace Is Way Too Relatable', slug: 'this-moms-list-of-toilet', userId: users[0].id }), createDocument(orgId, appId, { categoryIds: [categoryTrending.id], desc: '', fields: [{foo: 'bar'}], publishedAt: new Date('03-13-2017 16:35 UTC').toISOString(), status: 'published', tags: ['sexism', 'work'], title: 'Male And Female Coworkers Swapped Names For A Week To Prove Workplace Sexism', slug: 'male-and-female-coworkers', userId: users[0].id }), createDocument(orgId, appId, { categoryIds: [categoryRelationships.id], desc: '', fields: [{foo: 'bar'}], publishedAt: new Date('03-13-2017 16:34 UTC').toISOString(), status: 'published', tags: ['sexism', 'work'], title: 'This Is What The Ideal Body Type For Men And Women Looks Like', slug: 'this-is-what-theideal-body', userId: users[0].id }), createDocument(orgId, appId, { categoryIds: [categoryTrending.id, categoryEntertainment.id], desc: '', fields: [{foo: 'bar'}], publishedAt: new Date('03-13-2017 16:00 UTC').toISOString(), status: 'published', tags: ['got', 'hbo'], title: 'Its Official: Ed Sheeran Will Appear In Game of Thrones Season 7', slug: 'its-official-ed', userId: users[3].id }), createDocument(orgId, appId, { categoryIds: [categoryTrending.id, categoryEntertainment.id], desc: '', fields: [{foo: 'bar'}], publishedAt: new Date('03-13-2017 16:00 UTC').toISOString(), status: 'draft', tags: ['got', 'hbo'], title: 'Its Official: Maise Williams loves Ed Sheeran', slug: 'its-official-maise', userId: users[3].id }), createDocument(orgId, appId, { categoryIds: [categoryTrending.id, categoryVideos.id], desc: '', fields: [{foo: 'bar'}], publishedAt: new Date('03-13-2017 15:08 UTC').toISOString(), status: 'published', tags: ['breaking', 'bad'], title: 'You Can Now Watch The Breaking Bad Movie Online And Its Brilliant', slug: 'you-can-now-watch', userId: users[3].id }), createDocument(orgId, appId, { categoryIds: [categoryTrending.id], desc: '', fields: [{foo: 'bar'}], publishedAt: new Date('03-13-2017 14:10 UTC').toISOString(), status: 'published', tags: ['hell', 'challenge'], title: 'The Hell Challenge Is Getting Teens In Serious Trouble With Their Parents', slug: 'the-hell-challenge-is', userId: users[4].id }), createDocument(orgId, appId, { categoryIds: [categoryTrending.id], desc: '', fields: [{foo: 'bar'}], publishedAt: new Date('03-13-2017 12:43 UTC').toISOString(), status: 'published', tags: ['microwave', 'spying'], title: 'Kellyanne Conway Suggests Microwaves Are Capable Of Spying On Us', slug: 'kellyanne-conway-suggests', userId: users[4].id }), createDocument(orgId, appId, { categoryIds: [categoryTrending.id], desc: '', fields: [{foo: 'bar'}], publishedAt: new Date('03-13-2017 12:41 UTC').toISOString(), status: 'published', tags: ['texas', 'politics'], title: 'Texas Politician Proposes Law That Fines Men For Masturbation', slug: 'texas-politician-proposes', userId: users[0].id }), createDocument(orgId, appId, { categoryIds: [categoryTrending.id], desc: '', fields: [{foo: 'bar'}], publishedAt: new Date('03-13-2017 11:41 UTC').toISOString(), status: 'published', tags: ['wall', 'street'], title: 'Man Humps Fearless Girl Statue On Wall Street, Reminding Us We Need Feminism', slug: 'man-humps-fearless-girl', userId: users[0].id }), createDocument(orgId, appId, { categoryIds: [categoryHumor.id], desc: '', fields: [{foo: 'bar'}], publishedAt: new Date('03-13-2017 10:19 UTC').toISOString(), status: 'published', tags: ['twitter', 'stupid'], title: 'Twitter Users Reminisce On The Stupid Things We Used To Do And Everyone Can Relate', slug: 'twitter-users', userId: users[3].id }), createDocument(orgId, appId, { categoryIds: [categoryTrending.id], desc: '', fields: [{foo: 'bar'}], publishedAt: new Date('03-13-2017 10:03 UTC').toISOString(), status: 'published', tags: ['trump', 'facist'], title: 'Woman Confronts Sean Spicer While Shopping, Calls Trump Fascist On Video', slug: 'woman-confronts', userId: users[1].id }), createDocument(orgId, appId, { categoryIds: [categoryTrending.id, categoryAnimals.id], desc: '', fields: [{foo: 'bar'}], publishedAt: new Date('03-13-2017 09:19 UTC').toISOString(), status: 'published', tags: ['homemade', 'hats'], title: 'Meet ToadBro, The Toad That Wears The Coolest Homemade Hats Youve Ever Seen', slug: 'meet-toadbro', userId: users[1].id }), createDocument(orgId, appId, { categoryIds: [categoryTrending.id, categoryHumor.id, categoryNews.id], desc: '', fields: [{foo: 'bar'}], publishedAt: new Date('03-12-2017 12:31 UTC').toISOString(), status: 'published', tags: ['headlines', 'weekly'], title: '18 Absurd Headlines That Should Not Have Happened This Week', slug: '18-absurd', userId: users[2].id }), createDocument(orgId, appId, { categoryIds: [categoryAnimals.id], desc: '', fields: [{foo: 'bar'}], publishedAt: new Date('03-10-2017 12:51 UTC').toISOString(), status: 'published', tags: ['headlines', 'weekly'], title: 'These Images Of Nature Will Make You Rethink The World Around You', slug: 'these-images-of', userId: users[2].id }), createDocument(orgId, appId, { categoryIds: [categoryTrending.id], desc: '', fields: [{foo: 'bar'}], publishedAt: new Date('03-10-2017 12:44 UTC').toISOString(), status: 'published', tags: ['trump', 'sex'], title: 'You Can Now Listen To The Trumps Sex-Filled Interview From The 90s Online', slug: 'you-can-now-listen', userId: users[3].id }), createDocument(orgId, appId, { categoryIds: [categoryVideos.id, categoryTrending.id], desc: '', fields: [{foo: 'bar'}], publishedAt: new Date('03-10-2017 10:31 UTC').toISOString(), status: 'published', tags: ['winds', 'weather'], title: 'High Winds Literally Blew This Little Girl Away As She Opened Her Front Door', slug: 'high-winds-literally', userId: users[0].id }), createDocument(orgId, appId, { categoryIds: [categoryFood.id], desc: '', fields: [{foo: 'bar'}], publishedAt: new Date('03-09-2017 13:21 UTC').toISOString(), status: 'published', tags: ['millennials', 'mcdonalds'], title: 'Bad News For Fast Food Giant: Millennials Are Not Lovin McDonalds', slug: 'bad-news-for', userId: users[4].id }), ]) const channelHomeRes = await server .get(`/api/${process.env.API_VERSION}/channels/slug/home/resources`) .set('organizationid', orgId) .set('applicationid', appId) const channelHome = new Map(channelHomeRes.body.pkg.resources) let documents = [] const documentIds = [] const trendingSection = channelHome.get('trending') const humorSection = channelHome.get('humor') const videosSection = channelHome.get('videos') const latestSection = channelHome.get('latest') expect(trendingSection.length).to.equal(3) expect(humorSection.length).to.equal(4) expect(videosSection.length).to.equal(2) expect(latestSection.length).to.equal(5) const infScrollPage2Res = await server .get(`/api/${process.env.API_VERSION}/channels/slug/home/resources/latest?page=2&limit=5`) .set('organizationid', orgId) .set('applicationid', appId) const infScrollPage2 = new Map(infScrollPage2Res.body.pkg.resources) const page2 = infScrollPage2.get('latest') expect(page2.length).to.equal(5) const infScrollPage3Res = await server .get(`/api/${process.env.API_VERSION}/channels/slug/home/resources/latest?page=3&limit=5`) .set('organizationid', orgId) .set('applicationid', appId) const infScrollPage3 = new Map(infScrollPage3Res.body.pkg.resources) const page3 = infScrollPage3.get('latest') expect(page3.length).to.equal(5) documents = documents.concat(trendingSection, humorSection, videosSection, latestSection, page2, page3) for(let i = 0, l = documents.length; i < l; i++) { const document = documents[i] documentIds.push(document.id) } const duplicateIndexes = getDuplicateIndexes(documentIds) const numDuplicates = duplicateIndexes.length if(numDuplicates) { console.error('duplicate indexes', duplicateIndexes) console.error(documentIds) } expect(numDuplicates).to.equal(0) // Page 1 expect(trendingSection[0].permalink.indexOf('/trending')).to.equal(0) expect(trendingSection[0].title).to.equal('Snoop Dogg Points Gun At Donald Trump Clown In His New Music Video') expect(trendingSection[1].permalink.indexOf('/trending')).to.equal(0) expect(trendingSection[1].title).to.equal('The BBC Dad Whose Interview Was Interrupted By His Kids Finally Spoke About It') expect(trendingSection[2].permalink.indexOf('/trending')).to.equal(0) expect(trendingSection[2].title).to.equal('This Moms Tribute To Her Ex Sends An Important Message About Coparenting') expect(humorSection[0].permalink.indexOf('/trending')).to.equal(0) expect(humorSection[0].title).to.equal('Obamas White House Photographer Just Threw Shade At Trumps Administration') expect(humorSection[1].permalink.indexOf('/trending')).to.equal(0) expect(humorSection[1].title).to.equal('Joe Biden Revealed His Favorite Obama-Biden Bromance Meme And Its A Classic') expect(humorSection[2].permalink.indexOf('/humor')).to.equal(0) expect(humorSection[2].title).to.equal('Twitter Users Reminisce On The Stupid Things We Used To Do And Everyone Can Relate') expect(humorSection[3].permalink.indexOf('/trending')).to.equal(0) expect(humorSection[3].title).to.equal('18 Absurd Headlines That Should Not Have Happened This Week') expect(videosSection[0].permalink.indexOf('/trending')).to.equal(0) expect(videosSection[0].title).to.equal('You Can Now Watch The Breaking Bad Movie Online And Its Brilliant') expect(videosSection[1].permalink.indexOf('/videos')).to.equal(0) expect(videosSection[1].title).to.equal('High Winds Literally Blew This Little Girl Away As She Opened Her Front Door') expect(latestSection[0].permalink.indexOf('/news')).to.equal(0) expect(latestSection[0].title).to.equal('Rachel Maddow Leaked Donald Trumps Tax Returns And It Was Fairly Anti-Climatic') expect(latestSection[1].permalink.indexOf('/entertainment')).to.equal(0) expect(latestSection[1].title).to.equal('Alert: Official Game of Thrones Spin-Off Series Is A Serious Possibility') expect(latestSection[2].permalink.indexOf('/trending')).to.equal(0) expect(latestSection[2].title).to.equal('Female Jogger Fights Off Rapist And Locks Him In Bathroom After His Brutal Attack') expect(latestSection[3].permalink.indexOf('/trending')).to.equal(0) expect(latestSection[3].title).to.equal('This Grandma Partied With College Kids On Spring Break And Were In Love') expect(latestSection[4].permalink.indexOf('/trending')).to.equal(0) expect(latestSection[4].title).to.equal('This Guys Texting Prank Is A Must-Try If Youre A Star Wars Fan') // Page 2 expect(page2[0].permalink.indexOf('/trending')).to.equal(0) expect(page2[0].title).to.equal('Will Smith Took A Selfie While Bungee Jumping And Is Basically Uncle Phils Twin') expect(page2[1].permalink.indexOf('/trending')).to.equal(0) expect(page2[1].title).to.equal('Why Was The Jacuzzi In Steve Bannons Florida Home Allegedly Covered In Acid?') expect(page2[2].permalink.indexOf('/trending')).to.equal(0) expect(page2[2].title).to.equal('22 Reactions To Blizzard Stella Thatll Make You Forgot How Cold It Is Outside') expect(page2[3].permalink.indexOf('/trending')).to.equal(0) expect(page2[3].title).to.equal('This Moms List Of Toilet Rules To Try And Get Some Peace Is Way Too Relatable') expect(page2[4].permalink.indexOf('/trending')).to.equal(0) expect(page2[4].title).to.equal('Male And Female Coworkers Swapped Names For A Week To Prove Workplace Sexism') // Page 3 expect(page3[0].permalink.indexOf('/relationships')).to.equal(0) expect(page3[0].title).to.equal('This Is What The Ideal Body Type For Men And Women Looks Like') expect(page3[1].permalink.indexOf('/trending')).to.equal(0) expect(page3[1].title).to.equal('Its Official: Ed Sheeran Will Appear In Game of Thrones Season 7') expect(page3[2].permalink.indexOf('/trending')).to.equal(0) expect(page3[2].title).to.equal('The Hell Challenge Is Getting Teens In Serious Trouble With Their Parents') expect(page3[3].permalink.indexOf('/trending')).to.equal(0) expect(page3[3].title).to.equal('Kellyanne Conway Suggests Microwaves Are Capable Of Spying On Us') expect(page3[4].permalink.indexOf('/trending')).to.equal(0) expect(page3[4].title).to.equal('Texas Politician Proposes Law That Fines Men For Masturbation') }) })