This repository has been archived on 2026-04-30. You can view files and clone it, but cannot push or open issues or pull requests.
next-deploy/packages/lambda-at-edge/tests/public-and-static-dir/public-and-static-dir.test.ts
2020-07-05 16:56:57 -07:00

41 lines
1.3 KiB
TypeScript

import execa from 'execa';
import Builder from '../../src/build';
import fse, { readJSON } from 'fs-extra';
import { join } from 'path';
import { DEFAULT_LAMBDA_CODE_DIR } from '../../src/build';
import { cleanupDir } from '../test-utils';
import { OriginRequestDefaultHandlerManifest } from '../../types';
jest.mock('execa');
describe('When public and static directories do not exist', () => {
let defaultBuildManifest: OriginRequestDefaultHandlerManifest;
let fseRemoveSpy: jest.SpyInstance;
const fixturePath = join(__dirname, './app-with-no-static-or-public-dir-fixture');
const outputDir = join(fixturePath, '.test_sls_next_output');
beforeEach(async () => {
const mockExeca = execa as jest.Mock;
mockExeca.mockResolvedValueOnce();
fseRemoveSpy = jest.spyOn(fse, 'remove').mockImplementation(() => {
return;
});
const builder = new Builder(fixturePath, outputDir);
await builder.build();
defaultBuildManifest = await readJSON(
join(outputDir, `${DEFAULT_LAMBDA_CODE_DIR}/manifest.json`)
);
});
afterEach(() => {
fseRemoveSpy.mockRestore();
return cleanupDir(outputDir);
});
it('does not put any public files in the build manifest', async () => {
expect(defaultBuildManifest.publicFiles).toEqual({});
});
});