Skip to content
This repository has been archived by the owner on Apr 3, 2024. It is now read-only.

Commit

Permalink
Fill in unimplemented tests (#199)
Browse files Browse the repository at this point in the history
PR-URL: #199
  • Loading branch information
matthewloring authored Dec 19, 2016
1 parent c580792 commit 4dc2aa0
Showing 1 changed file with 115 additions and 14 deletions.
129 changes: 115 additions & 14 deletions test/standalone/test-debuglet.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ describe(__filename, function(){
.reply(404);

debuglet.once('initError', function(err) {
assert(err);
assert.ok(err);
scope.done();
done();
});
Expand Down Expand Up @@ -111,7 +111,7 @@ describe(__filename, function(){
});

debuglet.once('registered', function(id) {
assert(id === DEBUGGEE_ID);
assert.equal(id, DEBUGGEE_ID);
scope.done();
done();
});
Expand All @@ -137,15 +137,26 @@ describe(__filename, function(){
});

debuglet.once('registered', function(id) {
assert(id === DEBUGGEE_ID);
assert.equal(id, DEBUGGEE_ID);
scope.done();
done();
});

debuglet.start();
});

it('should error if a package.json doesn\'t exist');
it('should error if a package.json doesn\'t exist', function(done) {
var config = extend({}, defaultConfig,
{projectId: 'fake-project', workingDirectory: __dirname});
debuglet = new Debuglet(fakeDebug, config, logger);

debuglet.once('initError', function(err) {
assert(err);
done();
});

debuglet.start();
});

it('should register successfully otherwise', function(done) {
var config = extend({}, defaultConfig, {projectId: 'fake-project'});
Expand All @@ -160,7 +171,7 @@ describe(__filename, function(){
});

debuglet.once('registered', function(id) {
assert(id === DEBUGGEE_ID);
assert.equal(id, DEBUGGEE_ID);
scope.done();
done();
});
Expand All @@ -186,7 +197,7 @@ describe(__filename, function(){
});

debuglet.once('registered', function(id) {
assert(id === DEBUGGEE_ID);
assert.equal(id, DEBUGGEE_ID);
scope.done();
process.chdir('../..');
done();
Expand All @@ -195,11 +206,103 @@ describe(__filename, function(){
debuglet.start();
});

it('should de-activate when the server responds with isDisabled');
it('should de-activate when the server responds with isDisabled', function(done) {
this.timeout(4000);
var config = extend({}, defaultConfig, {projectId: 'fake-project'});
debuglet = new Debuglet(fakeDebug, config, logger);

var scope = nock(API)
.post(REGISTER_PATH)
.reply(200, {
debuggee: {
id: DEBUGGEE_ID,
isDisabled: true
}
})
.post(REGISTER_PATH)
.reply(200, {
debuggee: {
id: DEBUGGEE_ID
}
});

debuglet.once('registered', function(id) {
assert.equal(id, DEBUGGEE_ID);
setImmediate(function() {
assert.ok(debuglet.fetcherActive_);
scope.done();
done();
});
});

setTimeout(function() {
assert.ok(!debuglet.fetcherActive_);
}, 1000);

debuglet.start();
});

it('should re-register when registration expires', function(done) {
var config = extend({}, defaultConfig, {projectId: 'fake-project'});
debuglet = new Debuglet(fakeDebug, config, logger);

var scope = nock(API)
.post(REGISTER_PATH)
.reply(200, {
debuggee: {
id: DEBUGGEE_ID
}
})
.get(BPS_PATH + '?success_on_timeout=true')
.reply(404)
.post(REGISTER_PATH)
.reply(200, {
debuggee: {
id: DEBUGGEE_ID
}
});

debuglet.once('registered', function(id) {
assert.equal(id, DEBUGGEE_ID);
debuglet.once('registered', function(id) {
assert.equal(id, DEBUGGEE_ID);
scope.done();
done();
});
});

debuglet.start();
});

it('should fetch and add breakpoints', function(done) {
this.timeout(2000);

it('should re-register when registration expires');
var config = extend({}, defaultConfig, {projectId: 'fake-project'});
debuglet = new Debuglet(fakeDebug, config, logger);

it('should fetch breakpoints');
var scope = nock(API)
.post(REGISTER_PATH)
.reply(200, {
debuggee: {
id: DEBUGGEE_ID
}
})
.get(BPS_PATH + '?success_on_timeout=true')
.reply(200, {
breakpoints: [bp]
});

debuglet.once('registered', function reg(id) {
assert.equal(id, DEBUGGEE_ID);
setTimeout(function() {
assert.deepEqual(debuglet.activeBreakpointMap_.test, bp);
scope.done();
done();
}, 1000);
});

debuglet.start();
});

it('should re-fetch breakpoints on error', function(done) {
this.timeout(6000);
Expand Down Expand Up @@ -238,7 +341,7 @@ describe(__filename, function(){
.reply(200);

debuglet.once('registered', function reg(id) {
assert(id === DEBUGGEE_ID);
assert.equal(id, DEBUGGEE_ID);
setTimeout(function() {
assert.deepEqual(debuglet.activeBreakpointMap_.test, bp);
assert(!debuglet.activeBreakpointMap_.testLog);
Expand All @@ -250,8 +353,6 @@ describe(__filename, function(){
debuglet.start();
});

it('should add a breakpoint');

it('should expire stale breakpoints', function(done) {
var config = extend({}, defaultConfig, {
projectId: 'fake-project',
Expand All @@ -278,7 +379,7 @@ describe(__filename, function(){

debuglet = new Debuglet(fakeDebug, config, logger);
debuglet.once('registered', function(id) {
assert(id === DEBUGGEE_ID);
assert.equal(id, DEBUGGEE_ID);
setTimeout(function() {
assert.deepEqual(debuglet.activeBreakpointMap_.test, bp);
setTimeout(function() {
Expand Down Expand Up @@ -330,7 +431,7 @@ describe(__filename, function(){

debuglet = new Debuglet(fakeDebug, config, logger);
debuglet.once('registered', function(id) {
assert(id === DEBUGGEE_ID);
assert.equal(id, DEBUGGEE_ID);
setTimeout(function() {
assert.deepEqual(debuglet.activeBreakpointMap_.test, bp);
setTimeout(function() {
Expand Down

0 comments on commit 4dc2aa0

Please sign in to comment.