import {DataPersisterArgs, DataProviderArgs} from "~/types/interfaces";
import {QUERY_TYPE} from "~/types/enums";
import TypesTesting from "~/services/utils/typesTesting";

describe('isDataProviderArgs()', () => {
  it('should return true if data is DataProviderArgs', () => {
    const args:DataProviderArgs = {
      type: QUERY_TYPE.MODEL,
      listArgs: {
        itemsPerPage: 10,
        page: 1
      }
    }
    expect(TypesTesting.isDataProviderArgs(args)).toBeTruthy()
  })

  it('should return false if data is not a DataProviderArgs', () => {
    const args:DataPersisterArgs = {
      type: QUERY_TYPE.MODEL,
      data: {
      }
    }
    expect(TypesTesting.isDataProviderArgs(args)).toBeFalsy()
  })
})

describe('isDataPersisterArgs()', () => {
  it('should return true if data is DataPersisterArgs', () => {
    const args:DataPersisterArgs = {
      type: QUERY_TYPE.MODEL,
      data: {
      }
    }
    expect(TypesTesting.isDataPersisterArgs(args)).toBeTruthy()
  })

  it('should return false if data is not a DataPersisterArgs', () => {
    const args:DataProviderArgs = {
      type: QUERY_TYPE.MODEL,
      listArgs: {
        itemsPerPage: 10,
        page: 1
      }
    }
    expect(TypesTesting.isDataPersisterArgs(args)).toBeFalsy()
  })
})
