/
build.impl.spec.ts
41 lines (34 loc) · 1.07 KB
/
build.impl.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import { MockBuilderContext } from '@nrwl/workspace/testing';
import * as build from 'next/dist/build';
import { getMockContext } from '../../utils/testing';
import { NextBuildBuilderOptions } from '../../utils/types';
import { run } from './build.impl';
jest.mock('next/dist/build');
describe('Next.js Builder', () => {
let context: MockBuilderContext;
let options: NextBuildBuilderOptions;
beforeEach(async () => {
context = await getMockContext();
options = {
root: 'apps/wibble',
outputPath: 'dist/apps/wibble',
fileReplacements: [
{
replace: 'apps/wibble/src/environment.ts',
with: 'apps/wibble/src/environment.prod.ts'
}
]
};
jest.spyOn(build, 'default').mockReturnValue(Promise.resolve());
});
it('should call next build', async () => {
await run(options, context).toPromise();
expect(build.default).toHaveBeenCalledWith(
'/root/apps/wibble',
expect.objectContaining({
distDir: '../../dist/apps/wibble',
outdir: '../../dist/apps/wibble'
})
);
});
});