Skip to content

Commit 1316b77

Browse files
committed
chore: update tests
1 parent 55e13ab commit 1316b77

File tree

5 files changed

+33
-242
lines changed

5 files changed

+33
-242
lines changed

src/lib/functions/index.js

Lines changed: 0 additions & 209 deletions
This file was deleted.

src/tests/configurableDirs.test.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,13 @@ describe('next-on-netlify', () => {
4545
})
4646

4747
test('creates a Netlify Function for each SSR page', () => {
48-
expect(existsSync(join(functionsDir, 'next_index', 'next_index.js'))).toBe(true)
49-
expect(existsSync(join(functionsDir, 'next_shows_id', 'next_shows_id.js'))).toBe(true)
50-
expect(existsSync(join(functionsDir, 'next_shows_params', 'next_shows_params.js'))).toBe(true)
51-
expect(existsSync(join(functionsDir, 'next_getServerSideProps_static', 'next_getServerSideProps_static.js'))).toBe(
48+
expect(existsSync(join(functionsDir, 'next_index', 'next_index.ts'))).toBe(true)
49+
expect(existsSync(join(functionsDir, 'next_shows_id', 'next_shows_id.ts'))).toBe(true)
50+
expect(existsSync(join(functionsDir, 'next_shows_params', 'next_shows_params.ts'))).toBe(true)
51+
expect(existsSync(join(functionsDir, 'next_getServerSideProps_static', 'next_getServerSideProps_static.ts'))).toBe(
5252
true,
5353
)
54-
expect(existsSync(join(functionsDir, 'next_getServerSideProps_id', 'next_getServerSideProps_id.js'))).toBe(true)
54+
expect(existsSync(join(functionsDir, 'next_getServerSideProps_id', 'next_getServerSideProps_id.ts'))).toBe(true)
5555
})
5656

5757
test('copies static pages to output directory', () => {

src/tests/defaults.test.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -61,27 +61,27 @@ describe('SSR Pages', () => {
6161
const functionsDir = join(PROJECT_PATH, 'out_functions')
6262

6363
test('creates a Netlify Function for each SSR page', () => {
64-
expect(existsSync(join(functionsDir, 'next_index', 'next_index.js'))).toBe(true)
65-
expect(existsSync(join(functionsDir, 'next_shows_id', 'next_shows_id.js'))).toBe(true)
66-
expect(existsSync(join(functionsDir, 'next_shows_params', 'next_shows_params.js'))).toBe(true)
67-
expect(existsSync(join(functionsDir, 'next_getServerSideProps_static', 'next_getServerSideProps_static.js'))).toBe(
64+
expect(existsSync(join(functionsDir, 'next_index', 'next_index.ts'))).toBe(true)
65+
expect(existsSync(join(functionsDir, 'next_shows_id', 'next_shows_id.ts'))).toBe(true)
66+
expect(existsSync(join(functionsDir, 'next_shows_params', 'next_shows_params.ts'))).toBe(true)
67+
expect(existsSync(join(functionsDir, 'next_getServerSideProps_static', 'next_getServerSideProps_static.ts'))).toBe(
6868
true,
6969
)
70-
expect(existsSync(join(functionsDir, 'next_getServerSideProps_id', 'next_getServerSideProps_id.js'))).toBe(true)
7170
expect(
7271
readFileSync(join(functionsDir, 'next_getServerSideProps_id', 'nextPage', 'index.js'), 'utf-8'),
7372
).toBe(`module.exports = require("./pages/getServerSideProps/[id].js")`)
73+
expect(existsSync(join(functionsDir, 'next_getServerSideProps_id', 'next_getServerSideProps_id.ts'))).toBe(true)
7474
})
7575
})
7676

7777
describe('API Pages', () => {
7878
const functionsDir = join(PROJECT_PATH, 'out_functions')
7979

8080
test('creates a Netlify Function for each API endpoint', () => {
81-
expect(existsSync(join(functionsDir, 'next_api_static', 'next_api_static.js'))).toBe(true)
82-
expect(existsSync(join(functionsDir, 'next_api_shows_id', 'next_api_shows_id.js'))).toBe(true)
83-
expect(existsSync(join(functionsDir, 'next_api_shows_params', 'next_api_shows_params.js'))).toBe(true)
84-
expect(existsSync(join(functionsDir, 'next_api_hello-background', 'next_api_hello-background.js'))).toBe(true)
81+
expect(existsSync(join(functionsDir, 'next_api_static', 'next_api_static.ts'))).toBe(true)
82+
expect(existsSync(join(functionsDir, 'next_api_shows_id', 'next_api_shows_id.ts'))).toBe(true)
83+
expect(existsSync(join(functionsDir, 'next_api_shows_params', 'next_api_shows_params.ts'))).toBe(true)
84+
expect(existsSync(join(functionsDir, 'next_api_hello-background', 'next_api_hello-background.ts'))).toBe(true)
8585
})
8686
})
8787

@@ -127,10 +127,10 @@ describe('SSG Pages with getStaticProps', () => {
127127
})
128128

129129
test('creates Netlify Functions for pages with fallback', () => {
130-
const functionPath1 = 'next_getStaticProps_withFallback_id/next_getStaticProps_withFallback_id.js'
130+
const functionPath1 = 'next_getStaticProps_withFallback_id/next_getStaticProps_withFallback_id.ts'
131131
expect(existsSync(join(PROJECT_PATH, 'out_functions', functionPath1))).toBe(true)
132132

133-
const functionPath2 = 'next_getStaticProps_withFallback_slug/next_getStaticProps_withFallback_slug.js'
133+
const functionPath2 = 'next_getStaticProps_withFallback_slug/next_getStaticProps_withFallback_slug.ts'
134134
expect(existsSync(join(PROJECT_PATH, 'out_functions', functionPath2))).toBe(true)
135135
})
136136
})
@@ -140,19 +140,19 @@ describe('SSG Pages with getStaticProps and revalidate', () => {
140140

141141
test('creates a Netlify Function for each page', () => {
142142
expect(
143-
existsSync(join(functionsDir, 'next_getStaticProps_withrevalidate', 'next_getStaticProps_withrevalidate.js')),
143+
existsSync(join(functionsDir, 'next_getStaticProps_withrevalidate', 'next_getStaticProps_withrevalidate.ts')),
144144
).toBe(true)
145145
expect(
146146
existsSync(
147-
join(functionsDir, 'next_getStaticProps_withRevalidate_id', 'next_getStaticProps_withRevalidate_id.js'),
147+
join(functionsDir, 'next_getStaticProps_withRevalidate_id', 'next_getStaticProps_withRevalidate_id.ts'),
148148
),
149149
).toBe(true)
150150
expect(
151151
existsSync(
152152
join(
153153
functionsDir,
154154
'next_getStaticProps_withRevalidate_withFallback_id',
155-
'next_getStaticProps_withRevalidate_withFallback_id.js',
155+
'next_getStaticProps_withRevalidate_withFallback_id.ts',
156156
),
157157
),
158158
).toBe(true)

src/tests/i18n.test.js

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -61,23 +61,23 @@ describe('SSR Pages', () => {
6161
const functionsDir = join(PROJECT_PATH, 'out_functions')
6262

6363
test('creates a Netlify Function for each SSR page', () => {
64-
expect(existsSync(join(functionsDir, 'next_index', 'next_index.js'))).toBe(true)
65-
expect(existsSync(join(functionsDir, 'next_shows_id', 'next_shows_id.js'))).toBe(true)
66-
expect(existsSync(join(functionsDir, 'next_shows_params', 'next_shows_params.js'))).toBe(true)
67-
expect(existsSync(join(functionsDir, 'next_getServerSideProps_static', 'next_getServerSideProps_static.js'))).toBe(
64+
expect(existsSync(join(functionsDir, 'next_index', 'next_index.ts'))).toBe(true)
65+
expect(existsSync(join(functionsDir, 'next_shows_id', 'next_shows_id.ts'))).toBe(true)
66+
expect(existsSync(join(functionsDir, 'next_shows_params', 'next_shows_params.ts'))).toBe(true)
67+
expect(existsSync(join(functionsDir, 'next_getServerSideProps_static', 'next_getServerSideProps_static.ts'))).toBe(
6868
true,
6969
)
70-
expect(existsSync(join(functionsDir, 'next_getServerSideProps_id', 'next_getServerSideProps_id.js'))).toBe(true)
70+
expect(existsSync(join(functionsDir, 'next_getServerSideProps_id', 'next_getServerSideProps_id.ts'))).toBe(true)
7171
})
7272
})
7373

7474
describe('API Pages', () => {
7575
const functionsDir = join(PROJECT_PATH, 'out_functions')
7676

7777
test('creates a Netlify Function for each API endpoint', () => {
78-
expect(existsSync(join(functionsDir, 'next_api_static', 'next_api_static.js'))).toBe(true)
79-
expect(existsSync(join(functionsDir, 'next_api_shows_id', 'next_api_shows_id.js'))).toBe(true)
80-
expect(existsSync(join(functionsDir, 'next_api_shows_params', 'next_api_shows_params.js'))).toBe(true)
78+
expect(existsSync(join(functionsDir, 'next_api_static', 'next_api_static.ts'))).toBe(true)
79+
expect(existsSync(join(functionsDir, 'next_api_shows_id', 'next_api_shows_id.ts'))).toBe(true)
80+
expect(existsSync(join(functionsDir, 'next_api_shows_params', 'next_api_shows_params.ts'))).toBe(true)
8181
})
8282
})
8383

@@ -110,10 +110,10 @@ describe('SSG Pages with getStaticProps', () => {
110110
})
111111

112112
test('creates Netlify Functions for pages with fallback', () => {
113-
const functionPath1 = 'next_getStaticProps_withFallback_id/next_getStaticProps_withFallback_id.js'
113+
const functionPath1 = 'next_getStaticProps_withFallback_id/next_getStaticProps_withFallback_id.ts'
114114
expect(existsSync(join(PROJECT_PATH, 'out_functions', functionPath1))).toBe(true)
115115

116-
const functionPath2 = 'next_getStaticProps_withFallback_slug/next_getStaticProps_withFallback_slug.js'
116+
const functionPath2 = 'next_getStaticProps_withFallback_slug/next_getStaticProps_withFallback_slug.ts'
117117
expect(existsSync(join(PROJECT_PATH, 'out_functions', functionPath2))).toBe(true)
118118
})
119119
})
@@ -123,19 +123,19 @@ describe('SSG Pages with getStaticProps and revalidate', () => {
123123

124124
test('creates a Netlify Function for each page', () => {
125125
expect(
126-
existsSync(join(functionsDir, 'next_getStaticProps_withrevalidate', 'next_getStaticProps_withrevalidate.js')),
126+
existsSync(join(functionsDir, 'next_getStaticProps_withrevalidate', 'next_getStaticProps_withrevalidate.ts')),
127127
).toBe(true)
128128
expect(
129129
existsSync(
130-
join(functionsDir, 'next_getStaticProps_withRevalidate_id', 'next_getStaticProps_withRevalidate_id.js'),
130+
join(functionsDir, 'next_getStaticProps_withRevalidate_id', 'next_getStaticProps_withRevalidate_id.ts'),
131131
),
132132
).toBe(true)
133133
expect(
134134
existsSync(
135135
join(
136136
functionsDir,
137137
'next_getStaticProps_withRevalidate_withFallback_id',
138-
'next_getStaticProps_withRevalidate_withFallback_id.js',
138+
'next_getStaticProps_withRevalidate_withFallback_id.ts',
139139
),
140140
),
141141
).toBe(true)

test/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ describe('onBuild()', () => {
287287
utils,
288288
})
289289

290-
expect(await pathExists(`${resolvedFunctions}/next_api_test/next_api_test.js`)).toBeTruthy()
290+
expect(await pathExists(`${resolvedFunctions}/next_api_test/next_api_test.ts`)).toBeTruthy()
291291
})
292292
})
293293

0 commit comments

Comments
 (0)