Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/src/packages/sync/table/test/client-test.ts
Views: 687
/*1* This file is part of CoCalc: Copyright © 2020 Sagemath, Inc.2* License: MS-RSL – see LICENSE.md for details3*/45/*6Minimal client class that we use for testing.7*/89import { EventEmitter } from "events";10import { bind_methods, keys } from "@cocalc/util/misc";1112export class ClientTest extends EventEmitter {13private initial_get_query: any[];14public set_queries: any[] = [];1516constructor(initial_get_query) {17super();1819this.initial_get_query = initial_get_query;20bind_methods(this, ["query", "dbg", "query_cancel"]);21}2223public is_project(): boolean {24return false;25}2627public is_browser(): boolean {28return true;29}3031public is_compute_server(): boolean {32return false;33}3435public is_connected(): boolean {36return true;37}3839public is_signed_in(): boolean {40return true;41}4243public dbg(_: string): Function {44return console.log;45}4647public query(opts): void {48if (opts.options && opts.options.length === 1 && opts.options[0].set) {49// set query50this.set_queries.push(opts);51opts.cb();52} else {53// get query -- returns predetermined result54const table = keys(opts.query)[0];55opts.cb(undefined, { query: { [table]: this.initial_get_query } });56}57}5859public query_cancel(_): void {}6061public alert_message(_): void {}6263public server_time(): Date {64return new Date();65}6667public touch_project(_): void {}6869is_deleted = (_path: string, _project_id: string) => {70// not implemented yet in general71return undefined;72};73}747576