-
Notifications
You must be signed in to change notification settings - Fork 12k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(@angular-devkit/build-angular): refactor server builder tests to…
… use test harness (cherry picked from commit 54c170b)
- Loading branch information
1 parent
f6ab2e3
commit 1a5c592
Showing
8 changed files
with
324 additions
and
295 deletions.
There are no files selected for viewing
176 changes: 0 additions & 176 deletions
176
packages/angular_devkit/build_angular/src/server/base_spec.ts
This file was deleted.
Oops, something went wrong.
43 changes: 0 additions & 43 deletions
43
packages/angular_devkit/build_angular/src/server/external_dependencies_spec.ts
This file was deleted.
Oops, something went wrong.
76 changes: 0 additions & 76 deletions
76
packages/angular_devkit/build_angular/src/server/resources-output-path_spec.ts
This file was deleted.
Oops, something went wrong.
44 changes: 44 additions & 0 deletions
44
packages/angular_devkit/build_angular/src/server/tests/behavior/web-workers_spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/** | ||
* @license | ||
* Copyright Google LLC All Rights Reserved. | ||
* | ||
* Use of this source code is governed by an MIT-style license that can be | ||
* found in the LICENSE file at https://angular.io/license | ||
*/ | ||
|
||
import { execute } from '../../index'; | ||
import { BASE_OPTIONS, SERVER_BUILDER_INFO, describeBuilder } from '../setup'; | ||
|
||
describeBuilder(execute, SERVER_BUILDER_INFO, (harness) => { | ||
describe('Behavior: "Errors"', () => { | ||
it('should not try to resolve web-workers', async () => { | ||
harness.useTarget('test', { | ||
...BASE_OPTIONS, | ||
}); | ||
|
||
await harness.writeFiles({ | ||
'src/app/app.worker.ts': ` | ||
/// <reference lib="webworker" /> | ||
const foo: string = 'hello world'; | ||
addEventListener('message', ({ data }) => { | ||
postMessage(foo); | ||
}); | ||
`, | ||
'src/main.server.ts': ` | ||
if (typeof Worker !== 'undefined') { | ||
const worker = new Worker(new URL('./app/app.worker', import.meta.url), { type: 'module' }); | ||
worker.onmessage = ({ data }) => { | ||
console.log('page got message:', data); | ||
}; | ||
worker.postMessage('hello'); | ||
} | ||
`, | ||
}); | ||
|
||
const { result } = await harness.executeOnce(); | ||
|
||
expect(result?.success).toBeTrue(); | ||
}); | ||
}); | ||
}); |
38 changes: 38 additions & 0 deletions
38
packages/angular_devkit/build_angular/src/server/tests/options/external-dependencies_spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/** | ||
* @license | ||
* Copyright Google LLC All Rights Reserved. | ||
* | ||
* Use of this source code is governed by an MIT-style license that can be | ||
* found in the LICENSE file at https://angular.io/license | ||
*/ | ||
|
||
import { execute } from '../../index'; | ||
import { BASE_OPTIONS, SERVER_BUILDER_INFO, describeBuilder } from '../setup'; | ||
|
||
describeBuilder(execute, SERVER_BUILDER_INFO, (harness) => { | ||
describe('Option: "externalDependencies"', () => { | ||
it(`should not bundle dependency when set "externalDependencies" is set.`, async () => { | ||
harness.useTarget('server', { | ||
...BASE_OPTIONS, | ||
externalDependencies: ['@angular/core'], | ||
}); | ||
|
||
const { result } = await harness.executeOnce(); | ||
expect(result?.success).toBe(true); | ||
|
||
harness.expectFile('dist/main.js').content.toContain('require("@angular/core")'); | ||
harness.expectFile('dist/main.js').content.not.toContain('require("@angular/common")'); | ||
}); | ||
|
||
it(`should bundle all dependencies when "externalDependencies" is unset`, async () => { | ||
harness.useTarget('server', { | ||
...BASE_OPTIONS, | ||
}); | ||
|
||
const { result } = await harness.executeOnce(); | ||
expect(result?.success).toBe(true); | ||
harness.expectFile('dist/main.js').content.not.toContain('require("@angular/core")'); | ||
harness.expectFile('dist/main.js').content.not.toContain('require("@angular/common")'); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.