-
Notifications
You must be signed in to change notification settings - Fork 309
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
104 changed files
with
15,807 additions
and
1,083 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# This file is used by the build system to adjust CSS and JS output to support the specified browsers below. | ||
# For additional information regarding the format and rule options, please see: | ||
# https://github.com/browserslist/browserslist#queries | ||
|
||
# For the full list of supported browsers by the Angular framework, please see: | ||
# https://angular.io/guide/browser-support | ||
|
||
# You can see what browsers were selected by your queries by running: | ||
# npx browserslist | ||
|
||
last 1 Chrome version | ||
last 1 Firefox version | ||
last 2 Edge major versions | ||
last 2 Safari major versions | ||
last 2 iOS major versions | ||
Firefox ESR |
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,16 @@ | ||
# Editor configuration, see https://editorconfig.org | ||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
indent_style = space | ||
indent_size = 2 | ||
insert_final_newline = true | ||
trim_trailing_whitespace = true | ||
|
||
[*.ts] | ||
quote_type = single | ||
|
||
[*.md] | ||
max_line_length = off | ||
trim_trailing_whitespace = false |
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 @@ | ||
# See http://help.github.com/ignore-files/ for more about ignoring files. | ||
|
||
# compiled output | ||
/dist | ||
/tmp | ||
/out-tsc | ||
# Only exists if Bazel was run | ||
/bazel-out | ||
|
||
# dependencies | ||
/node_modules | ||
|
||
# profiling files | ||
chrome-profiler-events*.json | ||
|
||
# IDEs and editors | ||
/.idea | ||
.project | ||
.classpath | ||
.c9/ | ||
*.launch | ||
.settings/ | ||
*.sublime-workspace | ||
|
||
# IDE - VSCode | ||
.vscode/* | ||
!.vscode/settings.json | ||
!.vscode/tasks.json | ||
!.vscode/launch.json | ||
!.vscode/extensions.json | ||
.history/* | ||
|
||
# misc | ||
/.angular/cache | ||
/.sass-cache | ||
/connect.lock | ||
/coverage | ||
/libpeerconnection.log | ||
npm-debug.log | ||
yarn-error.log | ||
testem.log | ||
/typings | ||
|
||
# System Files | ||
.DS_Store | ||
Thumbs.db |
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,27 @@ | ||
# ExampleAppV14 | ||
|
||
This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 14.0.0. | ||
|
||
## Development server | ||
|
||
Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files. | ||
|
||
## Code scaffolding | ||
|
||
Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module`. | ||
|
||
## Build | ||
|
||
Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory. | ||
|
||
## Running unit tests | ||
|
||
Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io). | ||
|
||
## Running end-to-end tests | ||
|
||
Run `ng e2e` to execute the end-to-end tests via a platform of your choice. To use this command, you need to first add a package that implements end-to-end testing capabilities. | ||
|
||
## Further help | ||
|
||
To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI Overview and Command Reference](https://angular.io/cli) page. |
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,102 @@ | ||
{ | ||
"$schema": "./node_modules/@angular/cli/lib/config/schema.json", | ||
"version": 1, | ||
"cli": { | ||
"packageManager": "yarn" | ||
}, | ||
"newProjectRoot": "projects", | ||
"projects": { | ||
"example-app-v14": { | ||
"projectType": "application", | ||
"schematics": { | ||
"@schematics/angular:application": { | ||
"strict": true | ||
} | ||
}, | ||
"root": "", | ||
"sourceRoot": "src", | ||
"prefix": "app", | ||
"architect": { | ||
"build": { | ||
"builder": "@angular-devkit/build-angular:browser", | ||
"options": { | ||
"outputPath": "dist/example-app-v14", | ||
"index": "src/index.html", | ||
"main": "src/main.ts", | ||
"polyfills": ["zone.js"], | ||
"tsConfig": "tsconfig.app.json", | ||
"assets": [ | ||
"src/favicon.ico", | ||
"src/assets" | ||
], | ||
"styles": [ | ||
"src/styles.css" | ||
], | ||
"scripts": [] | ||
}, | ||
"configurations": { | ||
"production": { | ||
"budgets": [ | ||
{ | ||
"type": "initial", | ||
"maximumWarning": "500kb", | ||
"maximumError": "1mb" | ||
}, | ||
{ | ||
"type": "anyComponentStyle", | ||
"maximumWarning": "2kb", | ||
"maximumError": "4kb" | ||
} | ||
], | ||
"outputHashing": "all" | ||
}, | ||
"development": { | ||
"buildOptimizer": false, | ||
"optimization": false, | ||
"vendorChunk": true, | ||
"extractLicenses": false, | ||
"sourceMap": true, | ||
"namedChunks": true | ||
} | ||
}, | ||
"defaultConfiguration": "production" | ||
}, | ||
"serve": { | ||
"builder": "@angular-devkit/build-angular:dev-server", | ||
"configurations": { | ||
"production": { | ||
"browserTarget": "example-app-v14:build:production" | ||
}, | ||
"development": { | ||
"browserTarget": "example-app-v14:build:development" | ||
} | ||
}, | ||
"defaultConfiguration": "development" | ||
}, | ||
"extract-i18n": { | ||
"builder": "@angular-devkit/build-angular:extract-i18n", | ||
"options": { | ||
"browserTarget": "example-app-v14:build" | ||
} | ||
}, | ||
"test": { | ||
"builder": "@angular-devkit/build-angular:karma", | ||
"options": { | ||
"main": "src/test.ts", | ||
"polyfills": ["zone.js"], | ||
"tsConfig": "tsconfig.spec.json", | ||
"karmaConfig": "karma.conf.js", | ||
"assets": [ | ||
"src/favicon.ico", | ||
"src/assets" | ||
], | ||
"styles": [ | ||
"src/styles.css" | ||
], | ||
"scripts": [] | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
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 @@ | ||
import jestCfg from './jest-esm.config.mjs'; | ||
|
||
/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */ | ||
const jestIsolatedCfg = { | ||
...jestCfg, | ||
globals: { | ||
'ts-jest': { | ||
...jestCfg.globals["ts-jest"], | ||
isolatedModules: true, | ||
}, | ||
}, | ||
}; | ||
|
||
export default jestIsolatedCfg; |
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,25 @@ | ||
import ngPreset from 'jest-preset-angular/presets/index.js'; | ||
|
||
globalThis.ngJest = { | ||
skipNgcc: false, | ||
tsconfig: 'tsconfig-esm.spec.json', | ||
}; | ||
|
||
/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */ | ||
const jestConfig = { | ||
...ngPreset.defaultsESM, | ||
globals: { | ||
'ts-jest': { | ||
...ngPreset.defaultsESM.globals["ts-jest"], | ||
tsconfig: '<rootDir>/tsconfig-esm.spec.json', | ||
}, | ||
}, | ||
globalSetup: 'jest-preset-angular/global-setup.mjs', | ||
moduleNameMapper: { | ||
tslib: 'tslib/tslib.es6.js', | ||
rxjs: '<rootDir>/node_modules/rxjs/dist/bundles/rxjs.umd.js', | ||
}, | ||
setupFilesAfterEnv: ['<rootDir>/setup-jest-esm.ts'], | ||
} | ||
|
||
export default jestConfig; |
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,31 @@ | ||
import { jest } from '@jest/globals'; | ||
|
||
Object.defineProperty(window, 'CSS', { value: null }); | ||
|
||
Object.defineProperty(document, 'doctype', { | ||
value: '<!DOCTYPE html>', | ||
}); | ||
|
||
Object.defineProperty(window, 'getComputedStyle', { | ||
value: () => { | ||
return { | ||
display: 'none', | ||
appearance: ['-webkit-appearance'], | ||
}; | ||
}, | ||
}); | ||
|
||
/** | ||
* ISSUE: https://github.com/angular/material2/issues/7101 | ||
* Workaround for JSDOM missing transform property | ||
*/ | ||
Object.defineProperty(document.body.style, 'transform', { | ||
value: () => { | ||
return { | ||
enumerable: true, | ||
configurable: true, | ||
}; | ||
}, | ||
}); | ||
|
||
HTMLCanvasElement.prototype.getContext = <typeof HTMLCanvasElement.prototype.getContext>jest.fn(); |
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,13 @@ | ||
const jestCfg = require('./jest.config'); | ||
const { defaults } = require('jest-preset-angular/presets'); | ||
|
||
/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */ | ||
module.exports = { | ||
...jestCfg, | ||
globals: { | ||
'ts-jest': { | ||
...defaults.globals['ts-jest'], | ||
isolatedModules: true, | ||
}, | ||
}, | ||
}; |
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,16 @@ | ||
const { pathsToModuleNameMapper } = require('ts-jest'); | ||
const { paths } = require('./tsconfig.json').compilerOptions; | ||
|
||
// eslint-disable-next-line no-undef | ||
globalThis.ngJest = { | ||
skipNgcc: false, | ||
tsconfig: 'tsconfig.spec.json', | ||
}; | ||
|
||
/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */ | ||
module.exports = { | ||
preset: 'jest-preset-angular', | ||
globalSetup: 'jest-preset-angular/global-setup', | ||
moduleNameMapper: pathsToModuleNameMapper(paths, { prefix: '<rootDir>' }), | ||
setupFilesAfterEnv: ['<rootDir>/setup-jest.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 @@ | ||
{ | ||
"name": "example-app-v15", | ||
"version": "15.0.0", | ||
"scripts": { | ||
"ng": "ng", | ||
"start": "ng serve", | ||
"build": "ng build", | ||
"test": "jest --no-cache", | ||
"test-isolated": "jest -c=jest-isolated.config.js --no-cache", | ||
"test-esm": "node --experimental-vm-modules --no-warnings node_modules/jest/bin/jest.js -c=jest-esm.config.mjs --no-cache", | ||
"test-esm-isolated": "node --experimental-vm-modules --no-warnings node_modules/jest/bin/jest.js -c=jest-esm-isolated.config.mjs --no-cache" | ||
}, | ||
"private": true, | ||
"dependencies": { | ||
"@angular/animations": "^15.0.0", | ||
"@angular/common": "^15.0.0", | ||
"@angular/compiler": "^15.0.0", | ||
"@angular/core": "^15.0.0", | ||
"@angular/forms": "^15.0.0", | ||
"@angular/platform-browser": "^15.0.0", | ||
"@angular/platform-browser-dynamic": "^15.0.0", | ||
"@angular/router": "^15.0.0", | ||
"angular-in-memory-web-api": "^0.14.0", | ||
"rxjs": "~7.5.7", | ||
"tslib": "^2.4.1", | ||
"zone.js": "^0.12.0" | ||
}, | ||
"devDependencies": { | ||
"@angular-devkit/build-angular": "^15.0.0", | ||
"@angular/cli": "^15.0.0", | ||
"@angular/compiler-cli": "^15.0.0", | ||
"@types/jest": "^29.1.2", | ||
"@types/node": "^16.11.63", | ||
"jest": "^29.1.2", | ||
"jest-preset-angular": "^12.2.2", | ||
"typescript": "^4.8.4" | ||
} | ||
} |
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,2 @@ | ||
import 'jest-preset-angular/setup-jest.mjs'; | ||
import './jest-global-mocks'; |
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,2 @@ | ||
import 'jest-preset-angular/setup-jest'; | ||
import './jest-global-mocks'; |
24 changes: 24 additions & 0 deletions
24
examples/example-app-v15/src/app/about/about.component.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,24 @@ | ||
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { HighlightDirective } from '../shared/highlight.directive'; | ||
|
||
import { AboutComponent } from './about.component'; | ||
|
||
let fixture: ComponentFixture<AboutComponent>; | ||
|
||
describe('AboutComponent (highlightDirective)', () => { | ||
beforeEach(() => { | ||
fixture = TestBed.configureTestingModule({ | ||
declarations: [AboutComponent, HighlightDirective], | ||
schemas: [CUSTOM_ELEMENTS_SCHEMA], | ||
}).createComponent(AboutComponent); | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should have skyblue <h2>', () => { | ||
const h2: HTMLElement = fixture.nativeElement.querySelector('h2'); | ||
const bgColor = h2.style.backgroundColor; | ||
expect(bgColor).toBe('skyblue'); | ||
}); | ||
}); |
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,10 @@ | ||
import { Component } from '@angular/core'; | ||
|
||
@Component({ | ||
template: ` | ||
<h2 highlight="skyblue">About</h2> | ||
<h3>Quote of the day:</h3> | ||
<twain-quote></twain-quote> | ||
`, | ||
}) | ||
export class AboutComponent {} |
Oops, something went wrong.