-
Notifications
You must be signed in to change notification settings - Fork 30
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
f6a3951
commit 72deaf8
Showing
3 changed files
with
28 additions
and
6 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 |
---|---|---|
|
@@ -3,6 +3,7 @@ import { graphql } from "lightning/uiGraphQLApi"; | |
import AccountRelatedContacts from "c/accountRelatedContacts"; | ||
|
||
const mockGraphQL = require("./data/graphql.json"); | ||
const mockGraphQLEmpty = require("./data/graphql-empty.json"); | ||
|
||
describe("c-account-related-contacts", () => { | ||
afterEach(() => { | ||
|
@@ -35,4 +36,22 @@ describe("c-account-related-contacts", () => { | |
expect(details[0].textContent).toBe("415-555-5555"); | ||
expect(details[1].textContent).toBe("[email protected]"); | ||
}); | ||
|
||
it("should handle an incomplete graphql response", async () => { | ||
// setup | ||
const element = createElement("c-account-related-contacts", { | ||
is: AccountRelatedContacts, | ||
}); | ||
element.recordId = "0011700000pJRRSAA4"; | ||
|
||
document.body.appendChild(element); | ||
|
||
graphql.emit(mockGraphQLEmpty); | ||
// Resolve a promise to wait for a re-render of the new content | ||
await Promise.resolve(); | ||
|
||
// test | ||
const title = element.shadowRoot.querySelector("h3"); | ||
expect(title).toBeNull(); | ||
}); | ||
}); |
5 changes: 5 additions & 0 deletions
5
force-app/main/default/lwc/accountRelatedContacts/__tests__/data/graphql-empty.json
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,5 @@ | ||
{ | ||
"uiapi": { | ||
"query": {} | ||
} | ||
} |
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