Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
coopwire-hypothesis
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
孙灵跃 Leon Sun
coopwire-hypothesis
Commits
cde3eaf3
Commit
cde3eaf3
authored
Sep 26, 2015
by
Robert Knight
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add test to verify that post button is enabled when 'can-post' attribute is true
Card 89
parent
bc267718
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
11 deletions
+25
-11
publish-annotation-btn-test.js
...tic/scripts/directive/test/publish-annotation-btn-test.js
+5
-0
util.js
h/static/scripts/directive/test/util.js
+20
-11
No files found.
h/static/scripts/directive/test/publish-annotation-btn-test.js
View file @
cde3eaf3
...
@@ -130,6 +130,11 @@ describe('publishAnnotationBtn', function () {
...
@@ -130,6 +130,11 @@ describe('publishAnnotationBtn', function () {
});
});
var
disabledBtns
=
element
.
find
(
'button[disabled]'
);
var
disabledBtns
=
element
.
find
(
'button[disabled]'
);
assert
.
equal
(
disabledBtns
.
length
,
2
);
assert
.
equal
(
disabledBtns
.
length
,
2
);
// check that buttons are enabled when posting is possible
element
=
element
.
link
({
canPost
:
true
});
disabledBtns
=
element
.
find
(
'button[disabled]'
);
assert
.
equal
(
disabledBtns
.
length
,
0
);
});
});
});
});
h/static/scripts/directive/test/util.js
View file @
cde3eaf3
...
@@ -22,9 +22,6 @@ function hyphenate(name) {
...
@@ -22,9 +22,6 @@ function hyphenate(name) {
*
*
* { attrA: 'initial-value', scopeProperty: scopeValue }
* { attrA: 'initial-value', scopeProperty: scopeValue }
*
*
* Attribute values are converted to scope properties of the same
* name as the attribute and t
*
* @param {Document} document - The DOM Document to create the element in
* @param {Document} document - The DOM Document to create the element in
* @param {string} name - The name of the directive to instantiate
* @param {string} name - The name of the directive to instantiate
* @param {Object} attrs - A map of attribute names (in camelCase) to initial values.
* @param {Object} attrs - A map of attribute names (in camelCase) to initial values.
...
@@ -32,6 +29,8 @@ function hyphenate(name) {
...
@@ -32,6 +29,8 @@ function hyphenate(name) {
* scope when the element is linked
* scope when the element is linked
*
*
* @return {DOMElement} The Angular jqLite-wrapped DOM element for the component.
* @return {DOMElement} The Angular jqLite-wrapped DOM element for the component.
* The returned object has a link(scope) method which will
* re-link the component with new properties.
*/
*/
function
createDirective
(
document
,
name
,
attrs
,
initialScope
)
{
function
createDirective
(
document
,
name
,
attrs
,
initialScope
)
{
attrs
=
attrs
||
{};
attrs
=
attrs
||
{};
...
@@ -56,18 +55,28 @@ function createDirective(document, name, attrs, initialScope) {
...
@@ -56,18 +55,28 @@ function createDirective(document, name, attrs, initialScope) {
});
});
// setup initial scope
// setup initial scope
Object
.
keys
(
initialScope
).
forEach
(
function
(
key
)
{
$scope
[
key
]
=
initialScope
[
key
];
});
Object
.
keys
(
attrs
).
forEach
(
function
(
key
)
{
Object
.
keys
(
attrs
).
forEach
(
function
(
key
)
{
$scope
[
key
]
=
attrs
[
key
];
$scope
[
key
]
=
attrs
[
key
];
});
});
// instantiate component
// compile the template
var
element
=
$compile
(
templateElement
)(
$scope
);
var
linkFn
=
$compile
(
templateElement
);
element
.
scope
=
$scope
;
$scope
.
$digest
();
// link the component, passing in the initial
// scope values. The caller can then re-render/link
// the template passing in different properties
// and verify the output
var
linkDirective
=
function
(
props
)
{
var
childScope
=
$scope
.
$new
();
angular
.
extend
(
childScope
,
props
);
var
element
=
linkFn
(
childScope
);
element
.
link
=
linkDirective
;
element
.
scope
=
childScope
;
childScope
.
$digest
();
return
element
;
return
element
;
}
return
linkDirective
(
initialScope
);
}
}
module
.
exports
=
{
module
.
exports
=
{
...
...
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