Skip to content

Commit

Permalink
button for expand tree panel tested
Browse files Browse the repository at this point in the history
  • Loading branch information
adminoid committed Feb 16, 2021
1 parent 1ac6aeb commit 0411496
Show file tree
Hide file tree
Showing 12 changed files with 255 additions and 24 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"hot": "mix watch --hot",
"prod": "npm run production",
"production": "mix --production",
"test": "jest --watch"
"test": "jest"
},
"devDependencies": {
"@vue/compiler-sfc": "^3.0.5",
Expand Down
20 changes: 20 additions & 0 deletions public/img/admin-area/icons/minus.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions public/img/admin-area/icons/plus.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
134 changes: 131 additions & 3 deletions public/js/admin-area/app.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion resources/ts/admin-area/components/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ app-navbar
</template>

<script lang="ts">
import AppNavbar from './AppNavbar'
import AppNavbar from './AppNavbar.vue'
export default {
name: "App",
Expand Down
8 changes: 0 additions & 8 deletions resources/ts/admin-area/components/App.vue.d.ts

This file was deleted.

9 changes: 7 additions & 2 deletions resources/ts/admin-area/components/AppNavbar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,17 @@ nav.navbar.navbar-dark.bg-light-blue
.container-fluid
ul.navbar-nav
li.nav-item
a.btn.btn-outline-success
img(src='/img/admin-area/icons/folding.svg')
app-navbar-tree-toggle-btn
</template>

<script lang="ts">
import AppNavbarTreeToggleBtn from './AppNavbarTreeToggleBtn.vue'
export default {
name: "AppNavbar",
components: {
AppNavbarTreeToggleBtn,
}
}
</script>
45 changes: 45 additions & 0 deletions resources/ts/admin-area/components/AppNavbarTreeToggleBtn.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<template lang="pug">
a.btn.btn-outline-success(@click="clickHandler")
img(src='/img/admin-area/icons/folding.svg')
img.toggle(:src="imageUrl")
</template>

<script lang="ts">
import { defineComponent } from 'vue'
export default defineComponent({
name: "AppNavbarTreeToggleBtn",
data () {
return {
open: false
}
},
computed: {
imageUrl (): string {
let imageName = this.open ? 'minus' : 'plus'
return `/img/admin-area/icons/${imageName}.svg`
}
},
methods: {
clickHandler (): void {
this.open = !this.open
}
},
})
</script>

<style lang="sass" scoped>
.btn-outline-success
background-color: #fff
border-color: #a5e3e2
&:hover
background-color: #9cfffa
.toggle
margin-left: .4em
</style>
9 changes: 0 additions & 9 deletions resources/ts/admin-area/components/__tests__/App.spec.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { shallowMount } from '@vue/test-utils'
import AppNavbarTreeToggleBtn from '../AppNavbarTreeToggleBtn.vue'

describe('AppNavbarTreeToggleBtn.vue', () => {
it('test img src plus/minus', async () => {
const wrapper = shallowMount(AppNavbarTreeToggleBtn)
const button = wrapper.find('.btn-outline-success')

let image = wrapper.find('img.toggle')
let src = image.attributes('src')
let file = src.substring(src.lastIndexOf('/')+1)

expect(file).toMatch(/plus/);

await button.trigger('click')

src = image.attributes('src')
file = src.substring(src.lastIndexOf('/')+1)

expect(file).toMatch(/minus/);

})
})
5 changes: 5 additions & 0 deletions resources/ts/admin-area/shims-vue.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
declare module '*.vue' {
import type { DefineComponent } from 'vue'
const component: DefineComponent<{}, {}, any>
export default component
}
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"strict": true,
"jsx": "preserve",
"moduleResolution": "node",
// additional
"esModuleInterop": true
},
"include": [
Expand Down

0 comments on commit 0411496

Please sign in to comment.