@miraiportal/vue-counter 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of @miraiportal/vue-counter might be problematic. Click here for more details.

@@ -0,0 +1,32 @@
1
+ name: tests
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+ - '*.x'
8
+ pull_request:
9
+ schedule:
10
+ - cron: '0 0 * * *'
11
+
12
+ permissions:
13
+ contents: read
14
+
15
+ jobs:
16
+ tests:
17
+ runs-on: ubuntu-latest
18
+
19
+ steps:
20
+ - name: Checkout code
21
+ uses: actions/checkout@v6
22
+
23
+ - name: Setup Node
24
+ uses: actions/setup-node@v6
25
+ with:
26
+ node-version: 22
27
+
28
+ - name: Install dependencies
29
+ run: npm install
30
+
31
+ - name: Execute tests
32
+ run: npm test
package/package.json ADDED
@@ -0,0 +1,22 @@
1
+ {
2
+ "name": "@miraiportal/vue-counter",
3
+ "version": "1.0.0",
4
+ "license": "MIT",
5
+ "exports": {
6
+ ".": "./resources/js/index.ts"
7
+ },
8
+ "scripts": {
9
+ "test": "vitest run"
10
+ },
11
+ "dependencies": {
12
+ "@miraiportal/counter": "^1.0.0"
13
+ },
14
+ "devDependencies": {
15
+ "vite": "^7.3.1",
16
+ "vitest": "^4.0.18",
17
+ "vue": "^3.5.29"
18
+ },
19
+ "peerDependencies": {
20
+ "vue": "^3.5.29"
21
+ }
22
+ }
@@ -0,0 +1 @@
1
+ export * from './useCounter';
@@ -0,0 +1,13 @@
1
+ import { Counter } from '@miraiportal/counter';
2
+ import { computed, shallowRef } from 'vue';
3
+
4
+ export const useCounter = (initialCount = 0) => {
5
+ const counter = shallowRef(Counter.create(initialCount));
6
+
7
+ return {
8
+ count: computed(() => counter.value.count.value),
9
+ increment: () => (counter.value = counter.value.increment()),
10
+ decrement: () => (counter.value = counter.value.decrement()),
11
+ reset: () => (counter.value = Counter.create(initialCount)),
12
+ };
13
+ };
@@ -0,0 +1 @@
1
+ export * from './composables';
@@ -0,0 +1,45 @@
1
+ import { useCounter } from '../../composables/useCounter';
2
+
3
+ describe('useCounter', () => {
4
+ test('count', () => {
5
+ const value = 0;
6
+
7
+ const { count } = useCounter(value);
8
+
9
+ expect(count.value).toBe(value);
10
+ });
11
+
12
+ test('increment', () => {
13
+ const value = 0;
14
+
15
+ const { count, increment } = useCounter(value);
16
+
17
+ increment();
18
+
19
+ expect(count.value).toBe(value + 1);
20
+ });
21
+
22
+ test('decrement', () => {
23
+ const value = 0;
24
+
25
+ const { count, decrement } = useCounter(value);
26
+
27
+ decrement();
28
+
29
+ expect(count.value).toBe(value - 1);
30
+ });
31
+
32
+ test('reset', () => {
33
+ const value = 1;
34
+
35
+ const { count, increment, reset } = useCounter(value);
36
+
37
+ increment();
38
+
39
+ expect(count.value).toBe(value + 1);
40
+
41
+ reset();
42
+
43
+ expect(count.value).toBe(value);
44
+ });
45
+ });
package/vite.config.ts ADDED
@@ -0,0 +1,10 @@
1
+ /// <reference types="vitest/config" />
2
+
3
+ import { defineConfig } from 'vite';
4
+
5
+ export default defineConfig({
6
+ test: {
7
+ globals: true,
8
+ include: ['resources/js/tests/**/*.test.ts'],
9
+ },
10
+ });