Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Workaround spurious failure in async test

  • Loading branch information...
commit 0cfe3f20716cb5b0128787f7c8d8012ec7f51660 1 parent 00b39b8
@SteveSanderson SteveSanderson authored
Showing with 15 additions and 10 deletions.
  1. +15 −10 spec/asyncBehaviors.js
View
25 spec/asyncBehaviors.js
@@ -1,17 +1,22 @@
describe("Throttled observables", function() {
it("Should notify subscribers asynchronously after writes stop for the specified timeout duration", function() {
- var observable = ko.observable('A').extend({ throttle: 50 });
- var notifiedValues = [];
- observable.subscribe(function(value) {
- notifiedValues.push(value);
- });
+ var observable, notifiedValues;
- // Mutate a few times
- observable('B');
- observable('C');
- observable('D');
- expect(notifiedValues.length).toEqual(0); // Should not notify synchronously
+ waits(10); // Was getting spurious failures (blocks running out of order, mainly on IE) if the first item queued wasn't a "wait"
+ runs(function() {
+ observable = ko.observable('A').extend({ throttle: 50 });
+ notifiedValues = [];
+ observable.subscribe(function(value) {
+ notifiedValues.push(value);
+ });
+
+ // Mutate a few times
+ observable('B');
+ observable('C');
+ observable('D');
+ expect(notifiedValues.length).toEqual(0); // Should not notify synchronously
+ });
// Wait
waits(20);
Please sign in to comment.
Something went wrong with that request. Please try again.