瀏覽代碼

prettier et tests

Vincent 8 月之前
父節點
當前提交
b9e9f2cdd3

+ 8 - 2
services/data/Filters/InArrayFilter.ts

@@ -7,7 +7,10 @@ import RefUtils from '~/services/utils/refUtils'
 
 export default class InArrayFilter extends AbstractFilter implements ApiFilter {
   field: string
-  filterValue: Array<string | number | null> | Ref<Array<string | number | null>> | null
+  filterValue:
+    | Array<string | number | null>
+    | Ref<Array<string | number | null>>
+    | null
 
   /**
    * @param field
@@ -16,7 +19,10 @@ export default class InArrayFilter extends AbstractFilter implements ApiFilter {
    */
   constructor(
     field: string,
-    value: Array<string | number | null> | Ref<Array<string | number | null>> | null,
+    value:
+      | Array<string | number | null>
+      | Ref<Array<string | number | null>>
+      | null,
     reactiveFilter: boolean = false,
   ) {
     super(reactiveFilter)

+ 1 - 4
services/data/entityManager.ts

@@ -77,10 +77,7 @@ class EntityManager {
    * @param instance
    */
   // noinspection JSMethodCanBeStatic
-  public cast(
-    model: typeof ApiResource,
-    instance: ApiResource,
-  ): ApiResource {
+  public cast(model: typeof ApiResource, instance: ApiResource): ApiResource {
     // eslint-disable-next-line new-cap
     return new model(instance)
   }

+ 1 - 1
services/rights/abilityBuilder.ts

@@ -5,7 +5,7 @@ import RoleUtils from '~/services/rights/roleUtils'
 import type { AbilitiesType, AccessProfile } from '~/types/interfaces'
 import { ABILITIES } from '~/types/enum/enums'
 import type OrganizationProfile from '~/models/Organization/OrganizationProfile'
-import type { MongoAbility } from '@casl/ability/dist/types/Ability';
+import type { MongoAbility } from '@casl/ability/dist/types/Ability'
 
 interface ConditionParameters {
   action: string

+ 7 - 3
tests/units/services/data/entityManager.test.ts

@@ -732,7 +732,7 @@ describe('reset', () => {
 
     const initialEntity = new DummyApiModel()
     initialEntity.id = 1
-    initialEntity.name = 'serges'
+    initialEntity.name = 'serge'
 
     // @ts-ignore
     entityManager.getInitialStateOf = vi.fn(
@@ -750,7 +750,7 @@ describe('reset', () => {
     // @ts-ignore
     repo.save = vi.fn((data: any) => null)
 
-    const result = entityManager.reset(DummyApiModel, entity)
+    const result = entityManager.reset(initialEntity)
 
     // @ts-ignore
     expect(entityManager.getInitialStateOf).toHaveBeenCalledWith(
@@ -769,8 +769,12 @@ describe('reset', () => {
     entityManager.getInitialStateOf = vi.fn(
       (model: typeof ApiResource, id: string | number) => null,
     )
+    // @ts-ignore
+    entityManager.getModel = vi.fn(
+      (instance: ApiResource) => DummyApiModel,
+    )
 
-    expect(() => entityManager.reset(DummyApiModel, entity)).toThrowError(
+    expect(() => entityManager.reset(entity)).toThrowError(
       'no initial state recorded for this object - abort [dummyModel/1]',
     )
   })

+ 1 - 2
tests/units/services/rights/abilityBuilder.test.ts

@@ -40,11 +40,10 @@ const doc = {
 
 vi.mock('yaml-import', () => {
   return {
-    read: vi.fn((data: string) => doc)
+    read: vi.fn((data: string) => doc),
   }
 })
 
-
 beforeEach(() => {
   ability = vi.fn() as any as MongoAbility
   accessProfile = vi.fn() as any as AccessProfile

+ 1 - 1
types/interfaces.d.ts

@@ -205,7 +205,7 @@ interface ColumnDefinition {
   /**
    * The entity's property to display in this column
    */
-  property: string,
+  property: string
   /**
    * Label of the column.
    * If not provided, a translation of the property's name will be looked for.