Skip to content

Commit

Permalink
Updated jest mock for uiRecordApi (#876)
Browse files Browse the repository at this point in the history
  • Loading branch information
adityanaag3 authored Dec 1, 2023
1 parent 5141812 commit 8d90a90
Show file tree
Hide file tree
Showing 10 changed files with 1,110 additions and 695 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,17 @@ describe('c-contact-info', () => {

// Select elements for validation
const nameEl = element.shadowRoot.querySelector('p');
expect(nameEl.textContent).toBe(mockGetRecord.result.fields.Name.value);
expect(nameEl.textContent).toBe(mockGetRecord.fields.Name.value);

const phoneEl = element.shadowRoot.querySelector(
'lightning-formatted-phone'
);
expect(phoneEl.value).toBe(mockGetRecord.result.fields.Phone.value);
expect(phoneEl.value).toBe(mockGetRecord.fields.Phone.value);

const emailEl = element.shadowRoot.querySelector(
'lightning-formatted-email'
);
expect(emailEl.value).toBe(mockGetRecord.result.fields.Email.value);
expect(emailEl.value).toBe(mockGetRecord.fields.Email.value);
});

it('shows error panel element when error returned', async () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,35 +1,32 @@
{
"status": 0,
"result": {
"apiName": "Contact",
"childRelationships": {},
"eTag": "846fdcd21a53214d447e578adbe263c6",
"fields": {
"Email": {
"displayValue": null,
"value": "[email protected]"
},
"Name": {
"displayValue": null,
"value": "Amy Taylor"
},
"Phone": {
"displayValue": null,
"value": "4152568563"
},
"Title": {
"displayValue": null,
"value": "VP of Engineering"
},
"Picture__c": {
"displayValue": null,
"value": "https://s3-us-west-2.amazonaws.com/dev-or-devrl-s3-bucket/sample-apps/people/amy_taylor.jpg"
}
"apiName": "Contact",
"childRelationships": {},
"eTag": "846fdcd21a53214d447e578adbe263c6",
"fields": {
"Email": {
"displayValue": null,
"value": "[email protected]"
},
"id": "0031700000pHcf8AAC",
"lastModifiedById": "00517000002fESIAA2",
"lastModifiedDate": "2019-02-15T10:33:07.000Z",
"recordTypeInfo": null,
"systemModstamp": "2019-02-15T10:33:07.000Z"
}
"Name": {
"displayValue": null,
"value": "Amy Taylor"
},
"Phone": {
"displayValue": null,
"value": "4152568563"
},
"Title": {
"displayValue": null,
"value": "VP of Engineering"
},
"Picture__c": {
"displayValue": null,
"value": "https://s3-us-west-2.amazonaws.com/dev-or-devrl-s3-bucket/sample-apps/people/amy_taylor.jpg"
}
},
"id": "0031700000pHcf8AAC",
"lastModifiedById": "00517000002fESIAA2",
"lastModifiedDate": "2019-02-15T10:33:07.000Z",
"recordTypeInfo": null,
"systemModstamp": "2019-02-15T10:33:07.000Z"
}
Original file line number Diff line number Diff line change
@@ -1,35 +1,32 @@
{
"status": 0,
"result": {
"apiName": "Contact",
"childRelationships": {},
"eTag": "846fdcd21a53214d447e578adbe263c6",
"fields": {
"Email": {
"displayValue": null,
"value": "[email protected]"
},
"Name": {
"displayValue": null,
"value": "Amy Taylor"
},
"Phone": {
"displayValue": null,
"value": "4152568563"
},
"Title": {
"displayValue": null,
"value": "VP of Engineering"
},
"Picture__c": {
"displayValue": null,
"value": "https://s3-us-west-2.amazonaws.com/dev-or-devrl-s3-bucket/sample-apps/people/amy_taylor.jpg"
}
"apiName": "Contact",
"childRelationships": {},
"eTag": "846fdcd21a53214d447e578adbe263c6",
"fields": {
"Email": {
"displayValue": null,
"value": "[email protected]"
},
"id": "0031700000pHcf8AAC",
"lastModifiedById": "00517000002fESIAA2",
"lastModifiedDate": "2019-02-15T10:33:07.000Z",
"recordTypeInfo": null,
"systemModstamp": "2019-02-15T10:33:07.000Z"
}
"Name": {
"displayValue": null,
"value": "Amy Taylor"
},
"Phone": {
"displayValue": null,
"value": "4152568563"
},
"Title": {
"displayValue": null,
"value": "VP of Engineering"
},
"Picture__c": {
"displayValue": null,
"value": "https://s3-us-west-2.amazonaws.com/dev-or-devrl-s3-bucket/sample-apps/people/amy_taylor.jpg"
}
},
"id": "0031700000pHcf8AAC",
"lastModifiedById": "00517000002fESIAA2",
"lastModifiedDate": "2019-02-15T10:33:07.000Z",
"recordTypeInfo": null,
"systemModstamp": "2019-02-15T10:33:07.000Z"
}
Original file line number Diff line number Diff line change
@@ -1,31 +1,28 @@
{
"status": 0,
"result": {
"apiName": "Contact",
"childRelationships": {},
"eTag": "846fdcd21a53214d447e578adbe263c6",
"fields": {
"Email": {
"displayValue": null,
"value": "[email protected]"
},
"Name": {
"displayValue": null,
"value": "Amy Taylor"
},
"Phone": {
"displayValue": null,
"value": "4152568563"
},
"Title": {
"displayValue": null,
"value": "VP of Engineering"
}
"apiName": "Contact",
"childRelationships": {},
"eTag": "846fdcd21a53214d447e578adbe263c6",
"fields": {
"Email": {
"displayValue": null,
"value": "[email protected]"
},
"id": "0031700000pHcf8AAC",
"lastModifiedById": "00517000002fESIAA2",
"lastModifiedDate": "2019-02-15T10:33:07.000Z",
"recordTypeInfo": null,
"systemModstamp": "2019-02-15T10:33:07.000Z"
}
"Name": {
"displayValue": null,
"value": "Amy Taylor"
},
"Phone": {
"displayValue": null,
"value": "4152568563"
},
"Title": {
"displayValue": null,
"value": "VP of Engineering"
}
},
"id": "0031700000pHcf8AAC",
"lastModifiedById": "00517000002fESIAA2",
"lastModifiedDate": "2019-02-15T10:33:07.000Z",
"recordTypeInfo": null,
"systemModstamp": "2019-02-15T10:33:07.000Z"
}
Original file line number Diff line number Diff line change
Expand Up @@ -71,24 +71,20 @@ describe('c-lms-subscriber-web-component', () => {

// Select elements for validation
const imgEl = element.shadowRoot.querySelector('img');
expect(imgEl.src).toBe(
mockGetRecord.result.fields.Picture__c.value
);
expect(imgEl.src).toBe(mockGetRecord.fields.Picture__c.value);

const nameEl = element.shadowRoot.querySelector('p');
expect(nameEl.textContent).toBe(
mockGetRecord.result.fields.Name.value
);
expect(nameEl.textContent).toBe(mockGetRecord.fields.Name.value);

const phoneEl = element.shadowRoot.querySelector(
'lightning-formatted-phone'
);
expect(phoneEl.value).toBe(mockGetRecord.result.fields.Phone.value);
expect(phoneEl.value).toBe(mockGetRecord.fields.Phone.value);

const emailEl = element.shadowRoot.querySelector(
'lightning-formatted-email'
);
expect(emailEl.value).toBe(mockGetRecord.result.fields.Email.value);
expect(emailEl.value).toBe(mockGetRecord.fields.Email.value);
});

it('renders contact details without picture', async () => {
Expand All @@ -110,21 +106,21 @@ describe('c-lms-subscriber-web-component', () => {

const nameEl = element.shadowRoot.querySelector('p');
expect(nameEl.textContent).toBe(
mockGetRecordNoPicture.result.fields.Name.value
mockGetRecordNoPicture.fields.Name.value
);

const phoneEl = element.shadowRoot.querySelector(
'lightning-formatted-phone'
);
expect(phoneEl.value).toBe(
mockGetRecordNoPicture.result.fields.Phone.value
mockGetRecordNoPicture.fields.Phone.value
);

const emailEl = element.shadowRoot.querySelector(
'lightning-formatted-email'
);
expect(emailEl.value).toBe(
mockGetRecordNoPicture.result.fields.Email.value
mockGetRecordNoPicture.fields.Email.value
);
});
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,31 +1,28 @@
{
"status": 0,
"result": {
"apiName": "Contact",
"childRelationships": {},
"eTag": "846fdcd21a53214d447e578adbe263c6",
"fields": {
"Email": {
"displayValue": null,
"value": "[email protected]"
},
"Name": {
"displayValue": null,
"value": "Amy Taylor"
},
"Phone": {
"displayValue": null,
"value": "4152568563"
},
"Title": {
"displayValue": null,
"value": "VP of Engineering"
}
"apiName": "Contact",
"childRelationships": {},
"eTag": "846fdcd21a53214d447e578adbe263c6",
"fields": {
"Email": {
"displayValue": null,
"value": "[email protected]"
},
"id": "0031700000pHcf8AAC",
"lastModifiedById": "00517000002fESIAA2",
"lastModifiedDate": "2019-02-15T10:33:07.000Z",
"recordTypeInfo": null,
"systemModstamp": "2019-02-15T10:33:07.000Z"
}
"Name": {
"displayValue": null,
"value": "Amy Taylor"
},
"Phone": {
"displayValue": null,
"value": "4152568563"
},
"Title": {
"displayValue": null,
"value": "VP of Engineering"
}
},
"id": "0031700000pHcf8AAC",
"lastModifiedById": "00517000002fESIAA2",
"lastModifiedDate": "2019-02-15T10:33:07.000Z",
"recordTypeInfo": null,
"systemModstamp": "2019-02-15T10:33:07.000Z"
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,17 @@ describe('c-wire-get-record-static-contact', () => {

// Select elements for validation
const nameEl = element.shadowRoot.querySelector('p');
expect(nameEl.textContent).toBe(
mockGetRecord.result.fields.Name.value
);
expect(nameEl.textContent).toBe(mockGetRecord.fields.Name.value);

const phoneEl = element.shadowRoot.querySelector(
'lightning-formatted-phone'
);
expect(phoneEl.value).toBe(mockGetRecord.result.fields.Phone.value);
expect(phoneEl.value).toBe(mockGetRecord.fields.Phone.value);

const emailEl = element.shadowRoot.querySelector(
'lightning-formatted-email'
);
expect(emailEl.value).toBe(mockGetRecord.result.fields.Email.value);
expect(emailEl.value).toBe(mockGetRecord.fields.Email.value);
});
});

Expand Down
Loading

0 comments on commit 8d90a90

Please sign in to comment.