-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8d1e35e
commit a41ae22
Showing
1 changed file
with
68 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import { expect, describe, test, beforeAll, afterAll } from 'vitest' | ||
import { readFileSync } from 'fs' | ||
import { | ||
initPlainClient, | ||
getTestOrganization, | ||
getDefaultSpace, | ||
timeoutToCalmRateLimiting, | ||
} from '../helpers' | ||
import type { | ||
Organization, | ||
AppDefinition, | ||
AppUpload, | ||
Space, | ||
Environment, | ||
PlainClientAPI, | ||
} from '../../lib/contentful-management' | ||
|
||
describe('AppBundle api', { sequential: true }, () => { | ||
let organization: Organization | ||
let appDefinition: AppDefinition | ||
let appUpload: AppUpload | ||
let space: Space | ||
let env: Environment | ||
let client: PlainClientAPI | ||
|
||
beforeAll(async () => { | ||
space = await getDefaultSpace() | ||
env = await space.getEnvironment('master') | ||
organization = await getTestOrganization() | ||
|
||
client = initPlainClient({ | ||
spaceId: space.sys.id, | ||
environmentId: 'master', | ||
}) | ||
|
||
appDefinition = await organization.createAppDefinition({ | ||
name: 'Test AppBundle', | ||
}) | ||
|
||
appUpload = await organization.createAppUpload(readFileSync(`${__dirname}/fixtures/build.zip`)) | ||
}) | ||
|
||
afterAll(async () => { | ||
const { items: appDefinitions } = await organization.getAppDefinitions() | ||
const { items: appInstallations } = await env.getAppInstallations() | ||
|
||
for (const appInstallation of appInstallations) { | ||
await appInstallation.delete() | ||
} | ||
for (const appDefinition of appDefinitions) { | ||
await appDefinition.delete() | ||
} | ||
|
||
if (appUpload) { | ||
await appUpload.delete() | ||
} | ||
await timeoutToCalmRateLimiting() | ||
}) | ||
|
||
test('getManyFunction', async () => { | ||
const funcs = await client.function.getMany({ | ||
organizationId: organization.sys.id, | ||
appDefinitionId: appDefinition.sys.id, | ||
}) | ||
expect(funcs).toBeDefined() | ||
expect(funcs.items).toBeInstanceOf(Array) | ||
}) | ||
}) |