use .state() on jQuery deferreds instead of .isResolved()

refs FOO-3741

Change-Id: I6a14942edc39920f196d3a6df5a10e5997d92121
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/337484
Reviewed-by: Jen Smith <jen.smith@instructure.com>
QA-Review: Aaron Shafovaloff <ashafovaloff@instructure.com>
Product-Review: Aaron Shafovaloff <ashafovaloff@instructure.com>
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
This commit is contained in:
Aaron Shafovaloff 2024-01-12 07:48:57 -07:00
parent f0804f95dd
commit bd5cb3df8c
3 changed files with 6 additions and 4 deletions

View File

@ -16,7 +16,6 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import Backbone from '@canvas/backbone'
import CourseRestoreModel from 'ui/features/account_admin_tools/backbone/models/CourseRestore'
import $ from 'jquery'
@ -112,6 +111,7 @@ test('responds with a deferred object', function () {
})
// a restored course should be populated with a deleted course with an after a search was made.
// eslint-disable-next-line qunit/no-test-expect-argument
test('restores a course after search finds a deleted course', 2, function () {
this.courseRestore.search(this.course_id)
this.server.respond('GET', this.courseRestore.searchUrl(), [
@ -131,6 +131,7 @@ test('restores a course after search finds a deleted course', 2, function () {
{'Content-Type': 'application/json'},
JSON.stringify(progressCompletedJSON),
])
ok(dfd.isResolved(), 'All ajax request in this deferred object should be resolved')
// eslint-disable-next-line qunit/no-ok-equality
ok(dfd.state() === 'resolved', 'All ajax request in this deferred object should be resolved')
equal(this.courseRestore.get('workflow_state'), 'unpublished')
})

View File

@ -89,6 +89,7 @@ test('restores a user after search finds a deleted user', function () {
{'Content-Type': 'application/json'},
JSON.stringify({...userJSON, login_id: 'du'}),
])
ok(dfd.isResolved(), 'All ajax request in this deferred object should be resolved')
// eslint-disable-next-line qunit/no-ok-equality
ok(dfd.state() === 'resolved', 'All ajax request in this deferred object should be resolved')
equal(this.userRestore.get('login_id'), 'du')
})

View File

@ -480,7 +480,7 @@ export default class TokenSelector {
clearTimeout(this.timeout)
this.select(null)
return (this.timeout = setTimeout(() => {
if (this.lastFetch && !this.lastFetch.isResolved()) {
if (this.lastFetch && !this.lastFetch.state() === 'resolved') {
this.nextRequest = true
return
}