Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
boco-frontend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
idatt2106_2022_02
boco-frontend
Commits
ed1af7de
Commit
ed1af7de
authored
2 years ago
by
Zara Mudassar
Browse files
Options
Downloads
Patches
Plain Diff
Added some label rendering and input value tests.
parent
3e029a8e
No related branches found
Branches containing commit
No related tags found
1 merge request
!14
Create group view
Pipeline
#175947
failed
2 years ago
Stage: build
Stage: test
Stage: deploy
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/components/CreateNewGroup.vue
+21
-20
21 additions, 20 deletions
src/components/CreateNewGroup.vue
tests/unit/create-new-group.spec.js
+49
-0
49 additions, 0 deletions
tests/unit/create-new-group.spec.js
with
70 additions
and
20 deletions
src/components/CreateNewGroup.vue
+
21
−
20
View file @
ed1af7de
...
@@ -9,6 +9,7 @@
...
@@ -9,6 +9,7 @@
<div
class=
"mt-6"
>
<div
class=
"mt-6"
>
<label
<label
class=
"block mb-2 text-sm font-medium text-gray-900 dark:text-gray-300"
class=
"block mb-2 text-sm font-medium text-gray-900 dark:text-gray-300"
id=
"radioBoxLabel"
>
Synlighet
</label
>
Synlighet
</label
>
>
<div
class=
"form-check"
>
<div
class=
"form-check"
>
...
@@ -16,14 +17,15 @@
...
@@ -16,14 +17,15 @@
class=
"form-check-input appearance-none rounded-full h-4 w-4 border border-gray-300 bg-white checked:bg-blue-600 checked:border-blue-600 focus:outline-none transition duration-200 mt-1 align-top bg-no-repeat bg-center bg-contain float-left mr-2 cursor-pointer"
class=
"form-check-input appearance-none rounded-full h-4 w-4 border border-gray-300 bg-white checked:bg-blue-600 checked:border-blue-600 focus:outline-none transition duration-200 mt-1 align-top bg-no-repeat bg-center bg-contain float-left mr-2 cursor-pointer"
type=
"radio"
type=
"radio"
name=
"flexRadioDefault"
name=
"flexRadioDefault"
id=
"flexRadio
Default1
"
id=
"flexRadio
Open
"
value=
"Åpen"
value=
"Åpen"
@
change=
"checkRadioButton($event)"
@
change=
"checkRadioButton($event)"
checked
checked
/>
/>
<label
<label
class=
"form-check-label inline-block text-gray-800"
class=
"form-check-label inline-block text-gray-800"
for=
"flexRadioDefault1"
for=
"flexRadioOpen"
id=
"radioBoxOpenLabel"
>
>
Åpen
Åpen
</label>
</label>
...
@@ -33,13 +35,14 @@
...
@@ -33,13 +35,14 @@
class=
"form-check-input appearance-none rounded-full h-4 w-4 border border-gray-300 bg-white checked:bg-blue-600 checked:border-blue-600 focus:outline-none transition duration-200 mt-1 align-top bg-no-repeat bg-center bg-contain float-left mr-2 cursor-pointer"
class=
"form-check-input appearance-none rounded-full h-4 w-4 border border-gray-300 bg-white checked:bg-blue-600 checked:border-blue-600 focus:outline-none transition duration-200 mt-1 align-top bg-no-repeat bg-center bg-contain float-left mr-2 cursor-pointer"
type=
"radio"
type=
"radio"
name=
"flexRadioDefault"
name=
"flexRadioDefault"
id=
"flexRadio
Default2
"
id=
"flexRadio
Private
"
value=
"Privat"
value=
"Privat"
@
change=
"checkRadioButton($event)"
@
change=
"checkRadioButton($event)"
/>
/>
<label
<label
class=
"form-check-label inline-block text-gray-800"
class=
"form-check-label inline-block text-gray-800"
for=
"flexRadioDefault2"
for=
"flexRadioPrivate"
id=
"radioBoxPrivateLabel"
>
>
Privat
Privat
</label>
</label>
...
@@ -157,22 +160,21 @@
...
@@ -157,22 +160,21 @@
<!-- Button for adding an image -->
<!-- Button for adding an image -->
<div
class=
"inline-flex rounded-md shadow-sm"
>
<div
class=
"inline-flex rounded-md shadow-sm"
>
<button
<button
@
click=
"$refs.file.click()"
@
click=
"$refs.file.click()"
class=
"text-black bg-gray-200 hover:bg-grey-800 focus:ring-4 focus:outline-none focus:ring-grey-300 font-medium rounded-lg text-sm sm:w-auto px-5 py-2.5 text-center dark:bg-grey-600 dark:hover:bg-grey-700 dark:focus:ring-grey-800 disabled:opacity-50 cursor-not-allowed"
class=
"text-black bg-gray-200 hover:bg-grey-800 focus:ring-4 focus:outline-none focus:ring-grey-300 font-medium rounded-lg text-sm sm:w-auto px-5 py-2.5 text-center dark:bg-grey-600 dark:hover:bg-grey-700 dark:focus:ring-grey-800 disabled:opacity-50 cursor-not-allowed"
:disabled=
"imageAdded"
:disabled=
"imageAdded"
>
>
Velg bilde
Velg bilde
</button>
</button>
<!-- Button for removing an image -->
<!-- Button for removing an image -->
<button
<button
class=
"w-1/12 ml-5 text-white bg-white-500 font-medium rounded-lg text-sm"
class=
"w-1/12 ml-5 text-white bg-white-500 font-medium rounded-lg text-sm"
v-show=
"imageAdded"
v-show=
"imageAdded"
@
click=
"removeImage"
@
click=
"removeImage"
>
>
<img
src=
"../assets/removeIcon.png"
alt=
"Remove icon image"
>
<img
src=
"../assets/removeIcon.png"
alt=
"Remove icon image"
/
>
</button>
</button>
</div>
</div>
<!-- Div box for showing all chosen images -->
<!-- Div box for showing all chosen images -->
...
@@ -196,7 +198,7 @@
...
@@ -196,7 +198,7 @@
<
script
>
<
script
>
import
useVuelidate
from
"
@vuelidate/core
"
;
import
useVuelidate
from
"
@vuelidate/core
"
;
import
{
required
,
helpers
,
maxLength
}
from
"
@vuelidate/validators
"
;
import
{
required
,
helpers
,
maxLength
}
from
"
@vuelidate/validators
"
;
export
default
{
export
default
{
name
:
"
CreateNewGroup.vue
"
,
name
:
"
CreateNewGroup.vue
"
,
...
@@ -247,18 +249,17 @@ export default {
...
@@ -247,18 +249,17 @@ export default {
imageThere
:
false
,
imageThere
:
false
,
};
};
},
},
computed
:{
computed
:
{
imageAdded
:
function
(){
imageAdded
:
function
()
{
if
(
this
.
imageThere
){
if
(
this
.
imageThere
)
{
return
true
;
return
true
;
}
}
else
{
else
{
return
false
;
return
false
;
}
}
}
}
,
},
},
methods
:
{
methods
:
{
removeImage
:
function
(){
removeImage
:
function
()
{
this
.
group
.
images
.
pop
();
this
.
group
.
images
.
pop
();
this
.
imageThere
=
false
;
this
.
imageThere
=
false
;
console
.
log
(
"
Bilder nå:
"
+
this
.
group
.
images
.
length
);
console
.
log
(
"
Bilder nå:
"
+
this
.
group
.
images
.
length
);
...
...
This diff is collapsed.
Click to expand it.
tests/unit/create-new-group.spec.js
0 → 100644
+
49
−
0
View file @
ed1af7de
import
{
shallowMount
}
from
"
@vue/test-utils
"
;
import
CreateNewGroup
from
"
@/components/CreateNewGroup.vue
"
;
describe
(
"
CreateNewGroup elements rendering
"
,
()
=>
{
it
(
"
renders all labels
"
,
()
=>
{
const
wrapper
=
shallowMount
(
CreateNewGroup
);
expect
(
wrapper
.
find
(
'
#radioBoxLabel
'
).
text
()).
toMatch
(
"
Synlighet
"
);
expect
(
wrapper
.
find
(
'
#radioBoxOpenLabel
'
).
text
()).
toMatch
(
"
Åpen
"
);
expect
(
wrapper
.
find
(
'
#radioBoxPrivateLabel
'
).
text
()).
toMatch
(
"
Privat
"
);
expect
(
wrapper
.
find
(
'
#titleLabel
'
).
text
()).
toMatch
(
"
Gruppenavn
"
);
expect
(
wrapper
.
find
(
'
#selectCategoryLabel
'
).
text
()).
toMatch
(
"
Kategori
"
);
expect
(
wrapper
.
find
(
'
#descriptionLabel
'
).
text
()).
toMatch
(
"
Beskrivelse
"
);
expect
(
wrapper
.
find
(
'
#imageLabel
'
).
text
()).
toMatch
(
"
Bilde
"
);
});
it
(
"
Tests setting values of input field
"
,
async
()
=>
{
const
wrapper
=
shallowMount
(
CreateNewGroup
);
const
titleInput
=
wrapper
.
find
(
'
#title
'
);
await
titleInput
.
setValue
(
"
Fjellgata
"
);
expect
(
titleInput
.
element
.
value
).
toBe
(
"
Fjellgata
"
);
const
selectedCategory
=
wrapper
.
find
(
'
#categories
'
);
await
selectedCategory
.
setValue
(
"
Borettslag
"
);
expect
(
selectedCategory
.
element
.
value
).
toBe
(
"
Borettslag
"
);
const
descriptionInput
=
wrapper
.
find
(
'
#description
'
);
await
descriptionInput
.
setValue
(
"
Dette er et borettslag
"
);
expect
(
descriptionInput
.
element
.
value
).
toBe
(
"
Dette er et borettslag
"
);
});
it
(
"
Tests if radio box checks
"
,
async
()
=>
{
const
wrapper
=
shallowMount
(
CreateNewGroup
);
const
radioInputOpen
=
wrapper
.
find
(
'
#flexRadioOpen
'
);
await
radioInputOpen
.
setChecked
();
expect
(
radioInputOpen
.
element
.
checked
).
toBeTruthy
();
const
radioInputPrivate
=
wrapper
.
find
(
'
#flexRadioPrivate
'
);
await
radioInputPrivate
.
setChecked
();
expect
(
radioInputPrivate
.
element
.
checked
).
toBeTruthy
();
});
});
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment