Skip to content

Commit

Permalink
馃殦 (parser) Mixin in the object
Browse files Browse the repository at this point in the history
  • Loading branch information
HcySunYang committed Mar 21, 2019
1 parent 8a7183d commit bf82ecf
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
9 changes: 9 additions & 0 deletions packages/parser/__test__/__fixtures__/mixins.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<template>
<div></div>
</template>

<script>
export default {
mixins: [MixinA, MixinB, MixinC]
}
</script>
21 changes: 20 additions & 1 deletion packages/parser/__test__/parseJavascript.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import {
PropsResult,
EventResult,
MethodResult,
SlotResult
SlotResult,
MixInResult
} from '@vuese/parser'
import * as path from 'path'
import * as fs from 'fs'
Expand Down Expand Up @@ -458,3 +459,21 @@ test('Render function in class method: Functional children', () => {
expect((arg as SlotResult).describe).toMatchSnapshot()
expect((arg as SlotResult).backerDesc).toMatchSnapshot()
})

test('Mixin in the object', () => {
const sfc: AstResult = getAST('mixins.vue')
const mockOnMixin = jest.fn(() => {})
const options: ParserOptions = {
onMixIn: mockOnMixin
}
parseJavascript(sfc.jsAst as bt.File, options)

expect(mockOnMixin.mock.calls.length).toBe(3)
const arg1 = mockOnMixin.mock.calls[0][0]
const arg2 = mockOnMixin.mock.calls[1][0]
const arg3 = mockOnMixin.mock.calls[2][0]

expect((arg1 as MixInResult).mixIn).toBe('MixinA')
expect((arg2 as MixInResult).mixIn).toBe('MixinB')
expect((arg3 as MixInResult).mixIn).toBe('MixinC')
})

0 comments on commit bf82ecf

Please sign in to comment.