Skip to content

Commit

Permalink
spec: rewrite (#76)
Browse files Browse the repository at this point in the history
Co-authored-by: nikkeyl <[email protected]>
  • Loading branch information
github-actions[bot] and nikkeyl authored Jan 16, 2025
1 parent 9dac033 commit 70bf547
Showing 1 changed file with 135 additions and 68 deletions.
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();
});
});

0 comments on commit 70bf547

Please sign in to comment.