-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: create a copy for CODAP v3 (#356)
- Loading branch information
Showing
4 changed files
with
59 additions
and
15 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
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
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,33 @@ | ||
import { CloudContent, cloudContentFactory } from "./provider-interface" | ||
|
||
describe("ProviderInterface", () => { | ||
|
||
it("wraps/unwraps client content with `metadata` property (e.g. CODAP v2)", () => { | ||
const docContent = { metadata: {} } | ||
expect(CloudContent.isClientContent(docContent)).toBe(true) | ||
const wrappedContent = cloudContentFactory.createEnvelopedCloudContent(docContent) | ||
const unwrappedContent = wrappedContent.getClientContent() | ||
expect(unwrappedContent).toEqual(docContent) | ||
expect(CloudContent.isClientContent(unwrappedContent)).toBe(true) | ||
}) | ||
|
||
it("can't wrap/unwrap client content with `content` property (e.g. CODAP v3) without isClientContent", () => { | ||
const docContent = { content: { isContent: true } } | ||
const wrappedContent = cloudContentFactory.createEnvelopedCloudContent(docContent) | ||
const unwrappedContentFail = wrappedContent.getClientContent() | ||
// without the isClientContent override, unwrapping fails | ||
expect(unwrappedContentFail).not.toEqual(docContent) | ||
}) | ||
|
||
it("wraps/unwraps client content with `content` property (e.g. CODAP v3) with isClientContent", () => { | ||
const docContent = { content: { isContent: true } } | ||
// with the isClientContent override, unwrapping succeeds | ||
CloudContent.isClientContent = (inContent: any) => !!inContent?.content?.isContent | ||
expect(CloudContent.isClientContent(docContent)).toBe(true) | ||
const wrappedContent = cloudContentFactory.createEnvelopedCloudContent(docContent) | ||
const unwrappedContent = wrappedContent.getClientContent() | ||
expect(CloudContent.isClientContent(unwrappedContent)).toBe(true) | ||
expect(unwrappedContent).toEqual(docContent) | ||
}) | ||
|
||
}) |
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