UNPKG

@parity/light.js

Version:

A high-level reactive JS library optimized for light clients

46 lines (45 loc) 1.73 kB
"use strict"; // Copyright 2015-2019 Parity Technologies (UK) Ltd. // This file is part of Parity. // // SPDX-License-Identifier: MIT Object.defineProperty(exports, "__esModule", { value: true }); var Api = require("@parity/api"); var operators_1 = require("rxjs/operators"); var frequency_1 = require("./frequency"); var isObservable_1 = require("../utils/isObservable"); var mockApi_1 = require("../utils/testHelpers/mockApi"); var api_1 = require("@parity/light.js/src/api"); jest.mock('@parity/api'); Api.mockImplementation(function () { return mockApi_1.resolveApi('4'); }); /** * Helper function to make basic tests for frequency$ observables. * * @ignore */ var testFrequency = function (name, frequency$, resolveWith) { if (resolveWith === void 0) { resolveWith = 'foo'; } return describe(name + " frequency", function () { beforeEach(function () { api_1.setApi(mockApi_1.resolveApi(resolveWith)); }); it('should be an Observable', function () { expect(isObservable_1.default(frequency$())).toBe(true); }); it('should be subscribable', function () { expect(function () { return frequency$().subscribe(); }).not.toThrow(); }); it('should return values', function (done) { frequency$() .pipe(operators_1.take(1)) .subscribe(function (data) { expect(data).not.toBeNull(); done(); }); }); }); }; Object.keys(frequency_1.default).forEach(function (key) { return testFrequency(key, frequency_1.default[key], key.includes('Account') ? ['foo'] : 4 // Give string[] for accounts pubsub, or number elsewhere ); });