Skip to content

Commit f209cb5

Browse files
alan-agius4filipesilva
authored andcommitted
test(@angular-devkit/core): update host tests to not use deprecated Jasmine behaviour
``` DEPRECATION: An asynchronous before/it/after function was defined with the async keyword but also took a done callback. This is not supported and will stop working in the future. Either remove the done callback (recommended) or remove the async keyword. ```
1 parent 06af7d7 commit f209cb5

File tree

2 files changed

+15
-45
lines changed

2 files changed

+15
-45
lines changed

packages/angular_devkit/core/src/workspace/core_spec.ts

Lines changed: 11 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import { WorkspaceDefinition } from './definitions';
1919
import { WorkspaceHost } from './host';
2020

2121
describe('readWorkspace', () => {
22-
it('attempts to read from specified file path [angular.json]', async (done) => {
22+
it('attempts to read from specified file path [angular.json]', async () => {
2323
const requestedPath = '/path/to/workspace/angular.json';
2424

2525
const host: WorkspaceHost = {
@@ -42,11 +42,9 @@ describe('readWorkspace', () => {
4242
};
4343

4444
await readWorkspace(requestedPath, host);
45-
46-
done();
4745
});
4846

49-
it('attempts to read from specified file path [.angular.json]', async (done) => {
47+
it('attempts to read from specified file path [.angular.json]', async () => {
5048
const requestedPath = '/path/to/workspace/.angular.json';
5149

5250
const host: WorkspaceHost = {
@@ -69,11 +67,9 @@ describe('readWorkspace', () => {
6967
};
7068

7169
await readWorkspace(requestedPath, host);
72-
73-
done();
7470
});
7571

76-
it('attempts to read from specified non-standard file path with format', async (done) => {
72+
it('attempts to read from specified non-standard file path with format', async () => {
7773
const requestedPath = '/path/to/workspace/abc.json';
7874

7975
const host: WorkspaceHost = {
@@ -96,11 +92,9 @@ describe('readWorkspace', () => {
9692
};
9793

9894
await readWorkspace(requestedPath, host, WorkspaceFormat.JSON);
99-
100-
done();
10195
});
10296

103-
it('errors when reading from specified non-standard file path without format', async (done) => {
97+
it('errors when reading from specified non-standard file path without format', async () => {
10498
const requestedPath = '/path/to/workspace/abc.json';
10599

106100
const host: WorkspaceHost = {
@@ -128,11 +122,9 @@ describe('readWorkspace', () => {
128122
} catch (e) {
129123
expect(e.message).toContain('Unable to determine format for workspace path');
130124
}
131-
132-
done();
133125
});
134126

135-
it('errors when reading from specified file path with invalid specified format', async (done) => {
127+
it('errors when reading from specified file path with invalid specified format', async () => {
136128
const requestedPath = '/path/to/workspace/angular.json';
137129

138130
const host: WorkspaceHost = {
@@ -160,11 +152,9 @@ describe('readWorkspace', () => {
160152
} catch (e) {
161153
expect(e.message).toContain('Unsupported workspace format');
162154
}
163-
164-
done();
165155
});
166156

167-
it('attempts to find/read from directory path', async (done) => {
157+
it('attempts to find/read from directory path', async () => {
168158
const requestedPath = getSystemPath(normalize('/path/to/workspace'));
169159
const expectedFile = getSystemPath(join(normalize(requestedPath), '.angular.json'));
170160

@@ -201,11 +191,9 @@ describe('readWorkspace', () => {
201191
getSystemPath(join(normalize(requestedPath), '.angular.json')),
202192
].sort(),
203193
);
204-
205-
done();
206194
});
207195

208-
it('attempts to find/read only files for specified format from directory path', async (done) => {
196+
it('attempts to find/read only files for specified format from directory path', async () => {
209197
const requestedPath = '/path/to/workspace';
210198

211199
const isFileChecks: string[] = [];
@@ -246,11 +234,9 @@ describe('readWorkspace', () => {
246234

247235
readFileChecks.sort();
248236
expect(readFileChecks).toEqual([getSystemPath(join(normalize(requestedPath), 'angular.json'))]);
249-
250-
done();
251237
});
252238

253-
it('errors when no file found from specified directory path', async (done) => {
239+
it('errors when no file found from specified directory path', async () => {
254240
const requestedPath = '/path/to/workspace';
255241

256242
const host: WorkspaceHost = {
@@ -280,13 +266,11 @@ describe('readWorkspace', () => {
280266
} catch (e) {
281267
expect(e.message).toContain('Unable to locate a workspace file');
282268
}
283-
284-
done();
285269
});
286270
});
287271

288272
describe('writeWorkspace', () => {
289-
it('attempts to write to specified file path', async (done) => {
273+
it('attempts to write to specified file path', async () => {
290274
const requestedPath = '/path/to/workspace/angular.json';
291275

292276
let writtenPath: string | undefined;
@@ -314,11 +298,9 @@ describe('writeWorkspace', () => {
314298

315299
await writeWorkspace({} as WorkspaceDefinition, host, requestedPath, WorkspaceFormat.JSON);
316300
expect(writtenPath).toBe(requestedPath);
317-
318-
done();
319301
});
320302

321-
it('errors when writing to specified file path with invalid specified format', async (done) => {
303+
it('errors when writing to specified file path with invalid specified format', async () => {
322304
const requestedPath = '/path/to/workspace/angular.json';
323305

324306
const host: WorkspaceHost = {
@@ -348,11 +330,9 @@ describe('writeWorkspace', () => {
348330
} catch (e) {
349331
expect(e.message).toContain('Unsupported workspace format');
350332
}
351-
352-
done();
353333
});
354334

355-
it('errors when writing custom workspace without specified format', async (done) => {
335+
it('errors when writing custom workspace without specified format', async () => {
356336
const requestedPath = '/path/to/workspace/angular.json';
357337

358338
const host: WorkspaceHost = {
@@ -382,7 +362,5 @@ describe('writeWorkspace', () => {
382362
} catch (e) {
383363
expect(e.message).toContain('A format is required');
384364
}
385-
386-
done();
387365
});
388366
});

packages/angular_devkit/core/src/workspace/host_spec.ts

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,41 +21,33 @@ describe('createWorkspaceHost', () => {
2121
workspaceHost = createWorkspaceHost(testHost);
2222
});
2323

24-
it('supports isFile', async (done) => {
24+
it('supports isFile', async () => {
2525
expect(await workspaceHost.isFile('abc.txt')).toBeTruthy();
2626
expect(await workspaceHost.isFile('foo/bar.json')).toBeTruthy();
2727
expect(await workspaceHost.isFile('foo\\bar.json')).toBeTruthy();
2828

2929
expect(await workspaceHost.isFile('foo')).toBeFalsy();
3030
expect(await workspaceHost.isFile('not.there')).toBeFalsy();
31-
32-
done();
3331
});
3432

35-
it('supports isDirectory', async (done) => {
33+
it('supports isDirectory', async () => {
3634
expect(await workspaceHost.isDirectory('foo')).toBeTruthy();
3735
expect(await workspaceHost.isDirectory('foo/')).toBeTruthy();
3836
expect(await workspaceHost.isDirectory('foo\\')).toBeTruthy();
3937

4038
expect(await workspaceHost.isDirectory('abc.txt')).toBeFalsy();
4139
expect(await workspaceHost.isDirectory('foo/bar.json')).toBeFalsy();
4240
expect(await workspaceHost.isDirectory('not.there')).toBeFalsy();
43-
44-
done();
4541
});
4642

47-
it('supports readFile', async (done) => {
43+
it('supports readFile', async () => {
4844
expect(await workspaceHost.readFile('abc.txt')).toBe('abcdefg');
49-
50-
done();
5145
});
5246

53-
it('supports writeFile', async (done) => {
47+
it('supports writeFile', async () => {
5448
await workspaceHost.writeFile('newfile', 'baz');
5549
expect(testHost.files.sort() as string[]).toEqual(['/abc.txt', '/foo/bar.json', '/newfile']);
5650

5751
expect(testHost.$read('newfile')).toBe('baz');
58-
59-
done();
6052
});
6153
});

0 commit comments

Comments
 (0)