|
1 |
| -import { createClient, CreateClientParams } from '../../lib/contentful' |
2 | 1 | import * as SdkCore from 'contentful-sdk-core'
|
| 2 | +import { createClient } from '../../lib/contentful' |
3 | 3 | import * as CreateContentfulApi from '../../lib/create-contentful-api'
|
4 | 4 |
|
5 | 5 | // eslint-disable-next-line @typescript-eslint/no-var-requires
|
@@ -33,6 +33,7 @@ describe('contentful', () => {
|
33 | 33 |
|
34 | 34 | afterEach(() => {
|
35 | 35 | createHttpClientMock.mockReset()
|
| 36 | + createContentfulApiMock.mockReset() |
36 | 37 | })
|
37 | 38 |
|
38 | 39 | test('Throws if no accessToken is defined', () => {
|
@@ -104,29 +105,27 @@ describe('contentful', () => {
|
104 | 105 | )
|
105 | 106 | })
|
106 | 107 |
|
107 |
| - test.only('Initializes API with alpha features', () => { |
| 108 | + test('Initializes API and attaches custom environment', () => { |
108 | 109 | createClient({
|
109 | 110 | accessToken: 'accessToken',
|
110 | 111 | space: 'spaceId',
|
111 |
| - alphaFeatures: { withContentSourceMaps: true }, |
| 112 | + environment: 'stage', |
112 | 113 | })
|
113 | 114 | const callConfig = createContentfulApiMock.mock.calls[0]
|
114 |
| - |
115 |
| - const alphaFeatures = (callConfig[0].http.httpClientParams as any as CreateClientParams) |
116 |
| - .alphaFeatures |
117 |
| - expect(alphaFeatures).toEqual({ withContentSourceMaps: true }) |
| 115 | + expect(callConfig[0].http.defaults.baseURL).toEqual( |
| 116 | + 'http://some-base-url.com/environments/stage', |
| 117 | + ) |
118 | 118 | })
|
119 | 119 |
|
120 |
| - // fails, not sure if it because of wrong mocking |
121 |
| - test.skip('Initializes API and attaches custom environment', () => { |
| 120 | + test('Initializes API with alpha features', () => { |
122 | 121 | createClient({
|
123 | 122 | accessToken: 'accessToken',
|
124 | 123 | space: 'spaceId',
|
125 |
| - environment: 'stage', |
| 124 | + alphaFeatures: { withContentSourceMaps: true }, |
126 | 125 | })
|
127 |
| - const callConfig = createContentfulApiMock.mock.calls[0] |
128 |
| - expect(callConfig[0].http.defaults.baseURL).toEqual( |
129 |
| - 'http://some-base-url.com/environments/stage', |
130 |
| - ) |
| 126 | + const callConfig = createHttpClientMock.mock.calls[0] |
| 127 | + |
| 128 | + const alphaFeatures = callConfig[1].alphaFeatures |
| 129 | + expect(alphaFeatures).toEqual({ withContentSourceMaps: true }) |
131 | 130 | })
|
132 | 131 | })
|
0 commit comments