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
Boris Kocherov
rsvp.js
Commits
c2973910
Commit
c2973910
authored
Sep 23, 2013
by
Romain Courteaud
🐸
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
adding promise#always
parent
f8ce66af
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
65 additions
and
0 deletions
+65
-0
lib/rsvp/promise.js
lib/rsvp/promise.js
+4
-0
test/tests/extension_test.js
test/tests/extension_test.js
+61
-0
No files found.
lib/rsvp/promise.js
View file @
c2973910
...
@@ -145,6 +145,10 @@ Promise.prototype = {
...
@@ -145,6 +145,10 @@ Promise.prototype = {
fail
:
function
(
fail
)
{
fail
:
function
(
fail
)
{
return
this
.
then
(
null
,
fail
);
return
this
.
then
(
null
,
fail
);
},
always
:
function
(
fail
)
{
return
this
.
then
(
fail
,
fail
);
}
}
};
};
...
...
test/tests/extension_test.js
View file @
c2973910
...
@@ -1328,3 +1328,64 @@ describe("`cancel` on promise created by then", function () {
...
@@ -1328,3 +1328,64 @@ describe("`cancel` on promise created by then", function () {
});
});
});
});
describe
(
"
`always` on a promise
"
,
function
()
{
it
(
'
should be a function
'
,
function
()
{
var
promise
=
new
RSVP
.
Promise
(
function
(
done
,
fail
)
{});
assert
.
equal
(
typeof
promise
.
always
,
"
function
"
);
});
it
(
'
should return a new promise
'
,
function
()
{
var
promise
=
new
RSVP
.
Promise
(
function
(
done
,
fail
)
{}),
promise2
=
promise
.
always
();
assert
(
promise2
instanceof
RSVP
.
Promise
);
});
it
(
'
should fulfill the new promise if the parent is fulfilled
'
,
function
(
done
)
{
var
promise
=
new
RSVP
.
Promise
(
function
(
accept
,
fail
)
{
accept
(
"
bar
"
)}),
promise2
=
promise
.
always
();
setTimeout
(
function
()
{
assert
.
equal
(
promise2
.
isFulfilled
,
true
);
assert
.
equal
(
promise2
.
isRejected
,
undefined
);
assert
.
equal
(
promise2
.
fulfillmentValue
,
"
bar
"
);
done
();
},
20
);
});
it
(
'
should call the function parameter if the parent is fulfilled
'
,
function
(
done
)
{
var
promise
=
new
RSVP
.
Promise
(
function
(
accept
,
fail
)
{
accept
(
"
bar
"
)}),
parameter_called
=
false
,
promise2
=
promise
.
always
(
function
()
{
parameter_called
=
true
});
setTimeout
(
function
()
{
assert
.
equal
(
parameter_called
,
true
);
done
();
},
20
);
});
it
(
'
should reject the new promise if the parent is rejected
'
,
function
(
done
)
{
var
promise
=
new
RSVP
.
Promise
(
function
(
accept
,
fail
)
{
fail
(
"
foo
"
)}),
promise2
=
promise
.
always
();
setTimeout
(
function
()
{
assert
.
equal
(
promise2
.
isFulfilled
,
undefined
);
assert
.
equal
(
promise2
.
isRejected
,
true
);
assert
.
equal
(
promise2
.
rejectedReason
,
"
foo
"
);
done
();
},
20
);
});
it
(
'
should call the function parameter if the parent is rejected
'
,
function
(
done
)
{
var
promise
=
new
RSVP
.
Promise
(
function
(
accept
,
fail
)
{
fail
(
"
foo
"
)}),
parameter_called
=
false
,
promise2
=
promise
.
always
(
function
()
{
parameter_called
=
true
});
setTimeout
(
function
()
{
assert
.
equal
(
parameter_called
,
true
);
done
();
},
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