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

Fill in unimplemented tests #199

Merged
merged 1 commit into from
Dec 19, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

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 comment was marked as spam.

This comment was marked as spam.

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) {

This comment was marked as spam.

This comment was marked as spam.

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