import UrlOptionsBuilder from '~/services/connection/urlOptionsBuilder' import {QUERY_TYPE} from '~/types/enums' import {DataProviderArgs} from "~/types/interfaces"; describe('build()', () => { it('should return an array with options URL image at the end', () => { const args: DataProviderArgs = { type: QUERY_TYPE.IMAGE, imgArgs: { id:1, height:100, width:100 } } jest.useFakeTimers('modern'); jest.setSystemTime(1585692000000); const options = UrlOptionsBuilder.build(args) expect(options.pop()).toEqual('1585692000000') }) it('should return an array with options lists', () => { const args: DataProviderArgs = { type: QUERY_TYPE.MODEL, listArgs: { itemsPerPage:10, page:1, filters:[ {key: 'name', value: 'Foo'}, {key: 'givenName', value: 'Bar'} ] } } const options = UrlOptionsBuilder.build(args) expect(options.pop()).toEqual('givenName=Bar') expect(options.pop()).toEqual('name=Foo') expect(options.pop()).toEqual('page=1') expect(options.pop()).toEqual('itemsPerPage=10') }) })