-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue #SB-16090 merge: Merge pull request #221 from Ajoymaity/release…
…-2.7.0 Issue #SB-16090 test: Unit test for storage and file service
- Loading branch information
Showing
6 changed files
with
326 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
src/content/handlers/get-content-heirarchy-handler.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { GetContentHeirarchyHandler } from './get-content-heirarchy-handler'; | ||
import { ApiService } from '../..'; | ||
import { ContentServiceConfig, ContentDetailRequest } from '..'; | ||
import { of } from 'rxjs'; | ||
|
||
describe('GetContentHeirarchyHandler', () => { | ||
let getContentHeirarchyHandler: GetContentHeirarchyHandler; | ||
const mockApiService: Partial<ApiService> = {}; | ||
const mockContentServiceConfig: Partial<ContentServiceConfig> = {}; | ||
|
||
beforeAll(() => { | ||
getContentHeirarchyHandler = new GetContentHeirarchyHandler( | ||
mockApiService as ApiService, | ||
mockContentServiceConfig as ContentServiceConfig | ||
); | ||
}); | ||
|
||
beforeEach(() => { | ||
jest.clearAllMocks(); | ||
}); | ||
|
||
it('should be create a instance of getContentHeirarchyHandler', () => { | ||
expect(getContentHeirarchyHandler).toBeTruthy(); | ||
}); | ||
|
||
it('shpuld handle mapContentFromContentHeirarchyData by invoked handle()', (done) => { | ||
// arrange | ||
const request: ContentDetailRequest = { | ||
contentId: 'do_123' | ||
}; | ||
mockApiService.fetch = jest.fn(() => of({ | ||
body: { | ||
result: { | ||
content: { | ||
children: ['child-1', 'child-2'] | ||
} | ||
} | ||
} | ||
})); | ||
// act | ||
getContentHeirarchyHandler.handle(request).subscribe(() => { | ||
expect(mockApiService.fetch).toHaveBeenCalled(); | ||
done(); | ||
}); | ||
// assert | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.