Skip to content

Commit

Permalink
fix: appconfig unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
willfarrell committed Aug 25, 2023
1 parent 5e78b0b commit 335f3d3
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 18 deletions.
44 changes: 26 additions & 18 deletions packages/appconfig/__tests__/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,13 @@ test.serial(
test.serial(
'It should set AppConfigData param value to internal storage',
async (t) => {
const params = {
ApplicationIdentifier: '...',
ConfigurationProfileIdentifier: '...',
EnvironmentIdentifier: '...'
}
mockClient(AppConfigDataClient)
.on(StartConfigurationSessionCommand)
.on(StartConfigurationSessionCommand, params)
.resolvesOnce({
ContentType: 'application/json',
InitialConfigurationToken: 'InitialToken...'
Expand All @@ -127,12 +132,9 @@ test.serial(
appConfig({
AwsClient: AppConfigDataClient,
cacheExpiry: 0,
disablePrefetch: true,
fetchData: {
key: {
ApplicationIdentifier: '...',
ConfigurationProfileIdentifier: '...',
EnvironmentIdentifier: '...'
}
key: params
}
})
)
Expand All @@ -145,8 +147,13 @@ test.serial(
test.serial(
'It should use previous configuration token on subsequent app config fetch',
async (t) => {
const params = {
ApplicationIdentifier: '...',
ConfigurationProfileIdentifier: '...',
EnvironmentIdentifier: '...'
}
mockClient(AppConfigDataClient)
.on(StartConfigurationSessionCommand)
.on(StartConfigurationSessionCommand, params)
.resolvesOnce({
ContentType: 'application/json',
InitialConfigurationToken: 'InitialToken...'
Expand Down Expand Up @@ -178,12 +185,9 @@ test.serial(
appConfig({
AwsClient: AppConfigDataClient,
cacheExpiry: 0,
disablePrefetch: true,
fetchData: {
key: {
ApplicationIdentifier: '...',
ConfigurationProfileIdentifier: '...',
EnvironmentIdentifier: '...'
}
key: params
}
})
)
Expand Down Expand Up @@ -233,6 +237,7 @@ test.serial(
appConfig({
AwsClient: AppConfigDataClient,
cacheExpiry: 0,
disablePrefetch: true,
fetchData: {
key: {
ApplicationIdentifier: '...',
Expand Down Expand Up @@ -550,6 +555,7 @@ test.serial(
appConfig({
AwsClient: AppConfigDataClient,
cacheExpiry: 0,
disablePrefetch: true,
fetchData: {
key: {
ApplicationIdentifier: '...',
Expand All @@ -574,8 +580,13 @@ test.serial(
test.serial(
'Should not parse configuration is mime type is not application/json',
async (t) => {
const params = {
ApplicationIdentifier: 'xb0nby2',
ConfigurationProfileIdentifier: 'ofexqm2',
EnvironmentIdentifier: '7tp0goq'
}
mockClient(AppConfigDataClient)
.on(StartConfigurationSessionCommand)
.on(StartConfigurationSessionCommand, params)
.resolvesOnce({
ContentType: 'application/json',
InitialConfigurationToken: 'InitialToken...'
Expand Down Expand Up @@ -604,12 +615,9 @@ test.serial(
appConfig({
AwsClient: AppConfigDataClient,
cacheExpiry: 0,
disablePrefetch: true,
fetchData: {
key: {
ApplicationIdentifier: 'xb0nby2',
ConfigurationProfileIdentifier: 'ofexqm2',
EnvironmentIdentifier: '7tp0goq'
}
key: params
}
})
)
Expand Down
1 change: 1 addition & 0 deletions packages/appconfig/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ const appConfigMiddleware = (opts = {}) => {
modifyCache(options.cacheKey, value)
throw e
})

continue
}
values[internalKey] = fetchLatestConfiguration(
Expand Down

0 comments on commit 335f3d3

Please sign in to comment.