-
Notifications
You must be signed in to change notification settings - Fork 306
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(babel): alternative setup babel/typescript
BREAKING CHANGE: add an alternative preset for babel and restructures the whole repository to treat babel and ts-jest equally. The jest config of users will have to be adjusted, see the CHANGELOG.md for migration information.
- Loading branch information
Showing
26 changed files
with
1,785 additions
and
71 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
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,12 @@ | ||
const { babelAngularConfig } = require('jest-preset-angular/build/babel/babel.config') | ||
module.exports = api => { | ||
api.cache(false) | ||
return { | ||
presets: babelAngularConfig.presets, | ||
plugins: [ | ||
...babelAngularConfig.plugins, | ||
// your plugins | ||
] | ||
} | ||
} | ||
|
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
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
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 { Injectable } from "@angular/core"; | ||
import { HeroCategory, HeroColor } from "./hero-properties"; | ||
|
||
@Injectable({ | ||
providedIn: "root" | ||
}) | ||
export class HeroCategoryService { | ||
getCategoryForHero(heroName: string): HeroCategory { | ||
switch (heroName) { | ||
case "Joker": | ||
return HeroCategory.Evil; | ||
case "Batman": | ||
return HeroCategory.Good; | ||
default: | ||
return HeroCategory.Neutral; | ||
} | ||
} | ||
|
||
getColorForHero(heroName: string): HeroColor { | ||
switch (heroName) { | ||
case "Joker": | ||
return HeroColor.Purple; | ||
case "Batman": | ||
return HeroColor.Black; | ||
case "Catwoman": | ||
return HeroColor.Black; | ||
default: | ||
return HeroColor.Transparent; | ||
} | ||
} | ||
} |
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 @@ | ||
import { async } from "@angular/core/testing"; | ||
|
||
import { HeroCategoryService } from "./hero-category.service"; | ||
import { HeroCategory, HeroColor } from './hero-properties'; | ||
|
||
describe("HeroCategoryService", () => { | ||
let service: HeroCategoryService; | ||
|
||
beforeEach(() => (service = new HeroCategoryService())); | ||
|
||
it("should create", () => { | ||
expect(service).toBeTruthy(); | ||
}); | ||
|
||
it("should return the right category for heroes", () => { | ||
expect(service.getCategoryForHero("Batman")).toEqual(HeroCategory.Good); | ||
expect(service.getCategoryForHero("Joker")).toEqual(HeroCategory.Evil); | ||
expect(service.getCategoryForHero("Catwoman")).toEqual(HeroCategory.Neutral); | ||
}); | ||
|
||
it("should return the right color for heroes", () => { | ||
expect(service.getColorForHero("Batman")).toEqual(HeroColor.Black); | ||
expect(service.getColorForHero("Joker")).toEqual(HeroColor.Purple); | ||
expect(service.getColorForHero("The Penguin")).toEqual(HeroColor.Transparent); | ||
}); | ||
|
||
}); |
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,12 @@ | ||
|
||
export enum HeroCategory { | ||
Evil, | ||
Good, | ||
Neutral | ||
} | ||
|
||
export const enum HeroColor { | ||
Black = "#000000", | ||
Purple = "#551A8B", | ||
Transparent = "#00000000" | ||
} |
Oops, something went wrong.