Skip to content

Commit

Permalink
fix(jest): fix jest env issues for running testS
Browse files Browse the repository at this point in the history
  • Loading branch information
AhsanAyaz committed May 26, 2021
1 parent c4a915f commit cfe4e55
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 17 deletions.
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@
"<rootDir>/node_modules/",
"<rootDir>/dist/"
],
"modulePathIgnorePatterns": [
"<rootDir>/dist/"
],
"globals": {
"ts-jest": {
"tsconfig": "<rootDir>/tsconfig.spec.json",
Expand Down
9 changes: 2 additions & 7 deletions projects/demo/tsconfig.app.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@
"outDir": "../../out-tsc/app",
"types": []
},
"files": [
"src/main.ts",
"src/polyfills.ts"
],
"include": [
"src/**/*.d.ts"
]
"files": ["src/main.ts", "src/polyfills.ts"],
"include": ["src/**/*.d.ts"]
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ describe('DeviceDetectorService', () => {
expect(service).toBeTruthy();
}));

it('should return device info object when getDeviceInfo is called', inject(
it('should return device info object for iPhone when getDeviceInfo is called', inject(
[DeviceDetectorService],
(service: DeviceDetectorService) => {
const userAgent =
Expand All @@ -38,7 +38,7 @@ describe('DeviceDetectorService', () => {
}
));

it('should return device details when system is desktop', inject(
it('should return device details when system is desktop and using Linux & Chrome', inject(
[DeviceDetectorService],
(service: DeviceDetectorService) => {
const userAgent =
Expand All @@ -52,14 +52,13 @@ describe('DeviceDetectorService', () => {
));

// tslint:disable-next-line: max-line-length
it('should return false when isDesktop is called on a non-desktop userAgent', inject(
[DeviceDetectorService],
(service: DeviceDetectorService) => {
// tslint:disable-next-line:max-line-length
const userAgent = `Mozilla/5.0 (iPad; CPU OS 11_0 like Mac OS X) AppleWebKit/604.1.34 (KHTML, like Gecko) Version/11.0 Mobile/15A5341f Safari/604.1`;
expect(service.isDesktop(userAgent)).toBeFalsy();
}
));
it('should detect an iPad correctly', inject([DeviceDetectorService], (service: DeviceDetectorService) => {
// tslint:disable-next-line:max-line-length
const userAgent = `Mozilla/5.0 (iPad; CPU OS 11_0 like Mac OS X) AppleWebKit/604.1.34 (KHTML, like Gecko) Version/11.0 Mobile/15A5341f Safari/604.1`;
expect(service.isDesktop(userAgent)).toBeFalsy();
expect(service.isTablet(userAgent)).toBeTruthy();
expect(service.isMobile(userAgent)).toBeFalsy();
}));

it('should return true, os=`Mac`, browser=`Safari`, device=`iPad` and browser_version=`11.0` when system is iPad tablet', inject(
[DeviceDetectorService],
Expand Down

0 comments on commit cfe4e55

Please sign in to comment.