forked from learningequality/kolibri-design-system
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
103 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<template> | ||
<DocsPageTemplate apiDocs /> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<template> | ||
|
||
<div class="k-table"> | ||
<table> | ||
<thead> | ||
<tr> | ||
<th v-for="(header,index) in headers" :key="index"> | ||
{{ header }} | ||
</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<tr v-for="(row,index) in rows" :key="index"> | ||
<td v-for="(cell,cellIndex) in row" :key="cellIndex"> | ||
{{ cell }} | ||
</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
</div> | ||
|
||
</template> | ||
<script> | ||
export default { | ||
name: 'KTable', | ||
props: { | ||
headers: { | ||
type: Array, | ||
required: true, | ||
}, | ||
rows: { | ||
type: Array, | ||
required: true, | ||
}, | ||
}, | ||
}; | ||
</script> | ||
<style scoped> | ||
.k-table{ | ||
margin:20px; | ||
border-collapse:collapse; | ||
} | ||
.k-table table{ | ||
width:100%; | ||
border:2px solid #ccc; | ||
border-collapse:separate; | ||
border-spacing:0; | ||
} | ||
.k-table th, .k-table td{ | ||
padding: 10px; | ||
text-align:left; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import {shallowMount} from '@vue/test-utils' | ||
import KTable from '../../lib/KTable.vue'; | ||
|
||
describe('KTable.vue',()=>{ | ||
it('should mount the component',()=>{ | ||
const headers=['Name','Age','City'] | ||
const rows=[ | ||
['Alice',25,'New York'], | ||
['Bob',30,'Los Angeles'], | ||
['Charlie',35,'San Francisco'] | ||
] | ||
const wrapper=shallowMount(KTable,{ | ||
propsData:{ | ||
headers, | ||
rows | ||
} | ||
}) | ||
const thElements=wrapper.findAll('th') | ||
expect(thElements.length).toBe(headers.length) | ||
}) | ||
it('should render correct number of rows',()=>{ | ||
const headers=['Name','Age','City'] | ||
const rows=[ | ||
['Alice',25,'New York'], | ||
['Bob',30,'Los Angeles'], | ||
['Charlie',35,'San Francisco'] | ||
] | ||
const wrapper=shallowMount(KTable,{ | ||
propsData:{ | ||
headers, | ||
rows | ||
} | ||
}) | ||
const trElements=wrapper.findAll('tbody tr') | ||
expect(trElements.length).toBe(rows.length+1) | ||
}) | ||
}) |