mirror of
https://github.com/sasjs/adapter.git
synced 2026-01-09 05:20:05 +00:00
fix: move function, test: added test for folder operations
This commit is contained in:
54
src/test/FolderOperations.spec.ts
Normal file
54
src/test/FolderOperations.spec.ts
Normal file
@@ -0,0 +1,54 @@
|
||||
import { SASViyaApiClient } from '../SASViyaApiClient'
|
||||
|
||||
const sampleResponse = `{
|
||||
"creationTimeStamp": "2021-01-06T14:09:27.705Z",
|
||||
"modifiedTimeStamp": "2021-01-06T14:46:57.391Z",
|
||||
"createdBy": "dctestuser1",
|
||||
"modifiedBy": "dctestuser1",
|
||||
"id": "00000-00000-00000-00000-00000",
|
||||
"name": "test",
|
||||
"parentFolderUri":"/folders/folders/00000-00000-00000-00000-00000",
|
||||
"type": "folder",
|
||||
"memberCount":"1"
|
||||
}`
|
||||
|
||||
describe('FolderOperations', () => {
|
||||
let originalFetch: any
|
||||
|
||||
const sasViyaApiClient = new SASViyaApiClient(
|
||||
'https://sample.server.com',
|
||||
'/Public',
|
||||
'Context',
|
||||
function() {}
|
||||
)
|
||||
|
||||
beforeAll(() => {
|
||||
originalFetch = (global as any).fetch
|
||||
})
|
||||
|
||||
beforeEach(() => {
|
||||
;(global as any).fetch = jest.fn().mockImplementation(() =>
|
||||
Promise.resolve({
|
||||
text: () => Promise.resolve(sampleResponse),
|
||||
json: () => Promise.resolve(sampleResponse),
|
||||
ok: true,
|
||||
headers: {
|
||||
get: function() { return '' }
|
||||
}
|
||||
})
|
||||
)
|
||||
})
|
||||
|
||||
afterAll(() => {
|
||||
;(global as any).fetch = originalFetch
|
||||
})
|
||||
|
||||
it('should move folder successfully', async (done) => {
|
||||
let res: any = await sasViyaApiClient.moveFolder('/Test/test', '/Test/toFolder', 'toFolder', 'token')
|
||||
|
||||
expect(JSON.stringify(res)).toEqual(
|
||||
JSON.stringify(sampleResponse)
|
||||
)
|
||||
done()
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user