import { shallowMount } from '@vue/test-utils' ; import Spinner from '../' ; describe ( 'spinner' , ( ) => { test ( 'create' , ( ) => { const wrapper = shallowMount ( Spinner , { propsData : { } , } ) ; expect ( wrapper . name ( ) ) . toBe ( 'w-spinner' ) ; expect ( wrapper . html ( ) ) . toMatchSnapshot ( ) ; expect ( wrapper . classes ( ) ) . toContain ( 'weui-loading' ) ; wrapper . setProps ( { type : 'snake' , } ) ; expect ( wrapper . classes ( ) ) . toContain ( 'wv-spinner' ) ; } ) ; test ( 'size' , ( ) => { const wrapper = shallowMount ( Spinner , { propsData : { } , } ) ; expect ( wrapper . vm . size ) . toBe ( 17 ) ; wrapper . setProps ( { size : 20 , } ) ; expect ( wrapper . vm . size ) . toBe ( 20 ) ; expect ( wrapper . html ( ) ) . toMatchSnapshot ( ) ; } ) ; test ( 'color' , ( ) => { const wrapper = shallowMount ( Spinner , { propsData : { } , } ) ; expect ( wrapper . vm . color ) . toBe ( '#aaa' ) ; wrapper . setProps ( { color : 'red' , } ) ; expect ( wrapper . vm . color ) . toBe ( 'red' ) ; expect ( wrapper . html ( ) ) . toMatchSnapshot ( ) ; } ) ; test ( 'icon font class should be computed correctly' , ( ) => { const wrapper = shallowMount ( Spinner , { propsData : { } , } ) ; expect ( wrapper . vm . fontclass ) . toBe ( '' ) ; wrapper . setProps ( { type : 'snake' , } ) ; expect ( wrapper . vm . fontclass ) . toBe ( 'icon-spinner-1' ) ; wrapper . setProps ( { type : 'double-snake' , } ) ; expect ( wrapper . vm . fontclass ) . toBe ( 'icon-spinner9' ) ; wrapper . setProps ( { type : 'bar-circle' , } ) ; expect ( wrapper . vm . fontclass ) . toBe ( 'icon-spinner2' ) ; wrapper . setProps ( { type : 'dot-circle' , } ) ; expect ( wrapper . vm . fontclass ) . toBe ( 'icon-spinner1' ) ; } ) ; } ) ;