Skip to content
This repository has been archived by the owner on May 7, 2022. It is now read-only.

Commit

Permalink
update: 添加测试case
Browse files Browse the repository at this point in the history
  • Loading branch information
xuexb committed Apr 13, 2016
1 parent acfaefb commit 56033a1
Showing 1 changed file with 85 additions and 1 deletion.
86 changes: 85 additions & 1 deletion test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,16 @@ import 'should';

import Check from '../src/index';
import types from './types';

import log from '../src/log';


describe('check-version', () => {
let write = log._write;

afterEach(() => {
log._write = write;
});

it('new', () => {
Check.should.be.type('function');
});
Expand Down Expand Up @@ -79,4 +85,82 @@ describe('check-version', () => {
// done();
// });
// });

it('_sendLog promise', () => {
Check._sendLog().should.be.Promise();
});

// 没有更新
it('_sendLog({}, {})', done => {
let num = 0;
log._write = () => {
num += 1;
};
return Check._sendLog({}, {
update: [],
all: []
}).then(data => {
data.update.length.should.be.equal(0);
data.all.length.should.be.equal(0);
num.should.be.equal(2);
}).then(done);
});

it('_sendLog update:1', done => {
let num = 0;
log._write = () => {
num += 1;
};

Check._sendLog({}, {
update: [
{
prevVersion: 1,
name: 'test1',
version: 2
}
],
all: [
{
prevVersion: null,
name: 'test1',
version: 0
},
{
prevVersion: 1,
name: 'test1',
version: 2
}
]
}).then(function (data) {
data.update.length.should.be.equal(1);
data.all.length.should.be.equal(2);
(num === 4).should.be.true();
done();
});
});

it('_sendLog update:0', done => {
let num = 0;
log._write = () => {
num += 1;
};

Check._sendLog({}, {
update: [
],
all: [
{
prevVersion: 1,
name: 'test1',
version: 1
}
]
}).then(function (data) {
data.update.length.should.be.equal(0);
data.all.length.should.be.equal(1);
(num === 3).should.be.true();
done();
});
});
});

0 comments on commit 56033a1

Please sign in to comment.