Skip to content

Commit

Permalink
Try more awaits
Browse files Browse the repository at this point in the history
  • Loading branch information
ComLock committed Oct 29, 2024
1 parent 9f6c54b commit e1e993f
Showing 1 changed file with 40 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,74 +6,66 @@ declare namespace globalThis {
let app: App
let log: Log
let __: DoubleUnderscore
// let _devMode: boolean
let _assetUrl: string
// let _resources: Record<string, {
// bytes?: string
// exists?: boolean
// }>
}

await Deno.test("handles mode: inline", () => {
globalThis._assetUrl = '/admin/site/inline/default/draft/_/asset/com.enonic.app.react4xp:0000018a9816e580';
import('../../../../../main/resources/lib/enonic/react4xp/dependencies/initServiceUrlRoot.ts').then(({initServiceUrlRoot}) => {
assertEquals(initServiceUrlRoot(), '/admin/site/inline/default/draft/_/service/com.enonic.app.react4xp/');
});
function mockAssetUrl(mode: string) {
return `/admin/site/${mode}/default/draft/_/asset/com.enonic.app.react4xp:0000018a9816e580`;
}

await Deno.test("handles mode: inline", async () => {
globalThis._assetUrl = mockAssetUrl('inline');
const {initServiceUrlRoot} = await import('../../../../../main/resources/lib/enonic/react4xp/dependencies/initServiceUrlRoot.ts');
assertEquals(initServiceUrlRoot(), '/admin/site/inline/default/draft/_/service/com.enonic.app.react4xp/');
});

await Deno.test("handles mode: inline using type: absolute", () => {
globalThis._assetUrl = '/admin/site/inline/default/draft/_/asset/com.enonic.app.react4xp:0000018a9816e580';
import('../../../../../main/resources/lib/enonic/react4xp/dependencies/initServiceUrlRoot.ts').then(({initServiceUrlRoot}) => {
assertEquals(initServiceUrlRoot({
urlType: 'absolute'
}), 'http://localhost:8080/admin/site/inline/default/draft/_/service/com.enonic.app.react4xp/');
});
await Deno.test("handles mode: inline using type: absolute", async () => {
globalThis._assetUrl = mockAssetUrl('inline');
const {initServiceUrlRoot} = await import('../../../../../main/resources/lib/enonic/react4xp/dependencies/initServiceUrlRoot.ts');
assertEquals(initServiceUrlRoot({
urlType: 'absolute'
}), 'http://localhost:8080/admin/site/inline/default/draft/_/service/com.enonic.app.react4xp/');
});

await Deno.test("handles mode: edit", () => {
globalThis._assetUrl = '/admin/site/edit/default/draft/_/asset/com.enonic.app.react4xp:0000018a9816e580';
import('../../../../../main/resources/lib/enonic/react4xp/dependencies/initServiceUrlRoot.ts').then(({initServiceUrlRoot}) => {
assertEquals(initServiceUrlRoot(), '/admin/site/preview/default/draft/_/service/com.enonic.app.react4xp/');
});
await Deno.test("handles mode: edit", async () => {
globalThis._assetUrl = mockAssetUrl('edit');
const {initServiceUrlRoot} = await import('../../../../../main/resources/lib/enonic/react4xp/dependencies/initServiceUrlRoot.ts');
assertEquals(initServiceUrlRoot(), '/admin/site/preview/default/draft/_/service/com.enonic.app.react4xp/');
});

await Deno.test("handles mode: edit type: absolute", () => {
globalThis._assetUrl = '/admin/site/edit/default/draft/_/asset/com.enonic.app.react4xp:0000018a9816e580';
import('../../../../../main/resources/lib/enonic/react4xp/dependencies/initServiceUrlRoot.ts').then(({initServiceUrlRoot}) => {
assertEquals(initServiceUrlRoot({
urlType: 'absolute'
}), 'http://localhost:8080/admin/site/preview/default/draft/_/service/com.enonic.app.react4xp/');
});
await Deno.test("handles mode: edit type: absolute", async () => {
globalThis._assetUrl = mockAssetUrl('edit');
const {initServiceUrlRoot} = await import('../../../../../main/resources/lib/enonic/react4xp/dependencies/initServiceUrlRoot.ts');
assertEquals(initServiceUrlRoot({
urlType: 'absolute'
}), 'http://localhost:8080/admin/site/preview/default/draft/_/service/com.enonic.app.react4xp/');
});

await Deno.test("handles mode: preview", () => {
globalThis._assetUrl = '/admin/site/preview/default/draft/_/asset/com.enonic.app.react4xp:0000018a9816e580';
await Deno.test("handles mode: preview", async () => {
globalThis._assetUrl = mockAssetUrl('preview');
import('../../../../../main/resources/lib/enonic/react4xp/dependencies/initServiceUrlRoot.ts').then(({initServiceUrlRoot}) => {
assertEquals(initServiceUrlRoot(), '/admin/site/preview/default/draft/_/service/com.enonic.app.react4xp/');
});
});

await Deno.test("handles mode: preview type: absolute", () => {
globalThis._assetUrl = '/admin/site/preview/default/draft/_/asset/com.enonic.app.react4xp:0000018a9816e580';
import('../../../../../main/resources/lib/enonic/react4xp/dependencies/initServiceUrlRoot.ts').then(({initServiceUrlRoot}) => {
assertEquals(initServiceUrlRoot({
urlType: 'absolute'
}), 'http://localhost:8080/admin/site/preview/default/draft/_/service/com.enonic.app.react4xp/');
});
await Deno.test("handles mode: preview type: absolute", async () => {
globalThis._assetUrl = mockAssetUrl('preview');
const {initServiceUrlRoot} = await import('../../../../../main/resources/lib/enonic/react4xp/dependencies/initServiceUrlRoot.ts');
assertEquals(initServiceUrlRoot({
urlType: 'absolute'
}), 'http://localhost:8080/admin/site/preview/default/draft/_/service/com.enonic.app.react4xp/');
});

await Deno.test("handles mode: live", () => {
await Deno.test("handles mode: live", async () => {
globalThis._assetUrl = '/site/default/master/_/asset/com.enonic.app.react4xp:0000018a9816e580';
import('../../../../../main/resources/lib/enonic/react4xp/dependencies/initServiceUrlRoot.ts').then(({initServiceUrlRoot}) => {
assertEquals(initServiceUrlRoot(), '/site/default/master/_/service/com.enonic.app.react4xp/');
});
const {initServiceUrlRoot} = await import('../../../../../main/resources/lib/enonic/react4xp/dependencies/initServiceUrlRoot.ts');
assertEquals(initServiceUrlRoot(), '/site/default/master/_/service/com.enonic.app.react4xp/');
});

await Deno.test("handles mode: live type: absolute", () => {
await Deno.test("handles mode: live type: absolute", async () => {
globalThis._assetUrl = '/site/default/master/_/asset/com.enonic.app.react4xp:0000018a9816e580';
import('../../../../../main/resources/lib/enonic/react4xp/dependencies/initServiceUrlRoot.ts').then(({initServiceUrlRoot}) => {
assertEquals(initServiceUrlRoot({
urlType: 'absolute'
}), 'http://localhost:8080/site/default/master/_/service/com.enonic.app.react4xp/');
});
const {initServiceUrlRoot} = await import('../../../../../main/resources/lib/enonic/react4xp/dependencies/initServiceUrlRoot.ts');
assertEquals(initServiceUrlRoot({
urlType: 'absolute'
}), 'http://localhost:8080/site/default/master/_/service/com.enonic.app.react4xp/');
});

0 comments on commit e1e993f

Please sign in to comment.