Skip to content

Commit

Permalink
feat: add a test case for isAlphaUin func
Browse files Browse the repository at this point in the history
  • Loading branch information
caijw committed Oct 15, 2018
1 parent 4aff9c8 commit cc8e46d
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
2 changes: 2 additions & 0 deletions bin/proxy/websocket.js
Original file line number Diff line number Diff line change
Expand Up @@ -277,12 +277,14 @@ exports.start_listen = function() {
const ws = new WSServer({
server: global.TSW_HTTP_SERVER
});
global.TSW_WS_SERVER = ws;
bind_listen(ws);

if (global.TSW_HTTPS_SERVER) {
const wss = new WSServer({
server: global.TSW_HTTPS_SERVER
});
global.TSW_WSS_SERVER = ws;
bind_listen(wss);
}
};
Expand Down
43 changes: 43 additions & 0 deletions test/bin/tsw/util/alpha.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,49 @@ describe('test tsw/util/alpha', () => {
});
});

describe('#isAlphaUin', () => {

it('#check a num not skymode', () => {
config.skyMode = false;
const uid = 1;
expect(alpha.isAlpha(uid)).to.be.equal(undefined);
});

it('#update', () => {
alpha.update({ 1: true });
const uid = 1;
expect(alpha.isAlpha(uid)).to.be.equal(true);
});

it('#get From logger', () => {
alpha.update({ 1: true });

const stub = sinon.stub(logger, 'getKey').callsFake(() => {
return 1;
});

expect(alpha.isAlpha()).to.be.equal(true);
stub.restore();
});

it('#get From getUin', () => {
alpha.update({ 1: true });
context.window = {
request: {}
};
config.extendMod = {
getUid: (req) => {
return 1;
}
};

expect(alpha.isAlpha()).to.be.equal(true);
delete context.window;
delete config.extendMod;
});
});


describe('#getUin', () => {
it('#without req', () => {
expect(alpha.getUin()).to.be.equal(undefined);
Expand Down

0 comments on commit cc8e46d

Please sign in to comment.