@sanity/workbench 0.1.0-alpha.8 → 0.1.0-alpha.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +7 -3
- package/src/_internal/render.test.ts +0 -105
- package/src/core/__tests__/__fixtures__.ts +0 -245
- package/src/core/applications/application-list.test.ts +0 -222
- package/src/core/applications/local-application.test.ts +0 -93
- package/src/core/canvases.test.ts +0 -38
- package/src/core/log/index.test.ts +0 -133
- package/src/core/media-libraries.test.ts +0 -38
- package/src/core/organizations.test.ts +0 -134
- package/src/core/projects.test.ts +0 -248
- package/src/core/shared/urls.test.ts +0 -182
- package/src/core/user-applications/core-app.test.ts +0 -236
- package/src/core/user-applications/studios/schemas.test.ts +0 -113
- package/src/core/user-applications/studios/studio.test.ts +0 -997
- package/src/core/user-applications/user-application.test.ts +0 -125
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
// eslint-disable-next-line no-restricted-imports
|
|
2
|
-
import type { ApplicationResource as ProtocolApplicationResource } from "@sanity/message-protocol";
|
|
3
|
-
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
4
|
-
|
|
5
|
-
import { APPLICATION_DATA } from "../__tests__/__fixtures__";
|
|
6
|
-
import type { CoreAppUserApplication } from "./core-app";
|
|
7
|
-
import { UserApplication as AbstractUserApplication } from "./user-application";
|
|
8
|
-
|
|
9
|
-
class UserApplication extends AbstractUserApplication<
|
|
10
|
-
CoreAppUserApplication,
|
|
11
|
-
"coreApp",
|
|
12
|
-
ProtocolApplicationResource
|
|
13
|
-
> {
|
|
14
|
-
constructor(application: CoreAppUserApplication) {
|
|
15
|
-
super(application, "coreApp");
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
get title(): string {
|
|
19
|
-
return this.application.title;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
get subtitle() {
|
|
23
|
-
return undefined;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
get href(): string {
|
|
27
|
-
return "";
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
toProtocolResource() {
|
|
31
|
-
return {
|
|
32
|
-
...this.application,
|
|
33
|
-
type: "application",
|
|
34
|
-
url: this.url.toString(),
|
|
35
|
-
} as const;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
const setup = (overrides?: Partial<CoreAppUserApplication>) =>
|
|
40
|
-
new UserApplication({
|
|
41
|
-
...APPLICATION_DATA,
|
|
42
|
-
...overrides,
|
|
43
|
-
} as CoreAppUserApplication);
|
|
44
|
-
|
|
45
|
-
describe("UserApplication", () => {
|
|
46
|
-
afterEach(() => {
|
|
47
|
-
vi.unstubAllEnvs();
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
it("should generate a url for an internal application", () => {
|
|
51
|
-
vi.stubEnv("VITE_SANITY_ENV", "staging");
|
|
52
|
-
vi.stubEnv("VITE_SANITY_DOMAIN", "sanity.work");
|
|
53
|
-
const application = setup();
|
|
54
|
-
expect(application.url).toBeInstanceOf(URL);
|
|
55
|
-
expect(application.url.toString()).toMatchInlineSnapshot(
|
|
56
|
-
`"https://x7apsmr6fxvc.studio.sanity.work/"`,
|
|
57
|
-
);
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
it("should respect the SANITY_ENV", () => {
|
|
61
|
-
vi.stubEnv("VITE_SANITY_ENV", "production");
|
|
62
|
-
const application = setup();
|
|
63
|
-
expect(application.url).toBeInstanceOf(URL);
|
|
64
|
-
expect(application.url.toString()).toMatchInlineSnapshot(
|
|
65
|
-
`"https://x7apsmr6fxvc.sanity.studio/"`,
|
|
66
|
-
);
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
it("should generate a url for an external application", () => {
|
|
70
|
-
const application = setup({
|
|
71
|
-
...APPLICATION_DATA,
|
|
72
|
-
activeDeployment: null,
|
|
73
|
-
appHost: "https://my-app.com",
|
|
74
|
-
urlType: "external",
|
|
75
|
-
});
|
|
76
|
-
expect(application.url).toBeInstanceOf(URL);
|
|
77
|
-
expect(application.url.toString()).toMatchInlineSnapshot(
|
|
78
|
-
`"https://my-app.com/"`,
|
|
79
|
-
);
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
describe("initials", () => {
|
|
83
|
-
const initials = (title: string) => setup({ title }).initials;
|
|
84
|
-
|
|
85
|
-
it("should return the initials of a name", () => {
|
|
86
|
-
expect(initials("John Doe")).toBe("JD");
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
it("should return the initials of a name with extra spaces", () => {
|
|
90
|
-
expect(initials(" John Doe ")).toBe("JD");
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
it("should return intials even if the name is only one word", () => {
|
|
94
|
-
expect(initials("John")).toBe("J");
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
it("should return a maximum of two initials", () => {
|
|
98
|
-
expect(initials("John Doe Smith")).toBe("JS");
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
it("should handle empty string", () => {
|
|
102
|
-
expect(initials("")).toBe("");
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
it("should handle symbols-only string", () => {
|
|
106
|
-
expect(initials("@#$%")).toBe("");
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
it("should handle a single character", () => {
|
|
110
|
-
expect(initials("A")).toBe("A");
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
it("should handle strings containing numbers", () => {
|
|
114
|
-
expect(initials("0xHoldings")).toBe("0X");
|
|
115
|
-
expect(initials("7-Eleven")).toBe("7E");
|
|
116
|
-
expect(initials("Forever 21")).toBe("F2");
|
|
117
|
-
expect(initials("Motel 6")).toBe("M6");
|
|
118
|
-
expect(initials("2 Wire")).toBe("2W");
|
|
119
|
-
|
|
120
|
-
expect(initials("010101")).toBe("01");
|
|
121
|
-
expect(initials("W4t")).toBe("W4");
|
|
122
|
-
expect(initials("H4xx0r")).toBe("H4");
|
|
123
|
-
});
|
|
124
|
-
});
|
|
125
|
-
});
|