Skip to content

Commit

Permalink
chore: reset mocks to original implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
lili2311 committed Oct 19, 2022
1 parent 499fd49 commit 71a2f84
Show file tree
Hide file tree
Showing 15 changed files with 23 additions and 21 deletions.
7 changes: 4 additions & 3 deletions test/lib/api/feature-flags/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ describe('getFeatureFlag', () => {
userAgentPrefix: 'snyk-api-import:tests',
maxRetryCount: 1,
});
afterAll(async () => {
jest.resetAllMocks();
}, 1000);
afterAll(() => {
jest.restoreAllMocks();
});


it('get feature flag for org - mock', async () => {
jest.spyOn(requestManager, 'request').mockResolvedValueOnce({
Expand Down
2 changes: 1 addition & 1 deletion test/lib/api/project/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ describe('UpdateProject', () => {
process.env.SNYK_TOKEN = process.env.SNYK_TOKEN_TEST;
});
afterAll(() => {
jest.resetAllMocks();
jest.restoreAllMocks();
process.env = { ...OLD_ENV };
}, 1000);

Expand Down
2 changes: 1 addition & 1 deletion test/lib/import-projects.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ describe('importTarget()', () => {
const requestManager = new requestsManager({
userAgentPrefix: 'snyk-api-import:tests',
});
afterAll(async () => {
afterAll(() => {
process.env = { ...OLD_ENV };
});
it('Target is always sanitized', async () => {
Expand Down
7 changes: 4 additions & 3 deletions test/lib/org.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,10 @@ describe('listTargets', () => {
const requestManager = new requestsManager({
userAgentPrefix: 'snyk-api-import:tests',
});
afterAll(async () => {
jest.resetAllMocks();
}, 1000);
afterAll(() => {
jest.restoreAllMocks();
});


it('list the targets in a given Org without pagination - mock', async () => {
jest.spyOn(requestManager, 'request').mockResolvedValue({
Expand Down
2 changes: 1 addition & 1 deletion test/lib/orgs.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe('Orgs API', () => {
const requestManager = new requestsManager({
userAgentPrefix: 'snyk-api-import:tests',
});
afterAll(async () => {
afterAll(() => {
process.env = { ...OLD_ENV };
});

Expand Down
6 changes: 3 additions & 3 deletions test/scripts/generate-org-data.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ describe('generateOrgImportDataFile Github script', () => {
__dirname + '/group-groupIdExample-github.aaakk.us.kg-orgs.json',
__dirname + '/group-groupIdExample-github-enterprise-orgs.json',
];
afterAll(async () => {
afterAll(() => {
process.env = { ...OLD_ENV };
});

Expand Down Expand Up @@ -142,7 +142,7 @@ describe('generateOrgImportDataFile Gitlab script', () => {
const filesToCleanup: string[] = [
__dirname + '/group-groupIdExample-gitlab-orgs.json',
];
afterAll(async () => {
afterAll(() => {
process.env = { ...OLD_ENV };
});

Expand Down Expand Up @@ -233,7 +233,7 @@ describe('generateOrgImportDataFile Bitbucket Cloud script', () => {
const filesToCleanup: string[] = [
__dirname + '/group-groupIdExample-bitbucket-cloud-orgs.json',
];
afterAll(async () => {
afterAll(() => {
process.env = { ...OLD_ENV };
});

Expand Down
2 changes: 1 addition & 1 deletion test/system/help.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ describe('`snyk-api-import help <...>`', () => {
process.env.SNYK_API = process.env.SNYK_API_TEST;
process.env.SNYK_TOKEN = process.env.SNYK_TOKEN_TEST;

afterAll(async () => {
afterAll(() => {
process.env = { ...OLD_ENV };
});
it('Shows help text as expected', (done) => {
Expand Down
2 changes: 1 addition & 1 deletion test/system/import:data.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const main = './dist/index.js'.replace(/\//g, sep);

describe('`snyk-api-import import:data <...>`', () => {
const OLD_ENV = process.env;
afterAll(async () => {
afterAll(() => {
process.env = { ...OLD_ENV };
});
it('Shows help text as expected', (done) => {
Expand Down
2 changes: 1 addition & 1 deletion test/system/list:imported.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ describe('`snyk-api-import list:imported <...>`', () => {
const GROUP_ID = process.env.TEST_GROUP_ID as string;
const ORG_ID = process.env.TEST_ORG_ID as string;

afterAll(async () => {
afterAll(() => {
process.env = { ...OLD_ENV };
});
it('Shows help text as expected', (done) => {
Expand Down
2 changes: 1 addition & 1 deletion test/system/orgs:create.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ describe('`snyk-api-import help <...>`', () => {
const OLD_ENV = process.env;
const GROUP_ID = process.env.TEST_GROUP_ID as string;

afterAll(async () => {
afterAll(() => {
process.env = { ...OLD_ENV };
});
it('Shows help text as expected', (done) => {
Expand Down
2 changes: 1 addition & 1 deletion test/system/orgs:data/bitbucket.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const main = './dist/index.js'.replace(/\//g, path.sep);

describe('General `snyk-api-import orgs:data <...>`', () => {
const OLD_ENV = process.env;
afterAll(async () => {
afterAll(() => {
process.env = { ...OLD_ENV };
});
it('Generates orgs data as expected for Bitbucket Server', (done) => {
Expand Down
2 changes: 1 addition & 1 deletion test/system/orgs:data/errors.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const main = './dist/index.js'.replace(/\//g, path.sep);

describe('General `snyk-api-import orgs:data <...>`', () => {
const OLD_ENV = process.env;
afterAll(async () => {
afterAll(() => {
process.env = { ...OLD_ENV };
});
it('Shows error when missing groupId', (done) => {
Expand Down
2 changes: 1 addition & 1 deletion test/system/orgs:data/generic.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const main = './dist/index.js'.replace(/\//g, path.sep);

describe('General `snyk-api-import orgs:data <...>`', () => {
const OLD_ENV = process.env;
afterAll(async () => {
afterAll(() => {
process.env = { ...OLD_ENV };
});
it('Shows help text as expected', (done) => {
Expand Down
2 changes: 1 addition & 1 deletion test/system/orgs:data/github.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const main = './dist/index.js'.replace(/\//g, path.sep);

describe('General `snyk-api-import orgs:data <...>`', () => {
const OLD_ENV = process.env;
afterAll(async () => {
afterAll(() => {
process.env = { ...OLD_ENV };
});
it('Generates orgs data as expected', (done) => {
Expand Down
2 changes: 1 addition & 1 deletion test/system/orgs:data/gitlab.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const main = './dist/index.js'.replace(/\//g, path.sep);

describe('General `snyk-api-import orgs:data <...>`', () => {
const OLD_ENV = process.env;
afterAll(async () => {
afterAll(() => {
process.env = { ...OLD_ENV };
});
it('Generates orgs data as expected for Gitlab', (done) => {
Expand Down

0 comments on commit 71a2f84

Please sign in to comment.