Ai
3 Star 1 Fork 0

Gitee 极速下载/Guess-js

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
此仓库是为了提升国内下载速度的镜像仓库,每日同步一次。 原始仓库: https://github.com/guess-js/guess
克隆/下载
gaClientTests.js 1.24 KB
一键复制 编辑 原始数据 按行查看 历史
Katie 提交于 2018-05-07 09:43 +08:00 . Add guess-static-sites
// 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')
})
})
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/mirrors/Guess-js.git
git@gitee.com:mirrors/Guess-js.git
mirrors
Guess-js
Guess-js
master

搜索帮助