Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure that Realm enums are accessible #5484

Merged
merged 6 commits into from
Feb 24, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions integration-tests/tests/src/tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
92 changes: 92 additions & 0 deletions integration-tests/tests/src/tests/enums.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
////////////////////////////////////////////////////////////////////////////
//
// 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).to.be.an("object");
expect(ConnectionState).to.deep.equals({
Disconnected: "disconnected",
Connecting: "connecting",
Connected: "connected",
});
});
});
describe("SessionStopPolicy", function () {
it("is accessible", function () {
expect(SessionStopPolicy).to.be.an("object");
expect(SessionStopPolicy).to.deep.equal({
AfterUpload: "after-upload",
Immediately: "immediately",
Never: "never",
});
});
});
describe("OpenRealmBehaviorType", function () {
it("is accessible", function () {
expect(OpenRealmBehaviorType).to.be.an("object");
expect(OpenRealmBehaviorType).to.deep.equal({
DownloadBeforeOpen: "downloadBeforeOpen",
OpenImmediately: "openImmediately",
});
});
});
describe("OpenRealmTimeOutBehavior", function () {
it("is accessible", function () {
expect(OpenRealmTimeOutBehavior).to.be.an("object");
expect(OpenRealmTimeOutBehavior).to.deep.equal({
OpenLocalRealm: "openLocalRealm",
ThrowException: "throwException",
});
});
});
describe("NumericLogLevel", function () {
it("is accessible", function () {
expect(NumericLogLevel).to.be.an("object");
expect(NumericLogLevel).to.deep.equals({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This first line shouldn't be needed when you're doing deep equals to an object. Btw, does it still work with having the sat the end of equal? (I'd vote for where you're using to.deep.equal()) :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, most of these "to" "be" "equal/equals" are just meaningless syntactic sugar that does not change its behavior. So it could be expect(NumericLogLevel).deep.equals or expect(NumericLogLevel).to.deep.equal. I like both, I have generally been using the former for less use of this chaining but the latter does read nicer.

"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,
});
});
});
});