Skip to content

Commit 8b2b1a4

Browse files
chore: update jest to 30.x
1 parent 827163c commit 8b2b1a4

File tree

3 files changed

+2416
-2877
lines changed

3 files changed

+2416
-2877
lines changed

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
"@uirouter/core": ">=5.0.0"
4848
},
4949
"devDependencies": {
50-
"@types/jest": "^26.0.14",
50+
"@types/jest": "^30.0.0",
5151
"@types/jquery": "^3.3.38",
5252
"@types/lodash": "^4.14.152",
5353
"@typescript-eslint/eslint-plugin": "^4.1.1",
@@ -58,15 +58,16 @@
5858
"eslint-config-prettier": "^6.11.0",
5959
"eslint-plugin-prettier": "^3.1.4",
6060
"husky": "^4.2.5",
61-
"jest": "^26.4.2",
61+
"jest": "^30.2.0",
62+
"jest-environment-jsdom": "^30.2.0",
6263
"lodash": "^4.17.11",
6364
"prettier": "^2.0.5",
6465
"pretty-quick": "^2.0.1",
6566
"rollup": "^2.10.9",
6667
"rollup-plugin-node-resolve": "^5.2.0",
6768
"rollup-plugin-sourcemaps": "^0.6.2",
6869
"rollup-plugin-uglify": "^6.0.1",
69-
"ts-jest": "^26.4.0",
70+
"ts-jest": "^29.4.6",
7071
"typescript": "^5.9.3"
7172
},
7273
"husky": {

test/deepStateRedirectSpec.ts

Lines changed: 18 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ let $deepStateRedirect = undefined;
6565
let testGo = undefined;
6666

6767
describe('deepStateRedirect', function () {
68-
beforeEach(async function (done) {
68+
beforeEach(async function () {
6969
router = new UIRouter();
7070
router.plugin(servicesPlugin);
7171
router.plugin(memoryLocationPlugin);
@@ -79,20 +79,16 @@ describe('deepStateRedirect', function () {
7979
const newStates = getDSRStates();
8080
dsrReset(newStates);
8181
newStates.forEach((state) => router.stateRegistry.register(state));
82-
83-
done();
8482
});
8583

8684
describe(' - ', function () {
87-
it('should toggle between tab states', async function (done) {
85+
it('should toggle between tab states', async function () {
8886
await testGo('tabs', { entered: 'tabs' });
8987
await testGo('tabs.tabs2', { entered: 'tabs.tabs2' });
9088
await testGo('tabs.tabs1', { entered: 'tabs.tabs1', exited: 'tabs.tabs2' });
91-
92-
done();
9389
});
9490

95-
it('should redirect to tabs.tabs1.deep.nest', async function (done) {
91+
it('should redirect to tabs.tabs1.deep.nest', async function () {
9692
await testGo('tabs', { entered: 'tabs' });
9793
await testGo('tabs.tabs2.deep.nest', { entered: ['tabs.tabs2', 'tabs.tabs2.deep', 'tabs.tabs2.deep.nest'] });
9894
await testGo('tabs.tabs1', {
@@ -107,11 +103,9 @@ describe('deepStateRedirect', function () {
107103
},
108104
{ redirect: 'tabs.tabs2.deep.nest' }
109105
);
110-
111-
done();
112106
});
113107

114-
it('should forget a previous redirect to tabs.tabs2.deep.nest', async function (done) {
108+
it('should forget a previous redirect to tabs.tabs2.deep.nest', async function () {
115109
await testGo('tabs', { entered: 'tabs' });
116110
await testGo('tabs.tabs2.deep.nest', { entered: ['tabs.tabs2', 'tabs.tabs2.deep', 'tabs.tabs2.deep.nest'] });
117111
await testGo('tabs.tabs1.deep.nest', {
@@ -157,23 +151,19 @@ describe('deepStateRedirect', function () {
157151
exited: ['tabs.tabs1.deep.nest', 'tabs.tabs1.deep', 'tabs.tabs1'],
158152
});
159153
await testGo('tabs.tabs1', { entered: 'tabs.tabs1', exited: ['tabs.tabs2'] });
160-
161-
done();
162154
});
163155
});
164156

165157
describe('with child substates configured using {parent: parentState}', function () {
166-
it('should remember and redirect to the last deepest state', async function (done) {
158+
it('should remember and redirect to the last deepest state', async function () {
167159
await testGo('p8child1');
168160
await testGo('other');
169161
await testGo('p8', undefined, { redirect: 'p8child1' });
170-
171-
done();
172162
});
173163
});
174164

175165
describe('with configured params', function () {
176-
it('should redirect only when params match', async function (done) {
166+
it('should redirect only when params match', async function () {
177167
await $state.go('p1', { param1: 'foo', param2: 'foo2' });
178168
expect($state.current.name).toEqual('p1');
179169
expect($state.params).toEqual({ '#': null, param1: 'foo', param2: 'foo2' } as any);
@@ -186,23 +176,19 @@ describe('deepStateRedirect', function () {
186176

187177
await $state.go('p1', { param1: 'foo', param2: 'somethingelse' });
188178
expect($state.current.name).toEqual('p1.child'); // DSR
189-
190-
done();
191179
});
192180

193181
// Test for issue #184 getRedirect()
194-
it('should be returned from getRedirect() for matching DSR params', async function (done) {
182+
it('should be returned from getRedirect() for matching DSR params', async function () {
195183
await $state.go('p1', { param1: 'foo', param2: 'foo2' });
196184
await $state.go('.child');
197185

198186
expect($deepStateRedirect.getRedirect('p1', { param1: 'foo' }).state().name).toBe('p1.child');
199187
expect($deepStateRedirect.getRedirect('p1', { param1: 'bar' })).toBeUndefined();
200-
201-
done();
202188
});
203189

204190
// Test for PR #165
205-
it('should consider only the params from the dsr configuration', async function (done) {
191+
it('should consider only the params from the dsr configuration', async function () {
206192
router.stateRegistry.register({
207193
name: 'rootState1',
208194
url: '/rootstate1/:rootstate1param',
@@ -221,11 +207,9 @@ describe('deepStateRedirect', function () {
221207

222208
const targetState = $deepStateRedirect.getRedirect('rootState1', { rootstate1param: 'rootstate1param' });
223209
expect(targetState.state().name).toBe('rootState1.sub2');
224-
225-
done();
226210
});
227211

228-
it('should not redirect if a param is resetted', async function (done) {
212+
it('should not redirect if a param is resetted', async function () {
229213
await $state.go('p3', { param1: 'foo' });
230214
await $state.go('.child');
231215
await $state.go('p3', { param1: 'bar' });
@@ -238,11 +222,9 @@ describe('deepStateRedirect', function () {
238222

239223
await $state.go('p3', { param1: 'bar' });
240224
expect($state.current.name).toEqual('p3.child'); // DSR
241-
242-
done();
243225
});
244226

245-
it("should redirect only when all params match if 'params: true'", async function (done) {
227+
it("should redirect only when all params match if 'params: true'", async function () {
246228
await $state.go('p2', { param1: 'foo', param2: 'foo2' });
247229

248230
expect($state.current.name).toEqual('p2');
@@ -259,13 +241,11 @@ describe('deepStateRedirect', function () {
259241

260242
await $state.go('p2', { param1: 'foo', param2: 'foo2' });
261243
expect($state.current.name).toEqual('p2.child'); // DSR
262-
263-
done();
264244
});
265245
});
266246

267247
describe('ignoreDsr option', function () {
268-
it('should not redirect to tabs.tabs2.deep.nest when options are: { ignoreDsr: true }', async function (done) {
248+
it('should not redirect to tabs.tabs2.deep.nest when options are: { ignoreDsr: true }', async function () {
269249
await testGo('tabs', { entered: 'tabs' });
270250
await testGo('tabs.tabs2.deep.nest', { entered: pathFrom('tabs.tabs2', 'tabs.tabs2.deep.nest') });
271251
await testGo('tabs.tabs1.deep.nest', {
@@ -275,11 +255,9 @@ describe('deepStateRedirect', function () {
275255
await $state.go('tabs.tabs2', {}, { custom: { ignoreDsr: true } });
276256

277257
expect($state.current.name).toBe('tabs.tabs2');
278-
279-
done();
280258
});
281259

282-
it('should redirect to tabs.tabs2.deep.nest after a previous ignoreDsr transition', async function (done) {
260+
it('should redirect to tabs.tabs2.deep.nest after a previous ignoreDsr transition', async function () {
283261
await testGo('tabs', { entered: 'tabs' });
284262
await testGo('tabs.tabs2.deep.nest', { entered: pathFrom('tabs.tabs2', 'tabs.tabs2.deep.nest') });
285263
await testGo('tabs.tabs1.deep.nest', {
@@ -300,11 +278,9 @@ describe('deepStateRedirect', function () {
300278
},
301279
{ redirect: 'tabs.tabs1.deep.nest' }
302280
);
303-
304-
done();
305281
});
306282

307-
it('should remember the DSR state itself when transitioned to using ignoreDsr ', async function (done) {
283+
it('should remember the DSR state itself when transitioned to using ignoreDsr ', async function () {
308284
await testGo('tabs.tabs1.deep', { entered: pathFrom('tabs', 'tabs.tabs1.deep') });
309285
await testGo('tabs.tabs2', { entered: 'tabs.tabs2', exited: pathFrom('tabs.tabs1.deep', 'tabs.tabs1') });
310286

@@ -317,8 +293,6 @@ describe('deepStateRedirect', function () {
317293
await $state.go('tabs.tabs1', {}, {});
318294

319295
expect($state.current.name).toBe('tabs.tabs1');
320-
321-
done();
322296
});
323297
});
324298

@@ -328,47 +302,37 @@ describe('deepStateRedirect', function () {
328302
expect($deepStateRedirect.getRedirect('p4').state().name).toBe('p4.child');
329303
});
330304

331-
it('should affect the first transition to the DSR state', async function (done) {
305+
it('should affect the first transition to the DSR state', async function () {
332306
await testGo('p4', undefined, { redirect: 'p4.child' });
333307
await testGo('p4.child2');
334308
await testGo('p4', undefined, { redirect: 'p4.child2' });
335-
336-
done();
337309
});
338310

339-
it('should provide default parameters', async function (done) {
311+
it('should provide default parameters', async function () {
340312
await testGo('p5', undefined, { redirect: 'p5.child' });
341313
expect($state.params).toEqual({ p5param: '1', '#': null } as any);
342-
343-
done();
344314
});
345315

346-
it('should redirect to the default state when params: true and transition to DSR with un-seen param values', async function (done) {
316+
it('should redirect to the default state when params: true and transition to DSR with un-seen param values', async function () {
347317
await testGo('p6', undefined, { params: { param: '1' }, redirect: 'p6.child1' });
348318
await testGo('p6.child2');
349319
await testGo('p6', undefined, { params: { param: '1' }, redirect: 'p6.child2' });
350320
// await testGo("p6", undefined, { params: { param: "2" }, redirect: 'p6.child1' });
351-
352-
done();
353321
});
354322

355323
describe('in conjunction with a dsr fn', function () {
356-
it('should still invoke the dsr fn and use the result', async function (done) {
324+
it('should still invoke the dsr fn and use the result', async function () {
357325
// This effectively allows a function to determine DSR default
358326
await testGo('p7', undefined, { params: { param: '2' }, redirect: 'p7.child2' });
359327
await testGo('p7.child1');
360328
await testGo('p7', undefined, { params: { param: '2' }, redirect: 'p7.child1' });
361-
362-
done();
363329
});
364330

365-
it('should still invoke the dsr fn and use the result', async function (done) {
331+
it('should still invoke the dsr fn and use the result', async function () {
366332
// This effectively allows the default DSR to be determined by a fn
367333
await testGo('p7', undefined, { redirect: 'p7.child1' });
368334
await testGo('p1');
369335
await testGo('p7', undefined, { params: { param: '2' }, redirect: 'p7.child1' });
370-
371-
done();
372336
});
373337
});
374338
});

0 commit comments

Comments
 (0)