Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
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
Jérome Perrin
gitlab-ce
Commits
31c51c8c
Commit
31c51c8c
authored
Apr 06, 2017
by
Luke "Jared" Bennett
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'update-droplab-to-webpack-version' into new-resolvable-discussion
parents
de3e0834
993c2071
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
80 additions
and
10 deletions
+80
-10
app/assets/javascripts/droplab/plugins/input_setter.js
app/assets/javascripts/droplab/plugins/input_setter.js
+6
-5
spec/javascripts/droplab/plugins/input_setter.js
spec/javascripts/droplab/plugins/input_setter.js
+74
-5
No files found.
app/assets/javascripts/droplab/plugins/input_setter.js
View file @
31c51c8c
...
@@ -33,12 +33,13 @@ const InputSetter = {
...
@@ -33,12 +33,13 @@ const InputSetter = {
setInput
(
config
,
selectedItem
)
{
setInput
(
config
,
selectedItem
)
{
const
input
=
config
.
input
||
this
.
hook
.
trigger
;
const
input
=
config
.
input
||
this
.
hook
.
trigger
;
const
newValue
=
selectedItem
.
getAttribute
(
config
.
valueAttribute
);
const
newValue
=
selectedItem
.
getAttribute
(
config
.
valueAttribute
);
const
inputAttribute
=
config
.
inputAttribute
;
if
(
input
.
tagName
===
'
INPUT
'
)
{
if
(
!
newValue
)
return
;
input
.
value
=
newValue
;
}
else
{
if
(
input
.
hasAttribute
(
inputAttribute
))
return
input
.
setAttribute
(
inputAttribute
,
newValue
);
input
.
textContent
=
newValue
;
if
(
input
.
tagName
===
'
INPUT
'
)
return
input
.
value
=
newValue
;
}
return
input
.
textContent
=
newValue
;
},
},
destroy
()
{
destroy
()
{
...
...
spec/javascripts/droplab/plugins/input_setter.js
View file @
31c51c8c
...
@@ -117,12 +117,13 @@ describe('InputSetter', function () {
...
@@ -117,12 +117,13 @@ describe('InputSetter', function () {
describe
(
'
setInput
'
,
function
()
{
describe
(
'
setInput
'
,
function
()
{
beforeEach
(
function
()
{
beforeEach
(
function
()
{
this
.
selectedItem
=
{
getAttribute
:
()
=>
{}
};
this
.
selectedItem
=
{
getAttribute
:
()
=>
{}
};
this
.
input
=
{
value
:
'
oldValue
'
,
tagName
:
'
INPUT
'
};
this
.
input
=
{
value
:
'
oldValue
'
,
tagName
:
'
INPUT
'
,
hasAttribute
:
()
=>
{}
};
this
.
config
=
{
valueAttribute
:
{},
input
:
this
.
input
};
this
.
config
=
{
valueAttribute
:
{},
input
:
this
.
input
};
this
.
inputSetter
=
{
hook
:
{
trigger
:
{}
}
};
this
.
inputSetter
=
{
hook
:
{
trigger
:
{}
}
};
this
.
newValue
=
'
newValue
'
;
this
.
newValue
=
'
newValue
'
;
spyOn
(
this
.
selectedItem
,
'
getAttribute
'
).
and
.
returnValue
(
this
.
newValue
);
spyOn
(
this
.
selectedItem
,
'
getAttribute
'
).
and
.
returnValue
(
this
.
newValue
);
spyOn
(
this
.
input
,
'
hasAttribute
'
).
and
.
returnValue
(
false
);
InputSetter
.
setInput
.
call
(
this
.
inputSetter
,
this
.
config
,
this
.
selectedItem
);
InputSetter
.
setInput
.
call
(
this
.
inputSetter
,
this
.
config
,
this
.
selectedItem
);
});
});
...
@@ -131,14 +132,34 @@ describe('InputSetter', function () {
...
@@ -131,14 +132,34 @@ describe('InputSetter', function () {
expect
(
this
.
selectedItem
.
getAttribute
).
toHaveBeenCalledWith
(
this
.
config
.
valueAttribute
);
expect
(
this
.
selectedItem
.
getAttribute
).
toHaveBeenCalledWith
(
this
.
config
.
valueAttribute
);
});
});
it
(
'
should call .hasAttribute
'
,
function
()
{
expect
(
this
.
input
.
hasAttribute
).
toHaveBeenCalledWith
(
undefined
);
});
it
(
'
should set the value of the input
'
,
function
()
{
it
(
'
should set the value of the input
'
,
function
()
{
expect
(
this
.
input
.
value
).
toBe
(
this
.
newValue
);
expect
(
this
.
input
.
value
).
toBe
(
this
.
newValue
);
});
describe
(
'
if there is no newValue
'
,
function
()
{
beforeEach
(
function
()
{
this
.
newValue
=
''
;
this
.
inputSetter
=
{
hook
:
{
trigger
:
{}
}
};
this
.
config
=
{
valueAttribute
:
{},
input
:
this
.
input
};
this
.
input
=
{
value
:
'
oldValue
'
,
tagName
:
'
INPUT
'
};
this
.
selectedItem
=
{
getAttribute
:
()
=>
{}
};
InputSetter
.
setInput
.
call
(
this
.
inputSetter
,
this
.
config
,
this
.
selectedItem
);
});
it
(
'
should not set the value of the input
'
,
function
()
{
expect
(
this
.
input
.
value
).
toBe
(
'
oldValue
'
);
})
})
});
describe
(
'
if no config.input is provided
'
,
function
()
{
describe
(
'
if no config.input is provided
'
,
function
()
{
beforeEach
(
function
()
{
beforeEach
(
function
()
{
this
.
config
=
{
valueAttribute
:
{}
};
this
.
config
=
{
valueAttribute
:
{}
};
this
.
trigger
=
{
value
:
'
oldValue
'
,
tagName
:
'
INPUT
'
};
this
.
trigger
=
{
value
:
'
oldValue
'
,
tagName
:
'
INPUT
'
,
hasAttribute
:
()
=>
{}
};
this
.
inputSetter
=
{
hook
:
{
trigger
:
this
.
trigger
}
};
this
.
inputSetter
=
{
hook
:
{
trigger
:
this
.
trigger
}
};
InputSetter
.
setInput
.
call
(
this
.
inputSetter
,
this
.
config
,
this
.
selectedItem
);
InputSetter
.
setInput
.
call
(
this
.
inputSetter
,
this
.
config
,
this
.
selectedItem
);
...
@@ -151,14 +172,62 @@ describe('InputSetter', function () {
...
@@ -151,14 +172,62 @@ describe('InputSetter', function () {
describe
(
'
if the input tag is not INPUT
'
,
function
()
{
describe
(
'
if the input tag is not INPUT
'
,
function
()
{
beforeEach
(
function
()
{
beforeEach
(
function
()
{
this
.
input
=
{
textContent
:
'
oldValue
'
,
tagName
:
'
SPAN
'
};
this
.
input
=
{
textContent
:
'
oldValue
'
,
tagName
:
'
SPAN
'
,
hasAttribute
:
()
=>
{}
};
this
.
config
=
{
valueAttribute
:
{},
input
:
this
.
input
};
this
.
config
=
{
valueAttribute
:
{},
input
:
this
.
input
};
InputSetter
.
setInput
.
call
(
this
.
inputSetter
,
this
.
config
,
this
.
selectedItem
);
InputSetter
.
setInput
.
call
(
this
.
inputSetter
,
this
.
config
,
this
.
selectedItem
);
});
});
it
(
'
should set the textContent of the input
'
,
function
()
{
it
(
'
should set the textContent of the input
'
,
function
()
{
expect
(
this
.
config
.
input
.
textContent
).
toBe
(
this
.
newValue
);
expect
(
this
.
input
.
textContent
).
toBe
(
this
.
newValue
);
});
describe
(
'
if there is no new value
'
,
function
()
{
beforeEach
(
function
()
{
this
.
selectedItem
=
{
getAttribute
:
()
=>
{}
};
this
.
input
=
{
textContent
:
'
oldValue
'
,
tagName
:
'
INPUT
'
,
hasAttribute
:
()
=>
{}
};
this
.
config
=
{
valueAttribute
:
{},
input
:
this
.
input
};
this
.
inputSetter
=
{
hook
:
{
trigger
:
{}
}
};
this
.
newValue
=
'
newValue
'
;
spyOn
(
this
.
selectedItem
,
'
getAttribute
'
).
and
.
returnValue
(
this
.
newValue
);
InputSetter
.
setInput
.
call
(
this
.
inputSetter
,
this
.
config
,
this
.
selectedItem
);
});
it
(
'
should not set the value of the input
'
,
function
()
{
expect
(
this
.
input
.
textContent
).
toBe
(
'
oldValue
'
);
});
});
});
describe
(
'
if there is an inputAttribute
'
,
function
()
{
beforeEach
(
function
()
{
this
.
selectedItem
=
{
getAttribute
:
()
=>
{}
};
this
.
input
=
{
id
:
'
oldValue
'
,
hasAttribute
:
()
=>
{},
setAttribute
:
()
=>
{}
};
this
.
inputSetter
=
{
hook
:
{
trigger
:
{}
}
};
this
.
newValue
=
'
newValue
'
;
this
.
inputAttribute
=
'
id
'
;
this
.
config
=
{
valueAttribute
:
{},
input
:
this
.
input
,
inputAttribute
:
this
.
inputAttribute
,
};
spyOn
(
this
.
selectedItem
,
'
getAttribute
'
).
and
.
returnValue
(
this
.
newValue
);
spyOn
(
this
.
input
,
'
hasAttribute
'
).
and
.
returnValue
(
true
);
spyOn
(
this
.
input
,
'
setAttribute
'
);
InputSetter
.
setInput
.
call
(
this
.
inputSetter
,
this
.
config
,
this
.
selectedItem
);
});
it
(
'
should call setAttribute
'
,
function
()
{
expect
(
this
.
input
.
setAttribute
).
toHaveBeenCalledWith
(
this
.
inputAttribute
,
this
.
newValue
);
});
it
(
'
should not set the value or textContent of the input
'
,
function
()
{
expect
(
this
.
input
.
value
).
not
.
toBe
(
'
newValue
'
);
expect
(
this
.
input
.
textContent
).
not
.
toBe
(
'
newValue
'
);
});
});
});
});
});
});
...
...
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