I am using this code of stimulus in want to make test cases using Rspec
update(){
this.submitForm()
}
async submitForm(){
const organizationId = this.organizationTarget.value;
var endpoint = this.updateInvoiceTarget.value
var invoiceId = this.updateInvoiceTarget.getAttribute("data-invoice-id")
console.log("invoice_path "+ endpoint)
try {
const result = await fetch(endpoint, {
method: "POST",
headers: {
"Content-Type": "application/json",
"Accept": "application/json",
"X-CSRF-Token": this.getMetaValue("csrf-token"),
},
body: JSON.stringify({ "invoice_id": invoiceId, "organization_id": organizationId }),
});
const data = await result.json();
console.log(data)
if (data.code == 200) {
console.log("SUCCES")
var row = document.getElementById("invoices_list_"+invoiceId);
if (row) {
row.parentNode.removeChild(row);
}
}
} catch (error) {
console.log(error)
}
}
I want to get the expected result data using Rspec rails.