Skip to content

Commit

Permalink
remove console
Browse files Browse the repository at this point in the history
  • Loading branch information
aksonov committed May 29, 2018
1 parent 60ae6a1 commit 300999d
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 43 deletions.
1 change: 0 additions & 1 deletion __tests__/utils/mockTransport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ export default class MockTransport extends XmppTransport {
loginCount = 0

async login(user?: string, password?: string, host?: string) {
console.log('LOGIN', this.loginCount)
this.loginCount += 1
if (this.loginCount !== 2) {
await super.login(user, password, host)
Expand Down
91 changes: 49 additions & 42 deletions __tests__/utils/mockWocky.js
Original file line number Diff line number Diff line change
@@ -1,39 +1,38 @@
// @flow

import {Wocky} from 'wocky-client';
import {simpleActionLogger} from 'mst-middlewares';
import {addMiddleware} from 'mobx-state-tree';
import {observable} from 'mobx';
import {Wocky} from 'wocky-client'
import {simpleActionLogger} from 'mst-middlewares'
import {addMiddleware} from 'mobx-state-tree'
import {observable} from 'mobx'

export class XmppTransport {
provider: any;
fileService: any;
resource: string;
@observable connected: boolean = true;
@observable connecting: boolean = false;
@observable iq: any = {};
@observable rosterItem: any = {};
@observable message: {id: string, message: any};
@observable presence: {status: string, id: string};
@observable username: string;
@observable password: string;
@observable host: string;
@observable geoBot: any;
@observable notification: any;
isGeoSearching: boolean = false;
provider: any
fileService: any
resource: string
@observable connected: boolean = true
@observable connecting: boolean = false
@observable iq: any = {}
@observable rosterItem: any = {}
@observable message: {id: string, message: any}
@observable presence: {status: string, id: string}
@observable username: string
@observable password: string
@observable host: string
@observable geoBot: any
@observable notification: any
isGeoSearching: boolean = false

async login(user?: string, password?: string, host?: string) {
console.log('WOCKY LOGIN');
this.user = user;
this.password = password;
this.host = host;
this.connected = true;
this.user = user
this.password = password
this.host = host
this.connected = true
}

async disconnect() {
// this.provider.disconnectAfterSending()
// await new Promise(resolve => when(() => !this.connected, resolve))
this.connected = false;
this.connected = false
}

async sendIQ(data: any, withoutTo: boolean = false): Promise<any> {}
Expand All @@ -52,7 +51,12 @@ export class XmppTransport {
}
async remove() {}

async loadRelations(userId: string, relation: string = 'following', lastId?: string, max: number = 10) {
async loadRelations(
userId: string,
relation: string = 'following',
lastId?: string,
max: number = 10
) {
// return {list, count: parseInt(stanza.contacts.set.count)}
}

Expand All @@ -61,10 +65,10 @@ export class XmppTransport {
}
async downloadFile(tros: string, name: string, sourceUrl: string) {}
async downloadThumbnail(url: string, tros: string) {
return this.downloadFile(tros, 'thumbnail', url);
return this.downloadFile(tros, 'thumbnail', url)
}
async downloadTROS(tros: string) {
return this.downloadFile(tros, 'main', '');
return this.downloadFile(tros, 'main', '')
}
async requestUpload({file, size, width, height, access}: any) {
// return data.reference_url
Expand Down Expand Up @@ -107,7 +111,7 @@ export class XmppTransport {
// } else {
// throw 'Cannot generate ID'
// }
return '4321';
return '4321'
}
async removeBot(id: string) {}
async loadOwnBots(userId: string, lastId?: string, max: number = 10) {
Expand Down Expand Up @@ -184,34 +188,37 @@ export class XmppTransport {

class FakeFileService {
get tempDir() {
return null;
return null
}
fileExists(filePath: string): Promise<boolean> {
return new Promise((resolve, reject) => {
resolve(true);
});
resolve(true)
})
}
mkdir(folder: string) {
// return mkdir(folder);
}
getImageSize(filename: string): Promise<{width: number, height: number}> {
return new Promise((resolve, reject) => resolve({width: 0, height: 0}));
return new Promise((resolve, reject) => resolve({width: 0, height: 0}))
}
downloadHttpFile(urlString: string, fileName: string, headers: any): Promise<any> {
return new Promise((resolve, reject) => {
resolve();
});
resolve()
})
}
removeFile() {}
}

const transport = new XmppTransport();
const fileService = new FakeFileService();
const logger = console;
const transport = new XmppTransport()
const fileService = new FakeFileService()
const logger = console
export function createWocky(env = {}) {
const wocky = Wocky.create({host: 'testing.dev.tinyrobot.com'}, {analytics: {track: () => {}}, transport, fileService, logger, ...env});
addMiddleware(wocky, simpleActionLogger);
return wocky;
const wocky = Wocky.create(
{host: 'testing.dev.tinyrobot.com'},
{analytics: {track: () => {}}, transport, fileService, logger, ...env}
)
addMiddleware(wocky, simpleActionLogger)
return wocky
}

export default createWocky();
export default createWocky()

0 comments on commit 300999d

Please sign in to comment.