Skip to content

Commit

Permalink
refactor unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
=paolo.chiabrera committed May 8, 2017
1 parent 26b575b commit 4c78b0e
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions test/modules/scrapeSourceById.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ describe('scrapeSourceById', function () {
});

const cb = this.spy(err => {
expect(getSourceById).to.have.been.calledOnce;
expect(ensureFolderPath).to.have.been.calledOnce;
expect(onProgress).to.have.been.called;
expect(getSourceById).to.be.calledOnce;
expect(ensureFolderPath).to.be.calledOnce;
expect(onProgress).to.be.called;
expect(err).to.eql(fakeError);
done();
});
Expand All @@ -63,9 +63,9 @@ describe('scrapeSourceById', function () {
});

const cb = this.spy((err, results) => {
expect(getSourceById).to.have.been.calledOnce;
expect(ensureFolderPath).to.have.been.calledOnce;
expect(onProgress).to.have.been.called;
expect(getSourceById).to.be.calledOnce;
expect(ensureFolderPath).to.be.calledOnce;
expect(onProgress).to.be.called;
expect(err).to.be.null;
expect(results).to.eql({
pageNumber: 0,
Expand All @@ -85,7 +85,7 @@ describe('scrapeSourceById', function () {
const threshold = 0.1;
const onProgress = this.spy();

this.stub(main, 'scrapePage', (args, done) => {
const scrapePageStub = this.stub(main, 'scrapePage', (args, done) => {
if (args.pageNumber === 0) {
done(null, {
threshold: 1
Expand All @@ -99,9 +99,10 @@ describe('scrapeSourceById', function () {
});

const cb = this.spy((err, results) => {
expect(getSourceById).to.have.been.calledOnce;
expect(ensureFolderPath).to.have.been.calledOnce;
expect(onProgress).to.have.been.calledTwice;
expect(getSourceById).to.be.calledOnce;
expect(ensureFolderPath).to.be.calledOnce;
expect(onProgress).to.be.calledTwice;
expect(scrapePageStub).to.be.calledTwice;
expect(err).to.be.null;
expect(results).to.eql({
pageNumber: 1,
Expand Down

0 comments on commit 4c78b0e

Please sign in to comment.