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
3fc12b41
Commit
3fc12b41
authored
Mar 23, 2021
by
Coung Ngo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Delete gl_toggle_vuex.vue component
Delete component as it is not used anywhere
parent
d3d72aa0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
0 additions
and
163 deletions
+0
-163
app/assets/javascripts/vue_shared/components/gl_toggle_vuex.vue
...sets/javascripts/vue_shared/components/gl_toggle_vuex.vue
+0
-49
spec/frontend/vue_shared/components/gl_toggle_vuex_spec.js
spec/frontend/vue_shared/components/gl_toggle_vuex_spec.js
+0
-114
No files found.
app/assets/javascripts/vue_shared/components/gl_toggle_vuex.vue
deleted
100644 → 0
View file @
d3d72aa0
<
script
>
import
{
GlToggle
}
from
'
@gitlab/ui
'
;
import
{
capitalizeFirstCharacter
}
from
'
~/lib/utils/text_utility
'
;
export
default
{
name
:
'
GlToggleVuex
'
,
components
:
{
GlToggle
,
},
props
:
{
stateProperty
:
{
type
:
String
,
required
:
true
,
},
storeModule
:
{
type
:
String
,
required
:
false
,
default
:
null
,
},
setAction
:
{
type
:
String
,
required
:
false
,
default
()
{
return
`set
${
capitalizeFirstCharacter
(
this
.
stateProperty
)}
`
;
},
},
},
computed
:
{
value
:
{
get
()
{
const
{
state
}
=
this
.
$store
;
const
{
stateProperty
,
storeModule
}
=
this
;
return
storeModule
?
state
[
storeModule
][
stateProperty
]
:
state
[
stateProperty
];
},
set
(
value
)
{
const
{
stateProperty
,
storeModule
,
setAction
}
=
this
;
const
action
=
storeModule
?
`
${
storeModule
}
/
${
setAction
}
`
:
setAction
;
this
.
$store
.
dispatch
(
action
,
{
key
:
stateProperty
,
value
});
},
},
},
};
</
script
>
<
template
>
<gl-toggle
v-model=
"value"
>
<slot
v-bind=
"
{ value }">
</slot>
</gl-toggle>
</
template
>
spec/frontend/vue_shared/components/gl_toggle_vuex_spec.js
deleted
100644 → 0
View file @
d3d72aa0
import
{
GlToggle
}
from
'
@gitlab/ui
'
;
import
{
mount
,
createLocalVue
}
from
'
@vue/test-utils
'
;
import
Vuex
from
'
vuex
'
;
import
GlToggleVuex
from
'
~/vue_shared/components/gl_toggle_vuex.vue
'
;
const
localVue
=
createLocalVue
();
localVue
.
use
(
Vuex
);
describe
(
'
GlToggleVuex component
'
,
()
=>
{
let
wrapper
;
let
store
;
const
findButton
=
()
=>
wrapper
.
find
(
'
button
'
);
const
createWrapper
=
(
props
=
{})
=>
{
wrapper
=
mount
(
GlToggleVuex
,
{
localVue
,
store
,
propsData
:
{
stateProperty
:
'
toggleState
'
,
...
props
,
},
});
};
beforeEach
(()
=>
{
store
=
new
Vuex
.
Store
({
state
:
{
toggleState
:
false
,
},
actions
:
{
setToggleState
:
({
commit
},
{
key
,
value
})
=>
commit
(
'
setToggleState
'
,
{
key
,
value
}),
},
mutations
:
{
setToggleState
:
(
state
,
{
key
,
value
})
=>
{
state
[
key
]
=
value
;
},
},
});
createWrapper
();
});
afterEach
(()
=>
{
wrapper
.
destroy
();
});
it
(
'
renders gl-toggle
'
,
()
=>
{
expect
(
wrapper
.
find
(
GlToggle
).
exists
()).
toBe
(
true
);
});
it
(
'
properly computes default value for setAction
'
,
()
=>
{
expect
(
wrapper
.
props
(
'
setAction
'
)).
toBe
(
'
setToggleState
'
);
});
describe
(
'
without a store module
'
,
()
=>
{
it
(
'
calls action with new value when value changes
'
,
()
=>
{
jest
.
spyOn
(
store
,
'
dispatch
'
);
findButton
().
trigger
(
'
click
'
);
expect
(
store
.
dispatch
).
toHaveBeenCalledWith
(
'
setToggleState
'
,
{
key
:
'
toggleState
'
,
value
:
true
,
});
});
it
(
'
updates store property when value changes
'
,
()
=>
{
findButton
().
trigger
(
'
click
'
);
expect
(
store
.
state
.
toggleState
).
toBe
(
true
);
});
});
describe
(
'
with a store module
'
,
()
=>
{
beforeEach
(()
=>
{
store
=
new
Vuex
.
Store
({
modules
:
{
someModule
:
{
namespaced
:
true
,
state
:
{
toggleState
:
false
,
},
actions
:
{
setToggleState
:
({
commit
},
{
key
,
value
})
=>
commit
(
'
setToggleState
'
,
{
key
,
value
}),
},
mutations
:
{
setToggleState
:
(
state
,
{
key
,
value
})
=>
{
state
[
key
]
=
value
;
},
},
},
},
});
createWrapper
({
storeModule
:
'
someModule
'
,
});
});
it
(
'
calls action with new value when value changes
'
,
()
=>
{
jest
.
spyOn
(
store
,
'
dispatch
'
);
findButton
().
trigger
(
'
click
'
);
expect
(
store
.
dispatch
).
toHaveBeenCalledWith
(
'
someModule/setToggleState
'
,
{
key
:
'
toggleState
'
,
value
:
true
,
});
});
it
(
'
updates store property when value changes
'
,
()
=>
{
findButton
().
trigger
(
'
click
'
);
expect
(
store
.
state
.
someModule
.
toggleState
).
toBe
(
true
);
});
});
});
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