mirror of
https://github.com/logto-io/logto.git
synced 2025-03-24 22:41:28 -05:00
chore: apply suggestions from code review
Co-authored-by: Gao Sun <gao@silverhand.io>
This commit is contained in:
parent
2e103f513e
commit
801eae87d2
1 changed files with 71 additions and 71 deletions
|
@ -3,7 +3,7 @@ import { cond } from '@silverhand/essentials';
|
|||
import deepmerge from 'deepmerge';
|
||||
|
||||
describe('Test the deploy custom JWT script', () => {
|
||||
describe('Test script when both AccessToken & ClientCredentials scripts are working', () => {
|
||||
describe('Test script when both AccessToken & ClientCredentials scripts are existing', () => {
|
||||
it.each(Object.values(LogtoJwtTokenKey))('test %s script', (key) => {
|
||||
expect(
|
||||
deepmerge(
|
||||
|
@ -37,31 +37,31 @@ describe('Test the deploy custom JWT script', () => {
|
|||
describe('Test script:', () => {
|
||||
// Test it.each() can not be nested, so we have to test each key separately.
|
||||
it.each(Object.values(LogtoJwtTokenKey))(
|
||||
`when ${LogtoJwtTokenKey.AccessToken} script is working, test $s script`,
|
||||
`when ${LogtoJwtTokenKey.AccessToken} script is existing, test $s script`,
|
||||
(testingKey) => {
|
||||
const workingKey = LogtoJwtTokenKey.AccessToken;
|
||||
const workingScript = {
|
||||
[workingKey]: {
|
||||
production: `${workingKey}-production`,
|
||||
const existingKey = LogtoJwtTokenKey.AccessToken;
|
||||
const existingScript = {
|
||||
[existingKey]: {
|
||||
production: `${existingKey}-production`,
|
||||
},
|
||||
};
|
||||
expect(
|
||||
deepmerge(workingScript, {
|
||||
deepmerge(existingScript, {
|
||||
[testingKey]: {
|
||||
test: `${testingKey}-test`,
|
||||
},
|
||||
})
|
||||
).toEqual(
|
||||
workingKey === testingKey
|
||||
existingKey === testingKey
|
||||
? {
|
||||
[workingKey]: {
|
||||
production: `${workingKey}-production`,
|
||||
test: `${workingKey}-test`,
|
||||
[existingKey]: {
|
||||
production: `${existingKey}-production`,
|
||||
test: `${existingKey}-test`,
|
||||
},
|
||||
}
|
||||
: {
|
||||
[workingKey]: {
|
||||
production: `${workingKey}-production`,
|
||||
[existingKey]: {
|
||||
production: `${existingKey}-production`,
|
||||
},
|
||||
[testingKey]: {
|
||||
test: `${testingKey}-test`,
|
||||
|
@ -72,31 +72,31 @@ describe('Test the deploy custom JWT script', () => {
|
|||
);
|
||||
|
||||
it.each(Object.values(LogtoJwtTokenKey))(
|
||||
`when ${LogtoJwtTokenKey.ClientCredentials} script is working, test $s script`,
|
||||
`when ${LogtoJwtTokenKey.ClientCredentials} script is existing, test $s script`,
|
||||
(testingKey) => {
|
||||
const workingKey = LogtoJwtTokenKey.ClientCredentials;
|
||||
const workingScript = {
|
||||
[workingKey]: {
|
||||
production: `${workingKey}-production`,
|
||||
const existingKey = LogtoJwtTokenKey.ClientCredentials;
|
||||
const existingScript = {
|
||||
[existingKey]: {
|
||||
production: `${existingKey}-production`,
|
||||
},
|
||||
};
|
||||
expect(
|
||||
deepmerge(workingScript, {
|
||||
deepmerge(existingScript, {
|
||||
[testingKey]: {
|
||||
test: `${testingKey}-test`,
|
||||
},
|
||||
})
|
||||
).toEqual(
|
||||
workingKey === testingKey
|
||||
existingKey === testingKey
|
||||
? {
|
||||
[workingKey]: {
|
||||
production: `${workingKey}-production`,
|
||||
test: `${workingKey}-test`,
|
||||
[existingKey]: {
|
||||
production: `${existingKey}-production`,
|
||||
test: `${existingKey}-test`,
|
||||
},
|
||||
}
|
||||
: {
|
||||
[workingKey]: {
|
||||
production: `${workingKey}-production`,
|
||||
[existingKey]: {
|
||||
production: `${existingKey}-production`,
|
||||
},
|
||||
[testingKey]: {
|
||||
test: `${testingKey}-test`,
|
||||
|
@ -107,7 +107,7 @@ describe('Test the deploy custom JWT script', () => {
|
|||
);
|
||||
});
|
||||
|
||||
describe('Test script when both AccessToken & ClientCredentials scripts are not working', () => {
|
||||
describe('Test script when both AccessToken & ClientCredentials scripts are not existing', () => {
|
||||
it.each(Object.values(LogtoJwtTokenKey))('test %s script', (key) => {
|
||||
expect(
|
||||
deepmerge(
|
||||
|
@ -124,7 +124,7 @@ describe('Test the deploy custom JWT script', () => {
|
|||
});
|
||||
|
||||
describe('Test deploy custom JWT script', () => {
|
||||
describe('Deploy script when both AccessToken & ClientCredentials scripts are working', () => {
|
||||
describe('Deploy script when both AccessToken & ClientCredentials scripts are existing', () => {
|
||||
it.each(Object.values(LogtoJwtTokenKey))('deploy %s script', (key) => {
|
||||
expect(
|
||||
deepmerge(
|
||||
|
@ -160,30 +160,30 @@ describe('Test deploy custom JWT script', () => {
|
|||
describe('Deploy script:', () => {
|
||||
// Test it.each() can not be nested, so we have to test each key separately.
|
||||
it.each(Object.values(LogtoJwtTokenKey))(
|
||||
`when ${LogtoJwtTokenKey.AccessToken} script is working, deploy $s script`,
|
||||
`when ${LogtoJwtTokenKey.AccessToken} script is existing, deploy $s script`,
|
||||
(deployingKey) => {
|
||||
const workingKey = LogtoJwtTokenKey.AccessToken;
|
||||
const workingScript = {
|
||||
[workingKey]: {
|
||||
production: `${workingKey}-production`,
|
||||
const existingKey = LogtoJwtTokenKey.AccessToken;
|
||||
const existingScript = {
|
||||
[existingKey]: {
|
||||
production: `${existingKey}-production`,
|
||||
},
|
||||
};
|
||||
expect(
|
||||
deepmerge(workingScript, {
|
||||
deepmerge(existingScript, {
|
||||
[deployingKey]: {
|
||||
production: `${deployingKey}-production-new`,
|
||||
},
|
||||
})
|
||||
).toEqual(
|
||||
workingKey === deployingKey
|
||||
existingKey === deployingKey
|
||||
? {
|
||||
[workingKey]: {
|
||||
production: `${workingKey}-production-new`,
|
||||
[existingKey]: {
|
||||
production: `${existingKey}-production-new`,
|
||||
},
|
||||
}
|
||||
: {
|
||||
[workingKey]: {
|
||||
production: `${workingKey}-production`,
|
||||
[existingKey]: {
|
||||
production: `${existingKey}-production`,
|
||||
},
|
||||
[deployingKey]: {
|
||||
production: `${deployingKey}-production-new`,
|
||||
|
@ -194,30 +194,30 @@ describe('Test deploy custom JWT script', () => {
|
|||
);
|
||||
|
||||
it.each(Object.values(LogtoJwtTokenKey))(
|
||||
`when ${LogtoJwtTokenKey.ClientCredentials} script is working, deploy $s script`,
|
||||
`when ${LogtoJwtTokenKey.ClientCredentials} script is existing, deploy $s script`,
|
||||
(deployingKey) => {
|
||||
const workingKey = LogtoJwtTokenKey.ClientCredentials;
|
||||
const workingScript = {
|
||||
[workingKey]: {
|
||||
production: `${workingKey}-production`,
|
||||
const existingKey = LogtoJwtTokenKey.ClientCredentials;
|
||||
const existingScript = {
|
||||
[existingKey]: {
|
||||
production: `${existingKey}-production`,
|
||||
},
|
||||
};
|
||||
expect(
|
||||
deepmerge(workingScript, {
|
||||
deepmerge(existingScript, {
|
||||
[deployingKey]: {
|
||||
production: `${deployingKey}-production-new`,
|
||||
},
|
||||
})
|
||||
).toEqual(
|
||||
workingKey === deployingKey
|
||||
existingKey === deployingKey
|
||||
? {
|
||||
[workingKey]: {
|
||||
production: `${workingKey}-production-new`,
|
||||
[existingKey]: {
|
||||
production: `${existingKey}-production-new`,
|
||||
},
|
||||
}
|
||||
: {
|
||||
[workingKey]: {
|
||||
production: `${workingKey}-production`,
|
||||
[existingKey]: {
|
||||
production: `${existingKey}-production`,
|
||||
},
|
||||
[deployingKey]: {
|
||||
production: `${deployingKey}-production-new`,
|
||||
|
@ -228,7 +228,7 @@ describe('Test deploy custom JWT script', () => {
|
|||
);
|
||||
});
|
||||
|
||||
describe('Deploy script when both AccessToken & ClientCredentials scripts are not working', () => {
|
||||
describe('Deploy script when both AccessToken & ClientCredentials scripts are not existing', () => {
|
||||
it.each(Object.values(LogtoJwtTokenKey))('deploy %s script', (key) => {
|
||||
expect(
|
||||
deepmerge(
|
||||
|
@ -249,7 +249,7 @@ describe('Test deploy custom JWT script', () => {
|
|||
});
|
||||
|
||||
describe('Test undeploy custom JWT script', () => {
|
||||
describe('Undeploy script when both AccessToken & ClientCredentials scripts are working', () => {
|
||||
describe('Undeploy script when both AccessToken & ClientCredentials scripts are existing', () => {
|
||||
it.each(Object.values(LogtoJwtTokenKey))('undeploy %s script', (key) => {
|
||||
expect(
|
||||
deepmerge(
|
||||
|
@ -287,30 +287,30 @@ describe('Test undeploy custom JWT script', () => {
|
|||
describe('Undeploy script:', () => {
|
||||
// Test it.each() can not be nested, so we have to test each key separately.
|
||||
it.each(Object.values(LogtoJwtTokenKey))(
|
||||
`when ${LogtoJwtTokenKey.AccessToken} script is working, undeploy $s script`,
|
||||
`when ${LogtoJwtTokenKey.AccessToken} script is existing, undeploy $s script`,
|
||||
(undeployingKey) => {
|
||||
const workingKey = LogtoJwtTokenKey.AccessToken;
|
||||
const workingScript = {
|
||||
[workingKey]: {
|
||||
production: `${workingKey}-production`,
|
||||
const existingKey = LogtoJwtTokenKey.AccessToken;
|
||||
const existingScript = {
|
||||
[existingKey]: {
|
||||
production: `${existingKey}-production`,
|
||||
},
|
||||
};
|
||||
expect(
|
||||
deepmerge(workingScript, {
|
||||
deepmerge(existingScript, {
|
||||
[undeployingKey]: {
|
||||
production: undefined,
|
||||
},
|
||||
})
|
||||
).toEqual(
|
||||
workingKey === undeployingKey
|
||||
existingKey === undeployingKey
|
||||
? {
|
||||
[workingKey]: {
|
||||
[existingKey]: {
|
||||
production: undefined,
|
||||
},
|
||||
}
|
||||
: {
|
||||
[workingKey]: {
|
||||
production: `${workingKey}-production`,
|
||||
[existingKey]: {
|
||||
production: `${existingKey}-production`,
|
||||
},
|
||||
[undeployingKey]: {
|
||||
production: undefined,
|
||||
|
@ -321,30 +321,30 @@ describe('Test undeploy custom JWT script', () => {
|
|||
);
|
||||
|
||||
it.each(Object.values(LogtoJwtTokenKey))(
|
||||
`when ${LogtoJwtTokenKey.ClientCredentials} script is working, undeploy $s script`,
|
||||
`when ${LogtoJwtTokenKey.ClientCredentials} script is existing, undeploy $s script`,
|
||||
(undeployingKey) => {
|
||||
const workingKey = LogtoJwtTokenKey.ClientCredentials;
|
||||
const workingScript = {
|
||||
[workingKey]: {
|
||||
production: `${workingKey}-production`,
|
||||
const existingKey = LogtoJwtTokenKey.ClientCredentials;
|
||||
const existingScript = {
|
||||
[existingKey]: {
|
||||
production: `${existingKey}-production`,
|
||||
},
|
||||
};
|
||||
expect(
|
||||
deepmerge(workingScript, {
|
||||
deepmerge(existingScript, {
|
||||
[undeployingKey]: {
|
||||
production: undefined,
|
||||
},
|
||||
})
|
||||
).toEqual(
|
||||
workingKey === undeployingKey
|
||||
existingKey === undeployingKey
|
||||
? {
|
||||
[workingKey]: {
|
||||
[existingKey]: {
|
||||
production: undefined,
|
||||
},
|
||||
}
|
||||
: {
|
||||
[workingKey]: {
|
||||
production: `${workingKey}-production`,
|
||||
[existingKey]: {
|
||||
production: `${existingKey}-production`,
|
||||
},
|
||||
[undeployingKey]: {
|
||||
production: undefined,
|
||||
|
|
Loading…
Add table
Reference in a new issue