|  | 
| 1 | 1 | import * as core from '@actions/core'; | 
| 2 |  | -import { NotionEndpoints } from '@nishans/endpoints'; | 
|  | 2 | +import { HttpClient } from '@actions/http-client'; | 
| 3 | 3 | import { Schema, SelectSchemaUnit } from '@nishans/types'; | 
| 4 | 4 | import fs from 'fs'; | 
| 5 | 5 | import { action } from '../src/action'; | 
| @@ -80,25 +80,30 @@ it(`Should work`, async () => { | 
| 80 | 80 |  .mockImplementationOnce(() => 'token_v2') | 
| 81 | 81 |  .mockImplementationOnce(() => 'block_1'); | 
| 82 | 82 |  const coreInfo = jest.spyOn(core, 'info'); | 
| 83 |  | - constfetchDataMock=jest | 
|  | 83 | + jest | 
| 84 | 84 |  .spyOn(ActionUtils, 'fetchData') | 
| 85 | 85 |  .mockImplementationOnce(async () => { | 
| 86 | 86 |  return { | 
| 87 |  | - collection_id: 'collection_1' | 
|  | 87 | + collection_id: 'collection_1', | 
|  | 88 | + space_id: 'space_id', | 
|  | 89 | + view_ids: ['view_1'] | 
| 88 | 90 |  } as any; | 
| 89 | 91 |  }) | 
| 90 | 92 |  .mockImplementationOnce(async () => { | 
| 91 | 93 |  return { | 
| 92 | 94 |  schema | 
| 93 | 95 |  } as any; | 
| 94 | 96 |  }); | 
| 95 |  | - const queryCollectionMock = jest | 
| 96 |  | - .spyOn(NotionEndpoints.Queries, 'queryCollection') | 
| 97 |  | - .mockImplementationOnce(async () => { | 
| 98 |  | - return { | 
| 99 |  | - recordMap | 
| 100 |  | - } as any; | 
| 101 |  | - }); | 
|  | 97 | + | 
|  | 98 | + let http = new HttpClient(); | 
|  | 99 | + | 
|  | 100 | + jest.spyOn(http, 'post' as any).mockImplementationOnce(async () => { | 
|  | 101 | + return { | 
|  | 102 | + async resBody() { | 
|  | 103 | + return JSON.stringify({ recordMap }); | 
|  | 104 | + } | 
|  | 105 | + }; | 
|  | 106 | + }); | 
| 102 | 107 | 
 | 
| 103 | 108 |  jest.spyOn(ActionUtils, 'getSchemaEntries').mockImplementationOnce(() => { | 
| 104 | 109 |  return [ | 
| @@ -166,29 +171,6 @@ it(`Should work`, async () => { | 
| 166 | 171 |  ); | 
| 167 | 172 |  expect(getInputMock).toHaveBeenNthCalledWith(1, 'token_v2'); | 
| 168 | 173 |  expect(getInputMock).toHaveBeenNthCalledWith(2, 'database_id'); | 
| 169 |  | - expect(fetchDataMock).toHaveBeenNthCalledWith(1, 'block_1----', 'block'); | 
| 170 |  | - expect(fetchDataMock).toHaveBeenNthCalledWith( | 
| 171 |  | - 2, | 
| 172 |  | - 'collection_1', | 
| 173 |  | - 'collection' | 
| 174 |  | - ); | 
| 175 |  | - expect(queryCollectionMock).toHaveBeenCalledWith( | 
| 176 |  | - { | 
| 177 |  | - collectionId: 'collection_1', | 
| 178 |  | - collectionViewId: '', | 
| 179 |  | - query: {}, | 
| 180 |  | - loader: { | 
| 181 |  | - type: 'table', | 
| 182 |  | - loadContentCover: false, | 
| 183 |  | - limit: 10000, | 
| 184 |  | - userTimeZone: '' | 
| 185 |  | - } | 
| 186 |  | - }, | 
| 187 |  | - { | 
| 188 |  | - token: 'token_v2', | 
| 189 |  | - user_id: '' | 
| 190 |  | - } | 
| 191 |  | - ); | 
| 192 | 174 |  expect(readFileSyncMock).toHaveBeenCalledWith( | 
| 193 | 175 |  `${GITHUB_WORKSPACE}/README.md`, | 
| 194 | 176 |  'utf-8' | 
|  | 
0 commit comments