Skip to content

Commit

Permalink
Add inline function prop test (#77)
Browse files Browse the repository at this point in the history
  • Loading branch information
TheJaredWilcurt committed Jun 6, 2023
1 parent b2fd4e3 commit b48d1a1
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 2 deletions.
19 changes: 17 additions & 2 deletions tests/InlineFunctions.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ describe('InlineFunctions.vue', () => {
helpers.mockSettings({
clearInlineFunctions: false
});
let wrapper = mount(InlineFunctions);
const wrapper = mount(InlineFunctions);

expect(wrapper)
.toMatchSnapshot();
Expand All @@ -18,9 +18,24 @@ describe('InlineFunctions.vue', () => {
helpers.mockSettings({
clearInlineFunctions: true
});
let wrapper = mount(InlineFunctions);
const wrapper = mount(InlineFunctions);

expect(wrapper)
.toMatchSnapshot();
});

test('Props', () => {
const wrapper = mount(InlineFunctions);
const propFn = wrapper.vm.propFn;
const fn = propFn();

expect(typeof(propFn))
.toEqual('function');

expect(typeof(fn))
.toEqual('function');

expect(fn())
.toEqual({});
});
});
6 changes: 6 additions & 0 deletions tests/__snapshots__/InlineFunctions.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ exports[`InlineFunctions.vue Functions kept 1`] = `
Attribute does not end with }.
</div>
<p title="function () { [native code] },function () { [native code] }">In array</p>
<footer title="function _default() {
return function () {
return {};
};
}">Default function in in a prop</footer>
</div>
`;

Expand Down Expand Up @@ -65,5 +70,6 @@ exports[`InlineFunctions.vue Functions removed 1`] = `
Attribute does not end with }.
</div>
<p title="[function]">In array</p>
<footer title="[function]">Default function in in a prop</footer>
</div>
`;
9 changes: 9 additions & 0 deletions tests/components/InlineFunctions.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,21 @@
Attribute does not end with }.
</div>
<p :title="[method, method]">In array</p>
<footer :title="propFn">Default function in in a prop</footer>
</div>
</template>

<script>
export default {
name: 'InlineFunctions',
props: {
propFn: {
type: Function,
default: function () {
return () => ({});
}
}
},
methods: {
method: function () {
return 2;
Expand Down

0 comments on commit b48d1a1

Please sign in to comment.