Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

spec: rewrite #76

Merged
merged 1 commit into from
Jan 16, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
203 changes: 135 additions & 68 deletions specs/define-config.spec.ts
Original file line number Diff line number Diff line change
@@ -1,76 +1,143 @@
import { describe, expect, test as spec } from 'bun:test';
import type { NextConfig } from 'next';

import { defineConfig } from '#src/index.ts';

describe('Next Config', async () => {
spec('should return empty config', async () => {
expect(defineConfig({}));
describe('Next Config', () => {
spec('should return empty config', () => {
const config = defineConfig({});

expect(config).toMatchObject({});
expect(config satisfies NextConfig).toBeDefined();
});

spec('should return config', async () => {
expect(
defineConfig({
amp: {
canonicalBase: '',
},
assetPrefix: '',
basePath: '',
cacheMaxMemorySize: 1200,
cacheHandler: '',
cleanDistDir: true,
compress: true,
devIndicators: {
buildActivity: true,
buildActivityPosition: 'bottom-right',
},
deploymentId: '',
distDir: '',
eslint: {
dirs: [''],
ignoreDuringBuilds: true,
},
env: {},
excludeDefaultMomentLocales: true,
generateEtags: false,
i18n: {
defaultLocale: '',
domains: [{ defaultLocale: '', domain: '', http: true, locales: [''] }],
localeDetection: false,
locales: [],
},
images: {
contentDispositionType: 'attachment',
contentSecurityPolicy: '',
dangerouslyAllowSVG: false,
deviceSizes: [500, 500],
disableStaticImages: false,
formats: ['image/webp', 'image/avif'],
imageSizes: [500, 500],
loader: 'akamai',
loaderFile: '',
minimumCacheTTL: 100,
path: '',
remotePatterns: [
{
protocol: 'https',
hostname: '',
port: '',
pathname: '',
},
],
unoptimized: false,
},
onDemandEntries: {
maxInactiveAge: 100,
pagesBufferLength: 100,
},
pageExtensions: [''],
poweredByHeader: false,
trailingSlash: true,
typescript: { ignoreBuildErrors: false, tsconfigPath: '' },
sassOptions: {},
useFileSystemPublicRoutes: true,
}),
);
spec('should return config with all properties', () => {
const config = defineConfig({
amp: {
canonicalBase: '',
},
assetPrefix: '',
basePath: '',
cacheMaxMemorySize: 1200,
cacheHandler: '',
cleanDistDir: true,
compress: true,
devIndicators: {
buildActivity: true,
buildActivityPosition: 'bottom-right',
},
deploymentId: '',
distDir: '',
eslint: {
dirs: [''],
ignoreDuringBuilds: true,
},
env: {},
excludeDefaultMomentLocales: true,
generateEtags: false,
i18n: {
defaultLocale: '',
domains: [{ defaultLocale: '', domain: '', http: true, locales: [''] }],
localeDetection: false,
locales: [],
},
images: {
contentDispositionType: 'attachment',
contentSecurityPolicy: '',
dangerouslyAllowSVG: false,
deviceSizes: [500, 500],
disableStaticImages: false,
formats: ['image/webp', 'image/avif'],
imageSizes: [500, 500],
loader: 'akamai',
loaderFile: '',
minimumCacheTTL: 100,
path: '',
remotePatterns: [
{
protocol: 'https',
hostname: '',
port: '',
pathname: '',
},
],
unoptimized: false,
},
onDemandEntries: {
maxInactiveAge: 100,
pagesBufferLength: 100,
},
pageExtensions: [''],
poweredByHeader: false,
trailingSlash: true,
typescript: { ignoreBuildErrors: false, tsconfigPath: '' },
sassOptions: {},
useFileSystemPublicRoutes: true,
});

expect(config).toMatchObject({
amp: {
canonicalBase: '',
},
assetPrefix: '',
basePath: '',
cacheMaxMemorySize: 1200,
cacheHandler: '',
cleanDistDir: true,
compress: true,
devIndicators: {
buildActivity: true,
buildActivityPosition: 'bottom-right',
},
deploymentId: '',
distDir: '',
eslint: {
dirs: [''],
ignoreDuringBuilds: true,
},
env: {},
excludeDefaultMomentLocales: true,
generateEtags: false,
i18n: {
defaultLocale: '',
domains: [{ defaultLocale: '', domain: '', http: true, locales: [''] }],
localeDetection: false,
locales: [],
},
images: {
contentDispositionType: 'attachment',
contentSecurityPolicy: '',
dangerouslyAllowSVG: false,
deviceSizes: [500, 500],
disableStaticImages: false,
formats: ['image/webp', 'image/avif'],
imageSizes: [500, 500],
loader: 'akamai',
loaderFile: '',
minimumCacheTTL: 100,
path: '',
remotePatterns: [
{
protocol: 'https',
hostname: '',
port: '',
pathname: '',
},
],
unoptimized: false,
},
onDemandEntries: {
maxInactiveAge: 100,
pagesBufferLength: 100,
},
pageExtensions: [''],
poweredByHeader: false,
trailingSlash: true,
typescript: { ignoreBuildErrors: false, tsconfigPath: '' },
sassOptions: {},
useFileSystemPublicRoutes: true,
});

expect(config satisfies NextConfig).toBeDefined();
});
});
Loading