test: clear mocks

Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
CrazyMax 2023-01-24 00:44:31 +01:00
parent 251b9d49f3
commit 66653922b3
No known key found for this signature in database
GPG Key ID: 3248E46B6BB8C7F7
7 changed files with 35 additions and 7 deletions

View File

@ -1,8 +1,12 @@
import {describe, expect, it, test} from '@jest/globals';
import {jest, describe, expect, it, test, beforeEach} from '@jest/globals';
import * as fs from 'fs';
import * as path from 'path';
import {Builder} from '../src/builder';
beforeEach(() => {
jest.clearAllMocks();
});
describe('inspect', () => {
it('valid', async () => {
const builder = new Builder();

View File

@ -1,4 +1,4 @@
import {afterEach, describe, expect, it, jest, test} from '@jest/globals';
import {afterEach, beforeEach, describe, expect, it, jest, test} from '@jest/globals';
import * as fs from 'fs';
import * as path from 'path';
import * as semver from 'semver';
@ -21,6 +21,10 @@ jest.spyOn(BuildKit.prototype as any, 'tmpName').mockImplementation((): string =
return tmpName;
});
beforeEach(() => {
jest.clearAllMocks();
});
afterEach(() => {
rimraf.sync(tmpDir);
});

View File

@ -1,4 +1,4 @@
import {afterEach, describe, expect, it, jest, test} from '@jest/globals';
import {afterEach, beforeEach, describe, expect, it, jest, test} from '@jest/globals';
import * as fs from 'fs';
import * as path from 'path';
import * as semver from 'semver';
@ -21,6 +21,10 @@ jest.spyOn(Buildx.prototype as any, 'tmpDir').mockImplementation((): string => {
return tmpDir;
});
beforeEach(() => {
jest.clearAllMocks();
});
afterEach(() => {
rimraf.sync(tmpDir);
});

View File

@ -1,8 +1,12 @@
import {describe, expect, it, jest} from '@jest/globals';
import {beforeEach, describe, expect, it, jest} from '@jest/globals';
import * as exec from '@actions/exec';
import {Docker} from '../src/docker';
beforeEach(() => {
jest.clearAllMocks();
});
describe('isAvailable', () => {
it('cli', () => {
const execSpy = jest.spyOn(exec, 'getExecOutput');

View File

@ -1,6 +1,10 @@
import {describe, expect, it} from '@jest/globals';
import {beforeEach, describe, expect, it, jest} from '@jest/globals';
import * as git from '../src/git';
beforeEach(() => {
jest.clearAllMocks();
});
describe('git', () => {
it('returns git remote ref', async () => {
const ref: string = await git.getRemoteSha('https://github.com/docker/buildx.git', 'refs/pull/648/head');

View File

@ -1,8 +1,12 @@
import {describe, expect, jest, it} from '@jest/globals';
import {describe, expect, jest, it, beforeEach} from '@jest/globals';
import {Context} from '@actions/github/lib/context';
import {GitHub, Payload, ReposGetResponseData} from '../src/github';
beforeEach(() => {
jest.clearAllMocks();
});
jest.spyOn(GitHub.prototype, 'context').mockImplementation((): Context => {
return new Context();
});

View File

@ -1,9 +1,13 @@
import {describe, expect, it, test} from '@jest/globals';
import {beforeEach, describe, expect, it, jest, test} from '@jest/globals';
import * as fs from 'fs';
import * as path from 'path';
import {Util} from '../src/util';
beforeEach(() => {
jest.clearAllMocks();
});
describe('getInputList', () => {
it('single line correctly', async () => {
await setInput('foo', 'bar');