Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
gabaldon committed Sep 3, 2024
1 parent 4689ab5 commit 9931e91
Show file tree
Hide file tree
Showing 6 changed files with 296 additions and 2 deletions.
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
"gsap": "^3.12.5",
"postcss-cli": "^11.0.0",
"sass": "^1.77.8",
"vite-svg-loader": "^5.1.0"
"vite-svg-loader": "^5.1.0",
"vue-select": "^4.0.0-beta.3"
},
"devDependencies": {
"@chromatic-com/storybook": "^1.6.1",
Expand All @@ -49,6 +50,7 @@
"@tsconfig/node20": "^20.1.4",
"@types/jsdom": "^21.1.7",
"@types/node": "^20.14.5",
"@types/vue-select": "^3.16.8",
"@vitejs/plugin-vue": "^5.0.5",
"@vue/eslint-config-prettier": "^9.0.0",
"@vue/eslint-config-typescript": "^13.0.0",
Expand Down
57 changes: 56 additions & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 31 additions & 0 deletions src/components/Switch/WSwitch.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { describe, it, expect } from 'vitest'
import { mount } from '@vue/test-utils'
import WSwitch from './WSwitch.vue'

describe('WSwitch', () => {
it('renders properly', () => {
const wrapper = mount(WSwitch, {
emits: ['update:modelValue'],
props: {
modelValue: {
key: 'en',
label: 'English',
icon: null
},
'onUpdate:modelValue': (e) => wrapper.setProps({ modelValue: e }),
options: [{
key: 'en',
label: 'English',
icon: null
},{
key: 'es',
label: 'Español',
icon: null,
}
]
},
})

expect(wrapper.element).toMatchSnapshot()
})
})

Check failure on line 31 in src/components/Switch/WSwitch.spec.ts

View workflow job for this annotation

GitHub Actions / cache-and-install

src/components/Switch/WSwitch.spec.ts > WSwitch > renders properly

Error: Snapshot `WSwitch > renders properly 1` mismatched ❯ src/components/Switch/WSwitch.spec.ts:31:29
56 changes: 56 additions & 0 deletions src/components/Switch/WSwitch.stories.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import type { Meta, StoryObj } from '@storybook/vue3'
import WSwitch from './WSwitch.vue'
import { Option } from './WSwitch'

Check warning on line 3 in src/components/Switch/WSwitch.stories.ts

View workflow job for this annotation

GitHub Actions / cache-and-install

'Option' is defined but never used
import { ref, watch, markRaw } from 'vue'

Check warning on line 4 in src/components/Switch/WSwitch.stories.ts

View workflow job for this annotation

GitHub Actions / cache-and-install

'watch' is defined but never used

Check warning on line 4 in src/components/Switch/WSwitch.stories.ts

View workflow job for this annotation

GitHub Actions / cache-and-install

'markRaw' is defined but never used
import 'vue-select/dist/vue-select.css'

const meta: any = {
title: 'Example/WSwitch',
component: WSwitch,
tags: ['autodocs'],
argTypes: {},
args: {
options: [{
key: 'en',
label: 'English',
icon: null
},{
key: 'es',
label: 'Español',
icon: null,
}]}
} satisfies Meta<typeof WSwitch>

export default meta
type Story = StoryObj<typeof meta>

export const Default: Story = {
render: (args: any) => ({
components: { WSwitch },
setup() {
const model = ref({
key: 'en',
label: 'English',
icon: null
});

function update($event: any) {
model.value = $event
}

return { args, model, update };
},
template: `<WSwitch v-bind="args" v-model="model" @update:model-value="update" />`,
args: {
options: [{
key: 'en',
label: 'English',
icon: null
},{
key: 'es',
label: 'Español',
icon: null,
}]
}
})
}
1 change: 1 addition & 0 deletions src/components/Switch/WSwitch.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export type Option = {key: string, label: string, icon: string | null}
Loading

0 comments on commit 9931e91

Please sign in to comment.