Skip to content

Commit

Permalink
chore: run prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
tiwarishubham635 committed Dec 5, 2024
1 parent 7fe5675 commit 07d1651
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 27 deletions.
52 changes: 26 additions & 26 deletions spec/unit/auth_strategy/TokenAuthStrategy.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import TokenAuthStrategy from "../../../src/auth_strategy/TokenAuthStrategy";
import ApiTokenManager from "../../../src/http/bearer_token/ApiTokenManager";
import {jest} from "@jest/globals";
import { jest } from "@jest/globals";
import axios from "axios";
import twilio from "../../../src";

Expand Down Expand Up @@ -30,17 +30,17 @@ describe("NoAuthStrategy constructor", function () {
const initialHttpProxyValue = process.env.HTTP_PROXY;

beforeEach(() => {
createSpy = jest.spyOn(axios, 'create');
createSpy = jest.spyOn(axios, "create");
createSpy.mockReturnValue(
createMockAxios(
Promise.resolve({
status: 200,
data: {
"access_token": "accessTokenValue",
"token_type": "Bearer"
},
}),
),
createMockAxios(
Promise.resolve({
status: 200,
data: {
access_token: "accessTokenValue",
token_type: "Bearer",
},
})
)
);
});

Expand All @@ -61,10 +61,9 @@ describe("NoAuthStrategy constructor", function () {
it("Should check token expiry", function () {
const accountSid = "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
const keySid = "SKb5aed9ca12bf5890f37930e63cad6d38";
const token =
new twilio.jwt.AccessToken(accountSid, keySid, "secret", {
identity: "[email protected]",
});
const token = new twilio.jwt.AccessToken(accountSid, keySid, "secret", {
identity: "[email protected]",
});
expect(tokenAuthStrategy.isTokenExpired(token.toJwt())).toBe(false);
});

Expand Down Expand Up @@ -96,16 +95,16 @@ describe("NoAuthStrategy error response", function () {
const initialHttpProxyValue = process.env.HTTP_PROXY;

beforeEach(() => {
createSpy = jest.spyOn(axios, 'create');
createSpy = jest.spyOn(axios, "create");
createSpy.mockReturnValue(
createMockAxios(
Promise.resolve({
status: 403,
data: {
"message": "Invalid Credentials",
},
}),
),
createMockAxios(
Promise.resolve({
status: 403,
data: {
message: "Invalid Credentials",
},
})
)
);
});

Expand All @@ -120,7 +119,8 @@ describe("NoAuthStrategy error response", function () {
});

it("Should return error", async function () {
await expect(tokenAuthStrategy.getAuthString()).rejects.toThrow("Failed to fetch access token: Invalid Credentials");
await expect(tokenAuthStrategy.getAuthString()).rejects.toThrow(
"Failed to fetch access token: Invalid Credentials"
);
});

});
4 changes: 3 additions & 1 deletion src/http/bearer_token/ApiTokenManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ export default class ApiTokenManager implements TokenManager {
return token.accessToken;
})
.catch((error) => {
throw new Error(`Error Status Code: ${error.status}\nFailed to fetch access token: ${error.message}`);
throw new Error(
`Error Status Code: ${error.status}\nFailed to fetch access token: ${error.message}`
);
});
}
}

0 comments on commit 07d1651

Please sign in to comment.