bt-core-app 1.2.0 → 1.2.2

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.
@@ -0,0 +1,68 @@
1
+ import { describe, test, expect, afterAll, afterEach, beforeAll } from 'vitest'
2
+ import { createAuth, useAuth } from '../src/composables/auth'
3
+ import { setupServer } from 'msw/node'
4
+ import { http, HttpResponse } from 'msw'
5
+
6
+ const handlers = [
7
+ http.get('https://test-api/get/1', () => {
8
+ return HttpResponse.json({
9
+ data: { test: 'a' },
10
+ count: 0,
11
+ filters: ['test']
12
+ })
13
+ }),
14
+ http.get('https://test-api/get/2', () => {
15
+ return new HttpResponse('not found', {
16
+ status: 304
17
+ })
18
+ }),
19
+ http.get('https://test-api/getAll', () => {
20
+ return HttpResponse.json({
21
+ data: [{ test: 'a' }, { test: 'b' }],
22
+ count: 2,
23
+ filters: ['test', 'test two']
24
+ })
25
+ }),
26
+ http.post('https://test-api/post', () => {
27
+ return HttpResponse.json({ data: { test: 'b' } })
28
+ }),
29
+ http.patch('https://test-api/patch', () => {
30
+ return HttpResponse.json({ data: { test: 'c' } })
31
+ })
32
+ ]
33
+
34
+ const server = setupServer(...handlers)
35
+
36
+ beforeAll(() => server.listen({ onUnhandledRequest: 'error' }))
37
+
38
+ afterAll(() => server.close())
39
+
40
+ afterEach(() => server.resetHandlers())
41
+
42
+ describe('default auth', () => {
43
+ const auth = createAuth({
44
+ defaultTimeZone: 'Aus',
45
+ getAuthItem: () => { return {}},
46
+ getAuthUrl: () => ''
47
+ })
48
+
49
+ test('creates successfully', () => {
50
+ const state = auth.authState
51
+ const creds = auth.credentials
52
+
53
+ expect(state).not.toBeNull()
54
+ expect(auth.credentials).not.toBeNull()
55
+ expect(creds.timeZone).toEqual('Aus')
56
+ })
57
+
58
+ test('use successfully', () => {
59
+ const a = useAuth()
60
+
61
+ expect(a.authState).toEqual(auth.authState)
62
+ })
63
+
64
+
65
+ test('login', () => {
66
+ auth.login()
67
+ })
68
+ })
@@ -1,5 +1,5 @@
1
1
  import { setActivePinia, createPinia } from 'pinia'
2
- import { createSessionStore, createWholeLastUpdateStore } from '../src/composables/stores'
2
+ import { createSessionStoreDefinition, createWholeLastUpdateStoreDefinition } from '../src/composables/stores'
3
3
  import { createApi } from '../src/composables/api'
4
4
  import { describe, test, expect, beforeEach, afterAll, afterEach, beforeAll } from 'vitest'
5
5
  import { setupServer } from 'msw/node'
@@ -49,8 +49,8 @@ describe('use last update store no api no caching', () => {
49
49
 
50
50
  setActivePinia(pinia)
51
51
 
52
- const store = createWholeLastUpdateStore({
53
- api: null,
52
+ const store = createWholeLastUpdateStoreDefinition({
53
+ api: undefined,
54
54
  storageMode: 'session',
55
55
  storeName: 'whole'
56
56
  })()
@@ -95,7 +95,7 @@ describe('use last update store with api no caching', () => {
95
95
  app.use(pinia)
96
96
  setActivePinia(pinia)
97
97
 
98
- const store = createWholeLastUpdateStore({
98
+ const store = createWholeLastUpdateStoreDefinition({
99
99
  storageMode: 'session',
100
100
  api: api,
101
101
  storeName: 'whole-api'