const each = require('jest-each').default; const helpers = require('./support/helpers.js'); const serviceNumber = '6658542f-0cad-491f-bec8-ab8457700ead'; const updatesURL = `/services/${serviceNumber}/templates/count-sms-length`; let responseObj = {}; let jqueryAJAXReturnObj; beforeAll(() => { // ensure all timers go through Jest jest.useFakeTimers(); // mock the bits of jQuery used jest.spyOn(window.$, 'ajax'); // set up the object returned from $.ajax so it responds with whatever responseObj is set to jqueryAJAXReturnObj = { done: callback => { // For these tests the server responds immediately callback(responseObj); return jqueryAJAXReturnObj; }, fail: () => {} }; $.ajax.mockImplementation(() => jqueryAJAXReturnObj); require('../../app/assets/javascripts/updateStatus.js'); }); afterAll(() => { require('./support/teardown.js'); }); describe('Update content', () => { beforeEach(() => { document.body.innerHTML = `