All files / lib client.ts

76% Statements 19/25
92.3% Branches 12/13
76.92% Functions 10/13
85% Lines 17/20

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28  2x 6x 6x 2x   8x 6x     2x 2x 2x     6x 6x     6x 6x 1x   6x 1x      
import { Connection, UserInfo } from 'jsforce';
import { JsForceConfigOptions } from './common/interfaces';

export class Client {
    conn!: Connection;
    initialization!: Promise<any>;
 
    constructor(config: JsForceConfigOptions) {
        this.conn = new Connection(config.options);
 
        this.initialization = this.init(config.username, config.password, config.security_token);
    }
 
    async init(username:string, password: string, security_token?:string, callback?: (err: Error, result: UserInfo) => {}) {
        if (security_token) {
            password += security_token;
        }
        await this.conn.login(username,password).catch(
            (err) => {
                return err;
            }
        );
    }
 
    async logout(revoke?:boolean, callback?: (err:Error, res: undefined) => {}){
        return await this.conn.logout();
    }
}