-
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.
fix(@angular-devkit/build-angular): jasmine.clock with app builder
- Loading branch information
Showing
4 changed files
with
186 additions
and
7 deletions.
There are no files selected for viewing
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
18 changes: 18 additions & 0 deletions
18
packages/angular_devkit/build_angular/src/builders/karma/jasmine_global.js
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,18 @@ | ||
/** | ||
* @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.dev/license | ||
*/ | ||
|
||
// See: https://github.com/jasmine/jasmine/issues/2015 | ||
(function () { | ||
'use strict'; | ||
|
||
// jasmine will ignore `window` unless it returns this specific (but uncommon) | ||
// value from toString(). | ||
window.toString = function () { | ||
return '[object GjsGlobal]'; | ||
}; | ||
})(); |
14 changes: 14 additions & 0 deletions
14
packages/angular_devkit/build_angular/src/builders/karma/jasmine_global_cleanup.js
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,14 @@ | ||
/** | ||
* @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.dev/license | ||
*/ | ||
|
||
// See: https://github.com/jasmine/jasmine/issues/2015 | ||
(function () { | ||
'use strict'; | ||
|
||
delete window.toString; | ||
})(); |
46 changes: 46 additions & 0 deletions
46
...ages/angular_devkit/build_angular/src/builders/karma/tests/behavior/jasmine-clock_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,46 @@ | ||
/** | ||
* @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.dev/license | ||
*/ | ||
|
||
import { execute } from '../../index'; | ||
import { BASE_OPTIONS, KARMA_BUILDER_INFO, describeKarmaBuilder } from '../setup'; | ||
|
||
describeKarmaBuilder(execute, KARMA_BUILDER_INFO, (harness, setupTarget) => { | ||
describe('Behavior: "jasmine.clock()"', () => { | ||
beforeEach(async () => { | ||
await setupTarget(harness); | ||
}); | ||
|
||
it('can install and uninstall the mock clock', async () => { | ||
await harness.writeFiles({ | ||
'./src/app/app.component.spec.ts': ` | ||
import { AppComponent } from './app.component'; | ||
describe('Using jasmine.clock()', () => { | ||
beforeEach(async () => { | ||
jasmine.clock().install(); | ||
}); | ||
afterEach(() => { | ||
jasmine.clock().uninstall(); | ||
}); | ||
it('runs a basic test case', () => { | ||
expect(!!AppComponent).toBe(true); | ||
}); | ||
});`, | ||
}); | ||
|
||
harness.useTarget('test', { | ||
...BASE_OPTIONS, | ||
}); | ||
|
||
const { result } = await harness.executeOnce(); | ||
expect(result?.success).toBeTrue(); | ||
}); | ||
}); | ||
}); |