代码拉取完成,页面将自动刷新
// To run tests: $ npm run generate-predictions-tests
// mongod should be running
const chai = require('chai')
const expect = chai.expect
const mongoose = require('mongoose')
const config = require('../config')
const parser = require('../src/parser')
const fakeResponse = require('./fixtures/gaResponse.json')
const Prediction = require('../src/models/prediction')
describe('#SaveReports', function () {
beforeEach(async () => {
await mongoose.connect(config.db.mongoURL)
await mongoose.connection.db.dropDatabase()
})
afterEach(async () => {
mongoose.disconnect()
})
it('should save API response as predictions', async () => {
await parser.saveReports(fakeResponse['testData'])
const predictions = await Prediction.find({})
expect(await predictions.length).to.equal(4)
const prediction1 = predictions.find((p) => { return p.pagePath === '/page/turtles/' })
expect(prediction1.nextPageCertainty).to.equal(0.1875)
expect(prediction1.nextPagePath).to.equal('/turtles/turtle1.html')
const prediction2 = predictions.find((p) => { return p.pagePath === '/page/dogs/' })
expect(prediction2.nextPageCertainty).to.equal(0.14285714285714285)
expect(prediction2.nextPagePath).to.equal('/dogs/dog_photo2.html')
})
})
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。