55import assert from "assert" ;
66
77import { Context } from "../../../src/core/context" ;
8- import Dispatcher from "../../../src/core/dispatcher" ;
9- import Glean from "../../../src/core/glean/async" ;
10- import MetricsDatabase from "../../../src/core/metrics/database/async" ;
11- import EventsDatabase from "../../../src/core/metrics/events_database/async" ;
12- import PingsDatabase from "../../../src/core/pings/database/async" ;
8+ import Glean from "../../../src/core/glean" ;
9+ import MetricsDatabase from "../../../src/core/metrics/database" ;
10+ import EventsDatabase from "../../../src/core/metrics/events_database" ;
11+ import PingsDatabase from "../../../src/core/pings/database" ;
1312import { testResetGlean } from "../../../src/core/testing" ;
1413import { testUninitializeGlean } from "../../../src/core/testing/utils" ;
1514import { sanitizeApplicationId } from "../../../src/core/utils" ;
1615
1716describe ( "Context" , function ( ) {
1817 const testAppId = `gleanjs.test.${ this . title } ` ;
1918
20- beforeEach ( async function ( ) {
21- await testResetGlean ( testAppId ) ;
19+ beforeEach ( function ( ) {
20+ testResetGlean ( testAppId ) ;
2221 } ) ;
2322
24- it ( "dispatcher contains the expected value" , async function ( ) {
25- assert . notStrictEqual ( Context . dispatcher , undefined ) ;
26- assert . ok ( Context . dispatcher instanceof Dispatcher ) ;
27-
28- await testUninitializeGlean ( ) ;
29- // Dispatcher should be available when Glean is uninitialized too.
30- assert . notStrictEqual ( Context . dispatcher , undefined ) ;
31- assert . ok ( ( Context . dispatcher as unknown ) instanceof Dispatcher ) ;
32- } ) ;
33-
34- it ( "uploadEnabled contains the expected value" , async function ( ) {
23+ it ( "uploadEnabled contains the expected value" , function ( ) {
3524 assert . strictEqual ( Context . uploadEnabled , true ) ;
3625
3726 Glean . setUploadEnabled ( false ) ;
38- await Context . dispatcher . testBlockOnQueue ( ) ;
3927 assert . strictEqual ( Context . uploadEnabled , false ) ;
4028 } ) ;
4129
42- it ( "appId contains the expected value" , async function ( ) {
30+ it ( "appId contains the expected value" , function ( ) {
4331 assert . strictEqual ( Context . applicationId , sanitizeApplicationId ( testAppId ) ) ;
4432
45- await testResetGlean ( "new-id" ) ;
33+ testResetGlean ( "new-id" ) ;
4634 assert . strictEqual ( Context . applicationId , sanitizeApplicationId ( "new-id" ) ) ;
4735 } ) ;
4836
49- it ( "initialized contains the expected value" , async function ( ) {
37+ it ( "initialized contains the expected value" , function ( ) {
5038 assert . strictEqual ( Context . initialized , true ) ;
5139
52- await testUninitializeGlean ( ) ;
40+ testUninitializeGlean ( ) ;
5341 assert . strictEqual ( Context . initialized , false ) ;
5442 } ) ;
5543
@@ -63,20 +51,4 @@ describe("Context", function() {
6351 assert . notStrictEqual ( Context . pingsDatabase , undefined ) ;
6452 assert . ok ( Context . pingsDatabase instanceof PingsDatabase ) ;
6553 } ) ;
66-
67- it ( "the dispatcher is always available" , function ( ) {
68- const originalDispatcher = Context . dispatcher ;
69- assert . notStrictEqual ( originalDispatcher , null ) ;
70-
71- Context . testUninitialize ( ) ;
72-
73- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
74- // @ts -ignore
75- assert . strictEqual ( Context . _instance ?. _dispatcher , undefined ) ;
76-
77- // Trying to access the dispatcher will instantiate a new one.
78- const newDispatcher = Context . instance ;
79- assert . notStrictEqual ( newDispatcher , null ) ;
80- assert . notStrictEqual ( newDispatcher , originalDispatcher ) ;
81- } ) ;
8254} ) ;
0 commit comments