|
| 1 | +/* Copyright (c) 2014-2017 Richard Rodger and other contributors, MIT License */ |
| 2 | + |
| 3 | +var Code = require('code') |
| 4 | +var Lab = require('lab') |
| 5 | +var Seneca = require('seneca') |
| 6 | + |
| 7 | +var lab = exports.lab = Lab.script() |
| 8 | +var describe = lab.describe |
| 9 | +var it = lab.it |
| 10 | +var expect = Code.expect |
| 11 | + |
| 12 | + |
| 13 | +describe('npm', function () { |
| 14 | + |
| 15 | + it('query', {timeout: 8888}, function (done) { |
| 16 | + var seen = {} |
| 17 | + |
| 18 | + Seneca() |
| 19 | + |
| 20 | + // Place Seneca into test mode. Errors will be passed to done callback, |
| 21 | + // so no need to handle them in callbacks. |
| 22 | + .test(done) |
| 23 | + |
| 24 | + // Uncomment if you want to see detailed logs |
| 25 | + //.test(done, 'print') |
| 26 | + |
| 27 | + .use('entity') |
| 28 | + |
| 29 | + // Load the github plugin |
| 30 | + .use('..') |
| 31 | + |
| 32 | + .sub('role:entity', function (msg) { |
| 33 | + seen[msg.cmd] = 1 + (seen[msg.cmd]||0) |
| 34 | + }) |
| 35 | + |
| 36 | + .gate() |
| 37 | + |
| 38 | + .act('role:github,cmd:query,owner:senecajs,repo:seneca,name:seneca', function (ignore, out) { |
| 39 | + expect(out.owner).equal('senecajs') |
| 40 | + expect(out.repo).equal('seneca') |
| 41 | + expect(out.stars).above(0) |
| 42 | + expect(seen).to.equal({ load: 1, save: 1 }) |
| 43 | + }) |
| 44 | + |
| 45 | + .act('role:github,cmd:get,name:seneca', function (ignore, out) { |
| 46 | + expect(out.owner).equal('senecajs') |
| 47 | + expect(out.repo).equal('seneca') |
| 48 | + expect(out.stars).above(0) |
| 49 | + |
| 50 | + expect(seen).to.equal({ load: 2, save: 1 }) |
| 51 | + }) |
| 52 | + |
| 53 | + |
| 54 | + .act('role:github,cmd:get,name:seneca', function (ignore, out) { |
| 55 | + expect(out.owner).equal('senecajs') |
| 56 | + expect(out.repo).equal('seneca') |
| 57 | + expect(out.stars).above(0) |
| 58 | + |
| 59 | + expect(seen).to.equal({ load: 3, save: 1 }) |
| 60 | + }) |
| 61 | + |
| 62 | + .ready(done) |
| 63 | + }) |
| 64 | +}) |
| 65 | + |
| 66 | + |
0 commit comments