This repository has been archived by the owner on Mar 3, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added integration stub for profile 0
- Loading branch information
Showing
8 changed files
with
409 additions
and
61 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
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,71 @@ | ||
|
||
// mock the ddp connector: | ||
|
||
import {DDPClient} from "../ddpConnector" | ||
import * as _ from "underscore" | ||
|
||
|
||
|
||
const ddp:any = jest.genMockFromModule('ddp'); | ||
|
||
|
||
let connectionPossible = true; | ||
|
||
ddp.prototype.__setConnectionPossible = function(possible:boolean) { | ||
connectionPossible = possible; | ||
} | ||
|
||
ddp.prototype.connect = function(cb:any) { | ||
|
||
|
||
|
||
if (connectionPossible) { | ||
// return true | ||
this.emit('connected'); | ||
_.defer(() => { | ||
this.connected = true; | ||
cb(); | ||
}) | ||
|
||
|
||
|
||
} else { | ||
_.defer(() => { | ||
|
||
this.socket.emit('socket-close', 'mock: timeout'); | ||
}); | ||
|
||
} | ||
} | ||
|
||
|
||
|
||
module.exports = ddp; | ||
|
||
|
||
/* | ||
// This is a custom function that our tests can use during setup to specify | ||
// what the files on the "mock" filesystem should look like when any of the | ||
// `fs` APIs are used. | ||
let mockFiles = Object.create(null); | ||
function __setMockFiles(newMockFiles) { | ||
mockFiles = Object.create(null); | ||
for (const file in newMockFiles) { | ||
const dir = path.dirname(file); | ||
if (!mockFiles[dir]) { | ||
mockFiles[dir] = []; | ||
} | ||
mockFiles[dir].push(path.basename(file)); | ||
} | ||
} | ||
// A custom version of `readdirSync` that reads from the special mocked out | ||
// file list set via __setMockFiles | ||
function readdirSync(directoryPath) { | ||
return mockFiles[directoryPath] || []; | ||
} | ||
fs.__setMockFiles = __setMockFiles; | ||
fs.readdirSync = readdirSync; | ||
module.exports = fs; | ||
*/ |
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,35 @@ | ||
|
||
|
||
|
||
import {DDPConnector} from "../ddpConnector" | ||
|
||
jest.mock('ddp'); | ||
|
||
|
||
beforeEach(() => { | ||
// Set up some mocked out file info before each test | ||
//require('ddp').__setMockFiles(MOCK_FILE_INFO); | ||
}); | ||
|
||
|
||
test('Test DDPConnector', async () => { | ||
|
||
var ddpConnector = new DDPConnector({ | ||
host: '127.0.0.1', | ||
port: 3000 | ||
}); | ||
|
||
|
||
expect(ddpConnector).toBeInstanceOf(DDPConnector); | ||
|
||
|
||
|
||
await ddpConnector.connect(); | ||
|
||
|
||
|
||
expect(ddpConnector.connected).toBe(true); | ||
|
||
return 1; | ||
}) | ||
|
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
This file was deleted.
Oops, something went wrong.
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
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
Oops, something went wrong.