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
a628a289
Commit
a628a289
authored
Mar 04, 2022
by
Paul Slaughter
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add content_transition unit tests
- It needs to be tested yo
parent
9a23bf3f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
150 additions
and
0 deletions
+150
-0
spec/frontend/vue_shared/components/__snapshots__/content_transition_spec.js.snap
.../components/__snapshots__/content_transition_spec.js.snap
+41
-0
spec/frontend/vue_shared/components/content_transition_spec.js
...frontend/vue_shared/components/content_transition_spec.js
+109
-0
No files found.
spec/frontend/vue_shared/components/__snapshots__/content_transition_spec.js.snap
0 → 100644
View file @
a628a289
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`~/vue_shared/components/content_transition.vue default shows all transitions and only default is visible 1`] = `
<div>
<transition-stub
name="test_transition_name"
>
<div
data-testval="default"
>
<p>
Default
</p>
</div>
</transition-stub>
<transition-stub
name="test_transition_name"
>
<div
data-testval="foo"
style="display: none;"
>
<p>
Foo
</p>
</div>
</transition-stub>
<transition-stub
name="test_transition_name"
>
<div
data-testval="bar"
style="display: none;"
>
<p>
Bar
</p>
</div>
</transition-stub>
</div>
`;
spec/frontend/vue_shared/components/content_transition_spec.js
0 → 100644
View file @
a628a289
import
{
groupBy
,
mapValues
}
from
'
lodash
'
;
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
ContentTransition
from
'
~/vue_shared/components/content_transition.vue
'
;
const
TEST_CURRENT_SLOT
=
'
default
'
;
const
TEST_TRANSITION_NAME
=
'
test_transition_name
'
;
const
TEST_SLOTS
=
[
{
key
:
'
default
'
,
attributes
:
{
'
data-testval
'
:
'
default
'
}
},
{
key
:
'
foo
'
,
attributes
:
{
'
data-testval
'
:
'
foo
'
}
},
{
key
:
'
bar
'
,
attributes
:
{
'
data-testval
'
:
'
bar
'
}
},
];
describe
(
'
~/vue_shared/components/content_transition.vue
'
,
()
=>
{
let
wrapper
;
afterEach
(()
=>
{
wrapper
.
destroy
();
wrapper
=
null
;
});
const
createComponent
=
(
props
=
{},
slots
=
{})
=>
{
wrapper
=
shallowMount
(
ContentTransition
,
{
propsData
:
{
transitionName
:
TEST_TRANSITION_NAME
,
currentSlot
:
TEST_CURRENT_SLOT
,
slots
:
TEST_SLOTS
,
...
props
,
},
slots
:
{
default
:
'
<p>Default</p>
'
,
foo
:
'
<p>Foo</p>
'
,
bar
:
'
<p>Bar</p>
'
,
dne
:
'
<p>DOES NOT EXIST</p>
'
,
...
slots
,
},
});
};
const
findTransitionsData
=
()
=>
wrapper
.
findAll
(
'
transition-stub
'
).
wrappers
.
map
((
transition
)
=>
{
const
child
=
transition
.
find
(
'
[data-testval]
'
);
const
{
style
,
...
attributes
}
=
child
.
attributes
();
return
{
transitionName
:
transition
.
attributes
(
'
name
'
),
isVisible
:
child
.
isVisible
(),
attributes
,
text
:
transition
.
text
(),
};
});
const
findVisibleData
=
()
=>
{
const
group
=
groupBy
(
findTransitionsData
(),
(
x
)
=>
x
.
attributes
[
'
data-testval
'
]);
return
mapValues
(
group
,
(
x
)
=>
x
[
0
].
isVisible
);
};
describe
(
'
default
'
,
()
=>
{
beforeEach
(()
=>
{
createComponent
();
});
it
(
'
shows all transitions and only default is visible
'
,
()
=>
{
expect
(
wrapper
.
element
).
toMatchSnapshot
();
});
it
(
'
render transitions for each slot
'
,
()
=>
{
expect
(
findTransitionsData
()).
toEqual
([
{
attributes
:
{
'
data-testval
'
:
'
default
'
,
},
isVisible
:
true
,
text
:
'
Default
'
,
transitionName
:
'
test_transition_name
'
,
},
{
attributes
:
{
'
data-testval
'
:
'
foo
'
,
},
isVisible
:
false
,
text
:
'
Foo
'
,
transitionName
:
'
test_transition_name
'
,
},
{
attributes
:
{
'
data-testval
'
:
'
bar
'
,
},
isVisible
:
false
,
text
:
'
Bar
'
,
transitionName
:
'
test_transition_name
'
,
},
]);
});
});
describe
(
'
with currentSlot=foo
'
,
()
=>
{
beforeEach
(()
=>
{
createComponent
({
currentSlot
:
'
foo
'
});
});
it
(
'
should only show the foo slot
'
,
()
=>
{
expect
(
findVisibleData
()).
toEqual
({
default
:
false
,
foo
:
true
,
bar
:
false
,
});
});
});
});
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