1- import { shallow } from 'vue-test-utils'
1+ import { shallow , mount } from 'vue-test-utils'
22import Sass from './resources/Sass.vue'
33import SassModule from './resources/SassModule.vue'
4+ import SassModuleFunctional from './resources/SassModuleFunctional.vue'
45
56describe ( 'processes .vue file with sass style' , ( ) => {
67 it ( 'does not error on sass' , ( ) => {
@@ -9,13 +10,20 @@ describe('processes .vue file with sass style', () => {
910 it ( 'does not error on sass module' , ( ) => {
1011 expect ( ( ) => shallow ( SassModule ) ) . not . toThrow ( )
1112 } )
13+ it ( 'does not error on sass module when functional' , ( ) => {
14+ expect ( ( ) => mount ( SassModuleFunctional ) ) . not . toThrow ( )
15+ } )
1216} )
1317
1418describe ( 'processes .vue files which combine sass and modules' , ( ) => {
1519 let wrapper
20+ let functionalWrapper
21+
1622 beforeEach ( ( ) => {
1723 wrapper = shallow ( SassModule )
24+ functionalWrapper = mount ( SassModuleFunctional )
1825 } )
26+
1927 it ( 'does inject classes to $style' , ( ) => {
2028 expect ( wrapper . vm . $style ) . toBeDefined ( )
2129 expect ( wrapper . vm . $style . testA ) . toBeDefined ( )
@@ -24,6 +32,13 @@ describe('processes .vue files which combine sass and modules', () => {
2432 expect ( wrapper . vm . $style . testB ) . toEqual ( 'testB' )
2533 } )
2634
35+ it ( 'does inject classes to $style for functional components' , ( ) => {
36+ expect ( functionalWrapper . findAll ( '.testAFunctional' ) ) . toHaveLength ( 3 )
37+ expect ( functionalWrapper . findAll ( '.testBFunctional' ) ) . toHaveLength ( 2 )
38+ expect ( functionalWrapper . findAll ( '.otherTestAFunctional' ) ) . toHaveLength ( 1 )
39+ expect ( functionalWrapper . findAll ( '.otherTestBFunctional' ) ) . toHaveLength ( 1 )
40+ } )
41+
2742 describe ( 'entrypoint: direct import in SFC' , ( ) => {
2843 let wrapper
2944 beforeEach ( ( ) => {
0 commit comments