Skip to content

Commit

Permalink
Add editor config and update the workflow to include tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Xayton committed Feb 1, 2024
1 parent 511d975 commit c2e6fd2
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 32 deletions.
15 changes: 15 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# https://editorconfig.org

root = true

[*]
charset = utf-8
indent_style = space
indent_size = 2
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true

[*.md]
insert_final_newline = false
trim_trailing_whitespace = false
4 changes: 3 additions & 1 deletion .github/workflows/build-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Build and deploy

on:
push:
branches: ['main']
branches: [ 'main' ]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
Expand Down Expand Up @@ -36,6 +36,8 @@ jobs:
cache: 'npm'
- name: Install dependencies
run: npm install
- name: Test
run: npm run test
- name: Build
run: npm run build

Expand Down
24 changes: 12 additions & 12 deletions tests/footer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@ import Footer from "../src/components/Footer.vue";
import {secToTime} from "../src/composables/secToTime";

test('mount component', async () => {
expect(Footer).toBeTruthy()
expect(Footer).toBeTruthy()

const wrapper = mount(Footer, {
props: {totalUsers: 10, totalTime: 120},
})
const wrapper = mount(Footer, {
props: {totalUsers: 10, totalTime: 120},
})

expect(wrapper.text()).toContain('10 users')
expect(wrapper.text()).toContain(`(${secToTime(120)})`)
expect(wrapper.text()).toContain('10 users')
expect(wrapper.text()).toContain(`(${secToTime(120)})`)


await wrapper.get('img').trigger('click')
expect(wrapper.emitted()).toHaveProperty('randomize')
await wrapper.get('img').trigger('click')
expect(wrapper.emitted()).toHaveProperty('randomize')

await wrapper.setProps({totalUsers: 2, totalTime: 15})
expect(wrapper.text()).toContain('2 users')
expect(wrapper.text()).toContain(`(${secToTime(15)})`)
})
await wrapper.setProps({totalUsers: 2, totalTime: 15})
expect(wrapper.text()).toContain('2 users')
expect(wrapper.text()).toContain(`(${secToTime(15)})`)
})
24 changes: 12 additions & 12 deletions tests/secToTime.test.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { expect, test } from 'vitest'
import {expect, test} from 'vitest'
import {secToTime} from "../src/composables/secToTime";

test('secToTime works', () => {
expect(secToTime(0)).toBe("00:00")
expect(secToTime(1)).toBe("00:01")
expect(secToTime(59)).toBe("00:59")
expect(secToTime(60)).toBe("01:00")
expect(secToTime(61)).toBe("01:01")
expect(secToTime(120)).toBe("02:00")
expect(secToTime(3600)).toBe("60:00")
expect(secToTime(3601)).toBe("60:01")
expect(secToTime(3661)).toBe("61:01")
})
expect(secToTime(0)).toBe("00:00")
expect(secToTime(1)).toBe("00:01")
expect(secToTime(59)).toBe("00:59")
expect(secToTime(60)).toBe("01:00")
expect(secToTime(61)).toBe("01:01")
expect(secToTime(120)).toBe("02:00")

expect(secToTime(3600)).toBe("60:00")
expect(secToTime(3601)).toBe("60:01")
expect(secToTime(3661)).toBe("61:01")
})
15 changes: 8 additions & 7 deletions vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
/// <reference types="vitest" />
import {defineConfig} from 'vite'
import vue from '@vitejs/plugin-vue'

// https://vitejs.dev/config/
export default defineConfig({
plugins: [vue()],
base: '/standup-timer/',
test: {
// vitest specific configuration.
plugins: [vue()],
base: '/standup-timer/',
test: {
// vitest specific configuration.

// The testing environment. Simulate a DOM, so that Vue Components can be tested too.
environment: 'happy-dom'
}
// The testing environment. Simulate a DOM, so that Vue Components can be tested too.
environment: 'happy-dom'
}
})

0 comments on commit c2e6fd2

Please sign in to comment.