-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add logger * Add option to enable logging * Add debug logs for fetch * Add debug logs for remaining fetch helpers * Add debug logs to frontToken * Add debug logs to utils * Add logging to AntiCSRF * Add debug logs to recipeImplementation * Add debug logs to axios * Update build files * Update changelog * Update version * Review fixes * Fix typo in logs * Update build files * Add test for logger * Update size limit * Move unreleased changes to latest release in Changelog
- Loading branch information
1 parent
7d32ca1
commit bac45ad
Showing
24 changed files
with
547 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* Copyright (c) 2024, VRAI Labs and/or its affiliates. All rights reserved. | ||
* | ||
* This software is licensed under the Apache License, Version 2.0 (the | ||
* "License") as published by the Apache Software Foundation. | ||
* | ||
* 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. | ||
*/ | ||
const tough = require("tough-cookie"); | ||
import SuperTokens from "supertokens-react-native"; | ||
import { disableLogging } from "supertokens-react-native/lib/build/logger"; | ||
// jest does not call setupFiles properly with the new react-native init, so doing it this way instead | ||
import "./setup"; | ||
|
||
process.env.TEST_MODE = "testing"; | ||
|
||
describe("Logger test", () => { | ||
const consoleSpy = jest.spyOn(console, "log"); | ||
|
||
beforeEach(() => { | ||
disableLogging(); | ||
let nodeFetch = require("node-fetch").default; | ||
const fetch = require("fetch-cookie")(nodeFetch, new tough.CookieJar()); | ||
global.fetch = fetch; | ||
}); | ||
|
||
afterEach(() => { | ||
jest.clearAllMocks(); | ||
}); | ||
|
||
it("should log to console when debug logging is enabled", async () => { | ||
SuperTokens.init({ | ||
apiDomain: "http://localhost:3000", | ||
enableDebugLogs: true | ||
}); | ||
|
||
expect(consoleSpy).toHaveBeenCalledWith(expect.stringContaining("init: called")); | ||
}); | ||
|
||
it("should not log to console when debug logging is disabled", async () => { | ||
SuperTokens.init({ | ||
apiDomain: "http://localhost:3000", | ||
enableDebugLogs: false | ||
}); | ||
|
||
expect(consoleSpy).not.toHaveBeenCalledWith(expect.stringContaining("init: called")); | ||
}); | ||
|
||
it("should not log to console when no argument is passed for enableDebugLogs", async () => { | ||
SuperTokens.init({ | ||
apiDomain: "http://localhost:3000" | ||
}); | ||
|
||
expect(consoleSpy).not.toHaveBeenCalledWith(expect.stringContaining("init: called")); | ||
}); | ||
}); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.