Skip to content

Commit ed3ea9b

Browse files
author
naman-contentstack
committed
update test cases
1 parent eedccf3 commit ed3ea9b

File tree

1 file changed

+27
-19
lines changed

1 file changed

+27
-19
lines changed

packages/contentstack-audit/test/unit/audit-base-command.test.ts

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ describe('AuditBaseCommand class', () => {
3131

3232
class AuditFixCMD extends AuditBaseCommand {
3333
async run() {
34+
await this.init();
3435
await this.start('cm:stacks:audit:fix');
3536
}
3637
}
@@ -40,11 +41,11 @@ describe('AuditBaseCommand class', () => {
4041
} as FileTransportInstance;
4142

4243
const createMockWinstonLogger = () => ({
43-
log: (message: string) => console.log(message),
44-
error: (message: string) => console.error(`ERROR: ${message}`),
45-
info: (message: string) => console.info(`INFO: ${message}`),
46-
warn: (message: string) => console.warn(`WARN: ${message}`),
47-
debug: (message: string) => console.debug(`DEBUG: ${message}`),
44+
log: (message: string) => process.stdout.write(message + '\n'),
45+
error: (message: string) => process.stdout.write(`ERROR: ${message}\n`),
46+
info: (message: string) => process.stdout.write(`INFO: ${message}\n`),
47+
warn: (message: string) => process.stdout.write(`WARN: ${message}\n`),
48+
debug: (message: string) => process.stdout.write(`DEBUG: ${message}\n`),
4849
level: 'info'
4950
});
5051

@@ -144,22 +145,29 @@ describe('AuditBaseCommand class', () => {
144145
.stub(AuditBaseCommand.prototype, 'showOutputOnScreenWorkflowsAndExtension', () => {})
145146
.stub(ux.action, 'stop', () => {})
146147
.stub(ux.action, 'start', () => {})
147-
.stub(Entries.prototype, 'run', () => ({
148-
entry_1: {
149-
name: 'T1',
150-
display_name: 'T1',
151-
data_type: 'reference',
152-
missingRefs: ['gf_0'],
153-
treeStr: 'T1 -> gf_0',
148+
.stub(AuditBaseCommand.prototype, 'scanAndFix', () => ({
149+
missingCtRefs: { ct_1: {} },
150+
missingGfRefs: { gf_1: {} },
151+
missingEntryRefs: {
152+
entry_1: {
153+
name: 'T1',
154+
display_name: 'T1',
155+
data_type: 'reference',
156+
missingRefs: ['gf_0'],
157+
treeStr: 'T1 -> gf_0',
158+
},
154159
},
160+
missingCtRefsInExtensions: {},
161+
missingCtRefsInWorkflow: {},
162+
missingSelectFeild: {},
163+
missingMandatoryFields: {},
164+
missingTitleFields: {},
165+
missingRefInCustomRoles: {},
166+
missingEnvLocalesInAssets: {},
167+
missingEnvLocalesInEntries: {},
168+
missingFieldRules: {},
169+
missingMultipleFields: {}
155170
}))
156-
.stub(ContentType.prototype, 'run', () => ({ ct_1: {} }))
157-
.stub(GlobalField.prototype, 'run', () => ({ gf_1: {} }))
158-
.stub(Workflows.prototype, 'run', () => ({ wf_1: {} }))
159-
.stub(Extensions.prototype, 'run', () => ({ ext_1: {} }))
160-
.stub(CustomRoles.prototype, 'run', () => ({ ext_1: {} }))
161-
.stub(Assets.prototype, 'run', () => ({ ext_1: {} }))
162-
.stub(FieldRule.prototype, 'run', () => ({ ext_1: {} }))
163171
.stub(fs, 'createBackUp', () => {})
164172
.stub(fs, 'createWriteStream', () => new PassThrough())
165173
.stub(AuditBaseCommand.prototype, 'createBackUp', () => {})

0 commit comments

Comments
 (0)