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

Commit

Permalink
Tests for #30
Browse files Browse the repository at this point in the history
  • Loading branch information
roblourens committed Oct 14, 2016
1 parent 6ad4ce8 commit 019e4cf
Showing 1 changed file with 39 additions and 23 deletions.
62 changes: 39 additions & 23 deletions test/adapter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {DebugClient} from 'vscode-debugadapter-testsupport';
const LoggingReporter = require('./loggingReporter');

suite('Node Debug Adapter', () => {
const THREAD_ID = 1;
const NIGHTLY_NAME = os.platform() === 'win32' ? 'node-nightly.cmd' : 'node-nightly';
const DEBUG_ADAPTER = './out/src/nodeDebug.js';

Expand Down Expand Up @@ -583,57 +584,72 @@ suite('Node Debug Adapter', () => {

test('returns global vars', () => {
return testCompletions('')
.then(completions => {
assert(inCompletionsList(completions, 'global'));
});
.then(completions => assert(inCompletionsList(completions, 'global')));
});

test('returns local vars', () => {
return testCompletions('')
.then(completions => {
assert(inCompletionsList(completions, 'num', 'str', 'arr', 'obj'));
});
.then(completions => assert(inCompletionsList(completions, 'num', 'str', 'arr', 'obj')));
});

test('returns methods', () => {
return testCompletions('arr.')
.then(completions => {
assert(inCompletionsList(completions, 'push', 'indexOf'));
});
.then(completions => assert(inCompletionsList(completions, 'push', 'indexOf')));
});

test('returns object properties', () => {
return testCompletions('obj.')
.then(completions => {
assert(inCompletionsList(completions, 'a', 'b'));
});
.then(completions => assert(inCompletionsList(completions, 'a', 'b')));
});

test('multiple dots', () => {
return testCompletions('obj.b.')
.then(completions => {
assert(inCompletionsList(completions, 'startsWith', 'endsWith'));
});
.then(completions => assert(inCompletionsList(completions, 'startsWith', 'endsWith')));
});

test('returns from the correct column', () => {
return testCompletions('obj.b.', /*column=*/6)
.then(completions => {
assert(inCompletionsList(completions, 'a', 'b'));
});
.then(completions => assert(inCompletionsList(completions, 'a', 'b')));
});

test('returns from the correct frameId', () => {
return testCompletions('obj', undefined, /*frameId=*/1)
.then(completions => {
assert(!inCompletionsList(completions, 'obj'));
});
.then(completions => assert(!inCompletionsList(completions, 'obj')));
});

test('returns properties of string literals', () => {
return testCompletions('"".')
.then(completions => {
assert(inCompletionsList(completions, 'startsWith'));
.then(completions => assert(inCompletionsList(completions, 'startsWith')));
});
});

suite('stepping', () => {
const PROGRAM = Path.join(DATA_ROOT, 'program.js');

function start(): Promise<void> {
return dc.hitBreakpoint({ program: PROGRAM }, { path: PROGRAM, line: 1 });
}

test.only('returns the same frameIDs between steps', () => {
let firstFrameIDs: number[];
return start()
.then(() => {
return Promise.all([
dc.nextRequest({threadId: THREAD_ID }),
dc.waitForEvent('stopped')]);
})
.then(() => dc.stackTraceRequest({ threadId: THREAD_ID }))
.then(frameResponse => {
firstFrameIDs = frameResponse.body.stackFrames.map(frame => frame.id);

return Promise.all([
dc.nextRequest({threadId: THREAD_ID }),
dc.waitForEvent('stopped')]);
})
.then(() => dc.stackTraceRequest({ threadId: THREAD_ID }))
.then(frameResponse => {
const secondFrameIDs = frameResponse.body.stackFrames.map(frame => frame.id);
assert.deepEqual(firstFrameIDs, secondFrameIDs);
});
});
});
Expand Down

0 comments on commit 019e4cf

Please sign in to comment.