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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
894b5e0f
Commit
894b5e0f
authored
Oct 11, 2017
by
Simon Knox
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add weight select spec
parent
ff1d44fe
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
153 additions
and
4 deletions
+153
-4
app/assets/javascripts/boards/components/weight_select.vue
app/assets/javascripts/boards/components/weight_select.vue
+4
-4
spec/javascripts/boards/components/weight_select_spec.js
spec/javascripts/boards/components/weight_select_spec.js
+149
-0
No files found.
app/assets/javascripts/boards/components/weight_select.vue
View file @
894b5e0f
...
...
@@ -54,13 +54,13 @@ export default {
this
.
board
.
weight
=
this
.
weightInt
(
weight
);
},
weightInt
(
weight
)
{
if
(
weight
===
ANY_WEIGHT
)
{
return
-
1
;
if
(
weight
>
0
)
{
return
weight
;
}
if
(
weight
===
NO_WEIGHT
)
{
return
0
;
}
return
weight
return
-
1
;
}
},
mounted
()
{
...
...
@@ -124,7 +124,7 @@ export default {
:key=
"weight"
>
<a
:class=
"
{'is-active': weight
Int(weight) == value
}"
:class=
"
{'is-active': weight
== valueText
}"
:data-id="weight"
href="#"
>
...
...
spec/javascripts/boards/components/weight_select_spec.js
0 → 100644
View file @
894b5e0f
/* global IssuableContext */
import
Vue
from
'
vue
'
;
import
WeightSelect
from
'
~/boards/components/weight_select.vue
'
;
import
'
~/issuable_context
'
;
let
vm
;
let
board
;
const
weights
=
[
'
Any Weight
'
,
'
No Weight
'
,
1
,
2
,
3
];
function
getSelectedText
()
{
return
vm
.
$el
.
querySelector
(
'
.value
'
).
innerText
.
trim
();
}
function
activeDropdownItem
()
{
return
vm
.
$el
.
querySelector
(
'
.is-active
'
).
innerText
.
trim
();
}
describe
(
'
WeightSelect
'
,
()
=>
{
beforeEach
((
done
)
=>
{
setFixtures
(
'
<div class="test-container"></div>
'
);
board
=
{
weight
:
0
,
labels
:
[],
};
// eslint-disable-next-line no-new
new
IssuableContext
();
const
Component
=
Vue
.
extend
(
WeightSelect
);
vm
=
new
Component
({
propsData
:
{
board
,
canEdit
:
true
,
weights
,
},
}).
$mount
(
'
.test-container
'
);
Vue
.
nextTick
(
done
);
});
describe
(
'
selected value
'
,
()
=>
{
it
(
'
defaults to Any Weight
'
,
()
=>
{
expect
(
getSelectedText
()).
toBe
(
'
Any Weight
'
);
});
it
(
'
displays Any Weight for value -1
'
,
(
done
)
=>
{
vm
.
value
=
-
1
;
Vue
.
nextTick
(()
=>
{
expect
(
getSelectedText
()).
toEqual
(
'
Any Weight
'
);
done
();
});
});
it
(
'
displays No Weight
'
,
(
done
)
=>
{
vm
.
value
=
0
;
Vue
.
nextTick
(()
=>
{
expect
(
getSelectedText
()).
toEqual
(
'
No Weight
'
);
done
();
});
});
it
(
'
weight 1
'
,
(
done
)
=>
{
vm
.
value
=
1
;
Vue
.
nextTick
(()
=>
{
expect
(
getSelectedText
()).
toEqual
(
'
1
'
);
done
();
});
});
});
describe
(
'
active item in dropdown
'
,
()
=>
{
it
(
'
defaults to Any Weight
'
,
(
done
)
=>
{
document
.
querySelector
(
'
.edit-link
'
).
click
();
setTimeout
(()
=>
{
expect
(
activeDropdownItem
()).
toEqual
(
'
Any Weight
'
);
done
();
});
});
it
(
'
shows No Weight
'
,
(
done
)
=>
{
vm
.
value
=
0
;
document
.
querySelector
(
'
.edit-link
'
).
click
();
setTimeout
(()
=>
{
expect
(
activeDropdownItem
()).
toEqual
(
'
No Weight
'
);
done
();
});
});
it
(
'
shows correct weight
'
,
(
done
)
=>
{
vm
.
value
=
1
;
document
.
querySelector
(
'
.edit-link
'
).
click
();
setTimeout
(()
=>
{
expect
(
activeDropdownItem
()).
toEqual
(
'
1
'
);
done
();
});
});
});
describe
(
'
changing weight
'
,
()
=>
{
it
(
'
sets value
'
,
(
done
)
=>
{
document
.
querySelector
(
'
.edit-link
'
).
click
();
setTimeout
(()
=>
{
document
.
querySelectorAll
(
'
li a
'
)[
3
].
click
();
});
setTimeout
(()
=>
{
expect
(
activeDropdownItem
()).
toEqual
(
'
2
'
);
expect
(
board
.
weight
).
toEqual
(
'
2
'
);
done
();
});
});
it
(
'
sets Any Weight
'
,
(
done
)
=>
{
vm
.
value
=
2
;
document
.
querySelector
(
'
.edit-link
'
).
click
();
setTimeout
(()
=>
{
document
.
querySelectorAll
(
'
li a
'
)[
0
].
click
();
});
setTimeout
(()
=>
{
expect
(
activeDropdownItem
()).
toEqual
(
'
Any Weight
'
);
expect
(
board
.
weight
).
toEqual
(
-
1
);
done
();
});
});
it
(
'
sets No Weight
'
,
(
done
)
=>
{
vm
.
value
=
2
;
document
.
querySelector
(
'
.edit-link
'
).
click
();
setTimeout
(()
=>
{
document
.
querySelectorAll
(
'
li a
'
)[
1
].
click
();
});
setTimeout
(()
=>
{
expect
(
activeDropdownItem
()).
toEqual
(
'
No Weight
'
);
expect
(
board
.
weight
).
toEqual
(
0
);
done
();
});
});
});
});
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