⚝
One Hat Cyber Team
⚝
Your IP:
216.73.217.4
Server IP:
41.128.143.86
Server:
Linux host.raqmix.cloud 6.8.0-1025-azure #30~22.04.1-Ubuntu SMP Wed Mar 12 15:28:20 UTC 2025 x86_64
Server Software:
Apache
PHP Version:
8.3.23
Buat File
|
Buat Folder
Eksekusi
Dir :
~
/
usr
/
share
/
grafana
/
public
/
test
/
matchers
/
View File Name :
toEmitValuesWith.ts
import { matcherHint, printReceived } from 'jest-matcher-utils'; import { Observable, Subscription } from 'rxjs'; import { expectObservable, forceObservableCompletion } from './utils'; function tryExpectations
(received: T[], expectations: (received: T[]) => void): jest.CustomMatcherResult { try { expectations(received); return { pass: true, message: () => `${matcherHint('.not.toEmitValues')} Expected observable to complete with ${printReceived(received)} `, }; } catch (err) { return { pass: false, message: () => 'failed ' + err, }; } } /** * Collect all the values emitted by the observables (also errors) and pass them to the expectations functions after * the observable ended (or emitted error). If Observable does not complete within OBSERVABLE_TEST_TIMEOUT_IN_MS the * test fails. */ export function toEmitValuesWith
( received: Observable
, expectations: (actual: T[]) => void ): Promise
{ const failsChecks = expectObservable(received); if (failsChecks) { return Promise.resolve(failsChecks); } return new Promise((resolve) => { const receivedValues: T[] = []; const subscription = new Subscription(); subscription.add( received.subscribe({ next: (value) => { receivedValues.push(value); }, error: (err) => { receivedValues.push(err); subscription.unsubscribe(); resolve(tryExpectations(receivedValues, expectations)); }, complete: () => { subscription.unsubscribe(); resolve(tryExpectations(receivedValues, expectations)); }, }) ); forceObservableCompletion(subscription, resolve); }); }