File tree Expand file tree Collapse file tree 2 files changed +53
-0
lines changed Expand file tree Collapse file tree 2 files changed +53
-0
lines changed Original file line number Diff line number Diff line change 1+ import Vue from 'vue'
2+ import expect from 'expect'
3+ import { resetStyled , expectCSSMatches } from './utils'
4+
5+ let styled
6+
7+ describe ( '"as" polymorphic prop' , ( ) => {
8+ beforeEach ( ( ) => {
9+ styled = resetStyled ( )
10+ } )
11+
12+ it ( 'should render "as" polymorphic prop element' , ( ) => {
13+ const Base = styled . div `
14+ color: blue;
15+ `
16+ const b = new Vue ( {
17+ render : ( h ) => h ( Base , {
18+ props : {
19+ as : 'button'
20+ }
21+ } )
22+ } ) . $mount ( )
23+ expect ( b . $el . tagName . toLowerCase ( ) ) . toEqual ( 'button' )
24+ } )
25+
26+
27+ it ( 'should append base class to new components composing lower level styled components' , ( ) => {
28+ const Base = styled . div `
29+ color: blue;
30+ `
31+ const Composed = styled ( Base , {
32+ bg : String ,
33+ } ) `
34+ background: ${ props => props . bg } ;
35+ `
36+
37+ const b = new Vue ( Base ) . $mount ( )
38+ const c = new Vue ( {
39+ render : ( h ) => h ( Composed , {
40+ props : {
41+ bg : 'yellow' ,
42+ as : 'dialog'
43+ }
44+ } )
45+ } ) . $mount ( )
46+
47+ expect ( c . $el . tagName . toLowerCase ( ) ) . toEqual ( 'dialog' )
48+ expect ( c . $el . _prevClass . includes ( b . $el . _prevClass ) ) . toBeTruthy ( )
49+ expectCSSMatches ( '.a{color: blue;} .b{background:yellow;}' )
50+ } )
51+ } )
Original file line number Diff line number Diff line change @@ -60,4 +60,6 @@ describe('props', () => {
6060 const vm = new Vue ( Themed ) . $mount ( )
6161 expectCSSMatches ( '.a {color: blue;}' )
6262 } )
63+
64+ it ( )
6365} )
You can’t perform that action at this time.
0 commit comments