@@ -1753,11 +1753,47 @@ describe('Table', () => {
17531753 vm . $nextTick ( ( ) => {
17541754 expect ( toArray ( lastCells ) . map ( node => node . textContent ) )
17551755 . to . eql ( [ '-100' , '-95' , '-92' , '-92' , '-80' ] ) ;
1756+ destroyVM ( vm ) ;
17561757 done ( ) ;
17571758 } ) ;
17581759 } ) ;
17591760 } , DELAY ) ;
17601761 } ) ;
1762+
1763+ it ( 'sort correct change icon' , async ( ) => {
1764+ function assertSortIconCount ( $el , msg , count = 1 ) {
1765+ const sortIconCount = $el . querySelectorAll ( 'th.ascending, th.descending' ) . length ;
1766+ expect ( sortIconCount ) . to . equal ( count , msg ) ;
1767+ }
1768+
1769+ const vm = createVue ( {
1770+ template : `
1771+ <el-table ref="table" :data="testData" >
1772+ <el-table-column prop="name" sortable />
1773+ <el-table-column prop="release" sortable />
1774+ <el-table-column prop="director" sortable />
1775+ <el-table-column prop="runtime" sortable />
1776+ </el-table>
1777+ ` ,
1778+ data ( ) {
1779+ return { testData : getTestData ( ) } ;
1780+ }
1781+ } ) ;
1782+ await waitImmediate ( ) ;
1783+ assertSortIconCount ( vm . $el , 'sorting icon is not empty after mount' , 0 ) ;
1784+ // manual click first column header
1785+ const elm = vm . $el . querySelector ( '.caret-wrapper' ) ;
1786+ elm . click ( ) ;
1787+ await waitImmediate ( ) ;
1788+ assertSortIconCount ( vm . $el , 'sorting icon is not one after click header' ) ;
1789+ vm . $refs . table . sort ( 'director' , 'descending' ) ;
1790+ await waitImmediate ( ) ;
1791+ assertSortIconCount ( vm . $el , 'sorting icon is not one after call sort' ) ;
1792+ vm . $refs . table . sort ( 'director' , 'ascending' ) ;
1793+ await waitImmediate ( ) ;
1794+ assertSortIconCount ( vm . $el , 'sorting icon is not one after sort same column' ) ;
1795+ destroyVM ( vm ) ;
1796+ } ) ;
17611797 } ) ;
17621798
17631799 it ( 'hover' , async ( ) => {
0 commit comments