forked from jerryscript-project/jerryscript
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Geoff Gustafson <[email protected]> JerryScript-DCO-1.0-Signed-off-by: Geoff Gustafson [email protected]
- Loading branch information
Showing
1 changed file
with
70 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
// Copyright JS Foundation and other contributors, http://js.foundation | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
import { JerryDebugger, DEFAULT_DEBUGGER_HOST, DEFAULT_DEBUGGER_PORT } from '../debugger-client'; | ||
import WebSocket from 'ws'; | ||
|
||
//const mockOn = jest.fn(); | ||
jest.mock('ws', () => { | ||
return jest.fn().mockImplementation(() => { | ||
return {}; | ||
}); | ||
}); | ||
|
||
describe('JerryDebugger constructor', () => { | ||
it ('uses supplied option values', () => { | ||
const jd = new JerryDebugger({ | ||
host: '10.10.10.10', | ||
port: 4096, | ||
verbose: true, | ||
}); | ||
expect(jd.host).toEqual('10.10.10.10'); | ||
expect(jd.port).toEqual(4096); | ||
expect(jd.verbose).toEqual(true); | ||
}); | ||
|
||
it('supplies option defaults when missing', () => { | ||
const jd = new JerryDebugger({}); | ||
expect(jd.host).toEqual(DEFAULT_DEBUGGER_HOST); | ||
expect(jd.port).toEqual(DEFAULT_DEBUGGER_PORT); | ||
expect(jd.verbose).toEqual(false); | ||
}); | ||
}); | ||
|
||
describe('JerryDebugger.connect', () => { | ||
beforeEach(() => { | ||
}); | ||
|
||
it('creates a websocket', () => { | ||
const jd = new JerryDebugger({}); | ||
jd.connect(); | ||
expect(WebSocket).toHaveBeenCalledTimes(1); | ||
}); | ||
|
||
it('returns a resolving promise when already connected', () => { | ||
const jd = new JerryDebugger({}); | ||
jd.connect(); | ||
expect(WebSocket).toHaveBeenCalledTimes(1); | ||
const p2 = jd.connect(); | ||
console.log('here1'); | ||
return expect(p2).resolves.toBe(undefined); | ||
}); | ||
|
||
it('returned promise resolves when socket connects', () => { | ||
const jd = new JerryDebugger({}); | ||
const p = jd.connect(); | ||
console.log('here2'); | ||
expect(p).resolves.toBe(undefined); | ||
}); | ||
}); |