File tree Expand file tree Collapse file tree 3 files changed +95
-12
lines changed Expand file tree Collapse file tree 3 files changed +95
-12
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1+ import { mount } from '@vue/test-utils'
2+ import { ContainerQuery } from '../../src'
3+
4+ const ContainerQueryApp = {
5+ components : { ContainerQuery } ,
6+ props : {
7+ query : Object ,
8+ initialSize : Object
9+ } ,
10+ data ( ) {
11+ return { params : { } }
12+ } ,
13+ methods : {
14+ handleChange ( params ) {
15+ this . params = params
16+ }
17+ } ,
18+ render ( h ) {
19+ return (
20+ < container-query
21+ query = { this . query }
22+ initialSize = { this . initialSize }
23+ onChange = { this . handleChange }
24+ >
25+ < pre class = "app" > { this . params } </ pre >
26+ </ container-query >
27+ )
28+ }
29+ }
30+
31+ describe ( 'ContainerQuery' , ( ) => {
32+ const query = {
33+ mobile : { maxWidth : 399 } ,
34+ desktop : { minWidth : 400 }
35+ }
36+
37+ const initialSize = { width : 300 }
38+
39+ it ( 'renders without initialSize' , ( ) => {
40+ const wrapper = mount ( ContainerQueryApp , {
41+ propsData : { query }
42+ } )
43+
44+ expect ( wrapper . vm . params ) . toEqual ( { } )
45+ expect ( wrapper . is ( 'pre.app' ) ) . toBe ( true )
46+ } )
47+
48+ it ( 'renders with initialSize' , ( ) => {
49+ const wrapper = mount ( ContainerQueryApp , {
50+ propsData : { query, initialSize }
51+ } )
52+
53+ expect ( wrapper . vm . params . mobile ) . toBe ( true )
54+ expect ( wrapper . vm . params . desktop ) . toBe ( false )
55+ expect ( wrapper . is ( 'pre.app' ) ) . toBe ( true )
56+ } )
57+ } )
58+
Original file line number Diff line number Diff line change 1+ import { shallowMount } from '@vue/test-utils'
2+ import { createContainerQueryMixin } from '../../src'
3+
4+ const query = {
5+ mobile : { maxWidth : 399 } ,
6+ desktop : { minWidth : 400 }
7+ }
8+ const initialSize = { width : 300 }
9+
10+ const template = '<pre class="app">{ containerQuery }</pre>'
11+
12+ describe ( 'createContainerQueryMixin' , ( ) => {
13+ it ( 'renders without initialSize' , ( ) => {
14+ const wrapper = shallowMount ( {
15+ template,
16+ mixins : [
17+ createContainerQueryMixin ( query )
18+ ]
19+ } )
20+
21+ expect ( wrapper . vm . containerQuery ) . toEqual ( { } )
22+ expect ( wrapper . is ( 'pre.app' ) ) . toBe ( true )
23+ } )
24+
25+ it ( 'renders with initialSize' , ( ) => {
26+ const wrapper = shallowMount ( {
27+ template,
28+ mixins : [
29+ createContainerQueryMixin ( query , initialSize )
30+ ]
31+ } )
32+
33+ expect ( wrapper . vm . containerQuery . mobile ) . toBe ( true )
34+ expect ( wrapper . vm . containerQuery . desktop ) . toBe ( false )
35+ expect ( wrapper . is ( 'pre.app' ) ) . toBe ( true )
36+ } )
37+ } )
You can’t perform that action at this time.
0 commit comments