From f14917b31d5caa8dabe5814f011cc04421c6052d Mon Sep 17 00:00:00 2001 From: JacobOscarGunnarsson <44238293+JacobOscarGunnarsson@users.noreply.github.com> Date: Fri, 24 Feb 2023 10:13:06 +0100 Subject: [PATCH] Ensure that Realm enums are accessible (#5484) --- integration-tests/tests/src/tests.ts | 1 + integration-tests/tests/src/tests/enums.ts | 87 ++++++++++++++++++++++ 2 files changed, 88 insertions(+) create mode 100644 integration-tests/tests/src/tests/enums.ts diff --git a/integration-tests/tests/src/tests.ts b/integration-tests/tests/src/tests.ts index 1dda5eb52c..c97a7d5cde 100644 --- a/integration-tests/tests/src/tests.ts +++ b/integration-tests/tests/src/tests.ts @@ -40,6 +40,7 @@ import "./tests/objects"; import "./tests/queries"; import "./tests/realm-constructor"; import "./tests/schema"; +import "./tests/enums"; import "./tests/serialization"; import "./tests/set"; import "./tests/list"; diff --git a/integration-tests/tests/src/tests/enums.ts b/integration-tests/tests/src/tests/enums.ts new file mode 100644 index 0000000000..4e12065070 --- /dev/null +++ b/integration-tests/tests/src/tests/enums.ts @@ -0,0 +1,87 @@ +//////////////////////////////////////////////////////////////////////////// +// +// Copyright 2023 Realm Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//////////////////////////////////////////////////////////////////////////// + +import { expect } from "chai"; +import { + ConnectionState, + NumericLogLevel, + OpenRealmBehaviorType, + OpenRealmTimeOutBehavior, + SessionStopPolicy, +} from "realm"; + +describe("Enums", function () { + describe("ConnectionState", function () { + it("is accessible", function () { + expect(ConnectionState).deep.equals({ + Disconnected: "disconnected", + Connecting: "connecting", + Connected: "connected", + }); + }); + }); + describe("SessionStopPolicy", function () { + it("is accessible", function () { + expect(SessionStopPolicy).deep.equals({ + AfterUpload: "after-upload", + Immediately: "immediately", + Never: "never", + }); + }); + }); + describe("OpenRealmBehaviorType", function () { + it("is accessible", function () { + expect(OpenRealmBehaviorType).deep.equals({ + DownloadBeforeOpen: "downloadBeforeOpen", + OpenImmediately: "openImmediately", + }); + }); + }); + describe("OpenRealmTimeOutBehavior", function () { + it("is accessible", function () { + expect(OpenRealmTimeOutBehavior).deep.equals({ + OpenLocalRealm: "openLocalRealm", + ThrowException: "throwException", + }); + }); + }); + describe("NumericLogLevel", function () { + it("is accessible", function () { + expect(NumericLogLevel).deep.equals({ + "0": "All", + "1": "Trace", + "2": "Debug", + "3": "Detail", + "4": "Info", + "5": "Warn", + "6": "Error", + "7": "Fatal", + "8": "Off", + All: 0, + Trace: 1, + Debug: 2, + Detail: 3, + Info: 4, + Warn: 5, + Error: 6, + Fatal: 7, + Off: 8, + }); + }); + }); +});