Remove Explorer.databaseAccount (#717)

Co-authored-by: Steve Faulkner <southpolesteve@gmail.com>
This commit is contained in:
Hardikkumar Nai
2021-05-06 03:24:50 +05:30
committed by GitHub
parent fdd12b41c4
commit 8c05ac740c
67 changed files with 1077 additions and 1046 deletions

View File

@@ -1,4 +1,3 @@
import ko from "knockout";
import { HttpHeaders, HttpStatusCodes } from "../Common/Constants";
import { DatabaseAccount } from "../Contracts/DataModels";
import { updateUserContext, userContext } from "../UserContext";
@@ -35,7 +34,7 @@ const samplePinnedRepos: IPinnedRepo[] = [
];
describe("Pinned repos", () => {
const junoClient = new JunoClient(ko.observable<DatabaseAccount>(sampleDatabaseAccount));
const junoClient = new JunoClient();
beforeEach(() => {
window.fetch = jest.fn().mockImplementation(() => {
@@ -72,7 +71,7 @@ describe("Pinned repos", () => {
});
describe("GitHub", () => {
const junoClient = new JunoClient(ko.observable<DatabaseAccount>(sampleDatabaseAccount));
const junoClient = new JunoClient();
afterEach(() => {
jest.resetAllMocks();
@@ -131,11 +130,16 @@ describe("GitHub", () => {
});
describe("Gallery", () => {
const junoClient = new JunoClient(ko.observable<DatabaseAccount>(sampleDatabaseAccount));
const junoClient = new JunoClient();
const originalSubscriptionId = userContext.subscriptionId;
beforeAll(() => {
updateUserContext({ subscriptionId: sampleSubscriptionId });
updateUserContext({
databaseAccount: {
name: "name",
} as DatabaseAccount,
subscriptionId: sampleSubscriptionId,
});
});
afterEach(() => {
@@ -202,7 +206,6 @@ describe("Gallery", () => {
status: HttpStatusCodes.OK,
json: () => undefined as any,
});
const response = await junoClient.increaseNotebookViews(id);
expect(response.status).toBe(HttpStatusCodes.OK);

View File

@@ -70,7 +70,7 @@ export interface IPublishNotebookRequest {
export class JunoClient {
private cachedPinnedRepos: ko.Observable<IPinnedRepo[]>;
constructor(private databaseAccount?: ko.Observable<DataModels.DatabaseAccount>) {
constructor() {
this.cachedPinnedRepos = ko.observable<IPinnedRepo[]>([]);
}
@@ -500,7 +500,7 @@ export class JunoClient {
}
private getAccount(): string {
return this.databaseAccount().name;
return userContext?.databaseAccount?.name;
}
private getSubscriptionId(): string {