Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
R
rsvp.js
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Romain Courteaud
rsvp.js
Commits
77df9da7
Commit
77df9da7
authored
Feb 25, 2020
by
Romain Courteaud
🐙
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test queue.cancel
parent
5cf9be38
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
119 additions
and
13 deletions
+119
-13
test/tests/extension_test.js
test/tests/extension_test.js
+119
-13
No files found.
test/tests/extension_test.js
View file @
77df9da7
...
...
@@ -2211,8 +2211,10 @@ describe("`RSVP.Queue`", function () {
});
it
(
'
should throw if the queue is rejected
'
,
function
(
done
)
{
var
queue
=
new
RSVP
.
Queue
();
queue
.
cancel
();
var
queue
=
new
RSVP
.
Queue
()
.
push
(
undefined
,
function
()
{
return
RSVP
.
reject
(
1
);
});
setTimeout
(
function
()
{
assert
.
throws
(
function
()
{
...
...
@@ -2221,6 +2223,15 @@ describe("`RSVP.Queue`", function () {
done
();
},
20
);
});
it
(
'
should throw if the queue is cancelled
'
,
function
()
{
var
queue
=
new
RSVP
.
Queue
();
queue
.
cancel
();
assert
.
throws
(
function
()
{
queue
.
push
();
},
RSVP
.
ResolvedQueueError
);
});
});
describe
(
"
`Queue` instance
"
,
function
()
{
...
...
@@ -2251,7 +2262,7 @@ describe("`RSVP.Queue`", function () {
it
(
'
get the fulfillmentValue of the last queue entry
'
,
function
(
done
)
{
var
queue
=
new
RSVP
.
Queue
();
queue
.
push
(
function
()
{
return
"
foo
"
return
"
foo
"
;
});
setTimeout
(
function
()
{
...
...
@@ -2326,25 +2337,120 @@ describe("`RSVP.Queue`", function () {
done
();
},
20
);
});
});
describe
(
"
`cancel`
"
,
function
()
{
it
(
'
cancel also cancels the remaining promise
'
,
function
(
done
)
{
it
(
'
should be a function
'
,
function
()
{
var
queue
=
new
RSVP
.
Queue
();
assert
.
equal
(
typeof
queue
.
cancel
,
"
function
"
);
});
it
(
'
should reject with a CancellationError
'
,
function
(
done
)
{
var
queue
=
new
RSVP
.
Queue
(),
pushed_result
;
queue
.
push
(
function
()
{
return
RSVP
.
timeout
(
1
);
});
queue
.
push
(
undefined
,
function
(
value
)
{
pushed_result
=
value
;
throw
value
;
error
;
queue
.
then
(
null
,
function
(
e
)
{
error
=
e
;
});
queue
.
cancel
();
setTimeout
(
function
()
{
assert
(
pushed_result
instanceof
RSVP
.
CancellationError
);
assert
(
error
instanceof
RSVP
.
CancellationError
);
assert
.
equal
(
queue
.
isRejected
,
true
);
assert
(
queue
.
rejectedReason
instanceof
RSVP
.
CancellationError
);
done
();
},
20
);
});
it
(
'
does nothing on a `fulfilled` queue
'
,
function
(
done
)
{
var
queue
=
new
RSVP
.
Queue
()
.
push
(
function
()
{
return
'
ok
'
;
}),
result
=
'
MARKER1
'
,
error
=
'
MARKER2
'
;
queue
.
then
(
function
(
e
)
{
result
=
e
;
});
queue
.
fail
(
function
(
e
)
{
error
=
e
;
});
setTimeout
(
function
()
{
queue
.
cancel
();
setTimeout
(
function
()
{
assert
.
equal
(
queue
.
isRejected
,
undefined
);
assert
.
equal
(
queue
.
isFulfilled
,
true
);
assert
.
equal
(
queue
.
fulfillmentValue
,
'
ok
'
);
assert
.
equal
(
result
,
'
ok
'
);
assert
.
equal
(
error
,
'
MARKER2
'
);
done
();
},
20
);
},
20
);
});
it
(
'
does nothing on a `rejected` queue
'
,
function
(
done
)
{
var
queue
=
new
RSVP
.
Queue
()
.
push
(
function
()
{
throw
'
ko
'
;
}),
result
=
'
MARKER1
'
,
error
=
'
MARKER2
'
;
queue
.
then
(
function
(
e
)
{
result
=
e
;
});
queue
.
fail
(
function
(
e
)
{
error
=
e
;
});
setTimeout
(
function
()
{
queue
.
cancel
();
setTimeout
(
function
()
{
assert
.
equal
(
queue
.
isRejected
,
true
);
assert
.
equal
(
queue
.
isFulfilled
,
undefined
);
assert
.
equal
(
queue
.
rejectedReason
,
'
ko
'
);
assert
.
equal
(
result
,
'
MARKER1
'
);
assert
.
equal
(
error
,
'
ko
'
);
done
();
},
20
);
},
20
);
});
it
(
'
should `cancel` pending success `thenable`
'
,
function
(
done
)
{
var
thenable_cancel_called
=
false
,
thenable_ongoing
=
false
,
queue
=
new
RSVP
.
Queue
()
.
push
(
function
()
{
return
new
Promise
(
function
()
{
thenable_ongoing
=
true
;
},
function
()
{
thenable_cancel_called
=
true
;
});
}),
result
=
'
MARKER1
'
,
error
=
'
MARKER2
'
;
queue
.
then
(
function
(
e
)
{
result
=
e
;
});
queue
.
fail
(
function
(
e
)
{
error
=
e
;
});
setTimeout
(
function
()
{
assert
.
equal
(
queue
.
isRejected
,
undefined
);
assert
.
equal
(
queue
.
isFulfilled
,
undefined
);
assert
.
equal
(
thenable_ongoing
,
true
);
queue
.
cancel
();
assert
.
equal
(
thenable_cancel_called
,
true
);
setTimeout
(
function
()
{
assert
.
equal
(
queue
.
isRejected
,
true
);
assert
.
equal
(
queue
.
isFulfilled
,
undefined
);
assert
(
queue
.
rejectedReason
instanceof
RSVP
.
CancellationError
);
assert
.
equal
(
result
,
'
MARKER1
'
);
assert
(
error
instanceof
RSVP
.
CancellationError
);
done
();
},
20
);
},
20
);
});
});
});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment