Platform Developer II Mock Lightning Components 26/01/2023 by Miquel Espinosa 0 Comments Welcome to your Platform Developer II Mock Lightning Components 1. What are three reasons that a developer should write Jest tests for LWC? Choose 3 answers. To test basic user interaction To verify that events fire when expected To test how multiple components work together. To verify the DOM output of a component. To test a component's non-public properties. 2. A developer is creating a LWC that displays a list of records in a lightning-datatable. After saving a new record to the database, the list is not updating. What should the developer change in the code above for this to happen? Call refreshApex() on this.data Add the @track decorator to the data variable Create a new variable to store the result and annotate it with @track Create a variable to store the result and call refreshApex() 3. As part of a custom development, a developer creates a Lightning Component to show how a particular opportunity progresses over time. The component must display the date stamp when any of the following fields change: Amount Probability, Stage, or Close Date. What is the most efficient way to Query such information? [Select Amount, CloseDate, StageName, probability FROM OpportunityHistory WHERE OpportunityId = :oppId] [Select Newvalue, oldvalue FROM OpportunityField_History WHERE Opportunity = oppid AND Field IN [Select NewValue, OldValue FROM OpportunityFieldHistory WHERE OpportunityId = :oppId AND Field IN ('StageName', 'Probability', 'Amount/CloseDate')]; [Select Amount CloseDate.StageName, Probability FROM Opportunity_History WHERE OpportunityId = :oppId]; 4. A developer created a LWC that user lightning-record-edit-form to collect information about Leads. Users complain that they only see one error message at a time when they save a Lead record. Which best practice should the developer use to perform the validations, and allow more than one error message to be displayed simultaneously? Client-side validation Process Builder Apex REST Custom Validation Rules 5. Which three actions must be completed in a LWC for a JS file in a static resource to be loaded? Choose 3 answers. Reference the static resource in a tag. Import the static resource. Import a method from the platformResourceLoader Call loadscript Append the static resource to the DOM. 6. Universal Containers wants to be able to bring up an account details page and view a table of containers currently being rented. The user wants to be able to click on a container in the table and quickly edit and save the location of the container. In addition to this, the page should have a section that shows the location of each container on a map. UC wants the map to re-render whenever the location of a container is changed. What can a developer use to accomplish this task? Two Lightning Components leveraging Application Events. Two Visualforce Page Components leveraging Application Events. A single visualforce page leveraging platform events. Two lightning components leveraging platform events. 7. Given the code above, which two changes need to be made in the apex controller for the code to work? Choose 2 answers. Change the method signature to be global static, not public static. Change the argument from JSONObject to String Annotate the entire class as @AuraEnabled instead of just the single method. Remove line 06 from the Apex Controller and use firstName in the return. 8. a company has the lightning component above that allows users to click a button to save their changes and redirects them to a different page. Currently, when the user hits the Save button, the records are getting saved, but they are not redirected. Which three techniques can a developer use to debug the JS? Choose 3 answers. Use Developer Console to view checkpoints. Use Developer Console to view the debug log. Use console.log() messages in the JS Enable Debug Mode for Lightning Components for the user. Use the browser's dev tools to debug the JS. 9. How can a developer efficiently incorporate multiple JS libraries, such as JQuery and MomentJS, in a LWC? Implement the libraries in separate helper files. Use CONs with script attributes. Use JS remoting and script tags Join multiple assets from a static resource 10. A developer is tasked with creating a LWC that is responsive on various devices. Which 2 components should help accomplish this goal? Choose 2 answers. lightning-input-location lightning-navigation lightning-layout lightning-layout-item 11. Which three approaches should a developer implement to obtain the best performance for data retrieval when building a LWC? Choose 3 answers. Use lazy load for occasionally accessed data Use the Lightning Data Service Use layoutTypes : ['Full'] to display a set of fields Use getRecordUi to obtain metadata. Use (cacheable=true) whenever possible. 12. A lead developer for a Salesforce organization needs to develop a page-centric application that allows the user to interact with multiple objects related to a Contact. The application needs to implement a third-party JS framework such as Angular, and must be made available in both Classic and Lightning Experience. Given these requirements, what is the recommended solution to develop the application? Aura Components Visualforce Lightning Web Components Lightning Experience Builder 13. A developer implemented a custom data table in a LWC with filter functionality. However, users are submitted support tickets about long load times when the filters are changed. The component uses an Apex method that is called to query for records the selected filters. What should the developer do to improve performance of the component? Use setStorable() in the Apex method to store the response in the client-side cache Return all records into a list when the component is created and filter the array in JS Use SOSL to query the records on filter change. Use a selective SOQL query with a custom index. 14. A developer is building a LWC to get data from an Apex method called getData that takes a parameter, name. The data should be retrieved when the user clicks the Load Data button. Exhibit. What must be added to get the data? Add @wire(getData, (name: $name)) to the account field and this, account = getData (); to loadData() function. Add this.account = getData(this.name); to the loadData() function Add getData ({ name; this.name }), then (result => { this.account = result}) to the loadData() function. Add @wire(getData, {name: $'name'}) to the account field and delete loadData() because it is not needed. 15. A developer is developing a reuseable Aura Component that will reside on an sObject Lightning Page with the following HTML snippet: aura:component implements="force:hasRecordId,flexipage:availableForAIIPageTypesM div Hello! /div /aura:component Set the sObject type as a component attribute Add force:hasSobjectName to implements Use the getSObjectTypeQ method in an Apex class Create a design attribute and configure via App builder 16. A developer is building an Aura Component to display information about top opportunities in the org. Which three code changes must be made for the component to work? Choose 3 answers. Miquel -> This question does not provide de code. However, if it appears in the exam, remember the correct answers: A,B,D. Add the static keyword to the Apex Method Set the controller in the component markup Add the remoteAction annotation to the Apex method. Add the AuraEnabled annotation to the Apex method. Get the controller action with cmp.get("oppController.getTopOpps"). 17. A developer is building a LWC that displays, quantity, unit price, and the total for an order line item. The total is calculated dynamically as the quantity multiplied by the unit price. Add get total() { return quantity * unitPrice;} to the JS and Total: {total} in the template. Add calculateTotal() {return quantity * unitPrice;} to the JS and Total : {calculate Total()} in the template. Add Total: {quantity * unitPrice} in the template. Add Total; {multiple quantity, unitPrice} in the template. Time is Up! Time's up