Apply prettier formatting
This commit is contained in:
parent
1cac306093
commit
526645c791
1576 changed files with 65385 additions and 62478 deletions
|
@ -17,14 +17,14 @@ limitations under the License.
|
|||
import { mocked } from "jest-mock";
|
||||
import fetchMock from "fetch-mock-jest";
|
||||
|
||||
import ScalarAuthClient from '../src/ScalarAuthClient';
|
||||
import { stubClient } from './test-utils';
|
||||
import ScalarAuthClient from "../src/ScalarAuthClient";
|
||||
import { stubClient } from "./test-utils";
|
||||
import SdkConfig from "../src/SdkConfig";
|
||||
import { WidgetType } from "../src/widgets/WidgetType";
|
||||
|
||||
describe('ScalarAuthClient', function() {
|
||||
const apiUrl = 'https://test.com/api';
|
||||
const uiUrl = 'https:/test.com/app';
|
||||
describe("ScalarAuthClient", function () {
|
||||
const apiUrl = "https://test.com/api";
|
||||
const uiUrl = "https:/test.com/app";
|
||||
const tokenObject = {
|
||||
access_token: "token",
|
||||
token_type: "Bearer",
|
||||
|
@ -33,12 +33,12 @@ describe('ScalarAuthClient', function() {
|
|||
};
|
||||
|
||||
let client;
|
||||
beforeEach(function() {
|
||||
beforeEach(function () {
|
||||
jest.clearAllMocks();
|
||||
client = stubClient();
|
||||
});
|
||||
|
||||
it('should request a new token if the old one fails', async function() {
|
||||
it("should request a new token if the old one fails", async function () {
|
||||
const sac = new ScalarAuthClient(apiUrl + 0, uiUrl);
|
||||
|
||||
fetchMock.get("https://test.com/api0/account?scalar_token=brokentoken&v=1.1", {
|
||||
|
@ -60,7 +60,7 @@ describe('ScalarAuthClient', function() {
|
|||
expect(sac.exchangeForScalarToken).toBeCalledWith(tokenObject);
|
||||
expect(sac.hasCredentials).toBeTruthy();
|
||||
// @ts-ignore private property
|
||||
expect(sac.scalarToken).toEqual('wokentoken');
|
||||
expect(sac.scalarToken).toEqual("wokentoken");
|
||||
});
|
||||
|
||||
describe("exchangeForScalarToken", () => {
|
||||
|
@ -191,22 +191,29 @@ describe('ScalarAuthClient', function() {
|
|||
});
|
||||
|
||||
it("should send state=disable to API /widgets/set_assets_state", async () => {
|
||||
fetchMock.get("https://test.com/api8/widgets/set_assets_state?scalar_token=wokentoken1" +
|
||||
"&widget_type=m.custom&widget_id=id1&state=disable", {
|
||||
body: "OK",
|
||||
});
|
||||
fetchMock.get(
|
||||
"https://test.com/api8/widgets/set_assets_state?scalar_token=wokentoken1" +
|
||||
"&widget_type=m.custom&widget_id=id1&state=disable",
|
||||
{
|
||||
body: "OK",
|
||||
},
|
||||
);
|
||||
|
||||
await expect(sac.disableWidgetAssets(WidgetType.CUSTOM, "id1")).resolves.toBeUndefined();
|
||||
});
|
||||
|
||||
it("should throw upon non-20x code", async () => {
|
||||
fetchMock.get("https://test.com/api8/widgets/set_assets_state?scalar_token=wokentoken1" +
|
||||
"&widget_type=m.custom&widget_id=id2&state=disable", {
|
||||
status: 500,
|
||||
});
|
||||
fetchMock.get(
|
||||
"https://test.com/api8/widgets/set_assets_state?scalar_token=wokentoken1" +
|
||||
"&widget_type=m.custom&widget_id=id2&state=disable",
|
||||
{
|
||||
status: 500,
|
||||
},
|
||||
);
|
||||
|
||||
await expect(sac.disableWidgetAssets(WidgetType.CUSTOM, "id2"))
|
||||
.rejects.toThrow("Scalar request failed: 500");
|
||||
await expect(sac.disableWidgetAssets(WidgetType.CUSTOM, "id2")).rejects.toThrow(
|
||||
"Scalar request failed: 500",
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue