forked from ngneat/reactive-forms
-
Notifications
You must be signed in to change notification settings - Fork 0
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
11 changed files
with
9,490 additions
and
6,002 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,12 @@ | ||
module.exports = { | ||
preset: 'jest-preset-angular', | ||
setupFilesAfterEnv: ['<rootDir>/setup-jest.ts'], | ||
cacheDirectory: '<rootDir>/.cache', | ||
testMatch: ['<rootDir>/projects/ngneat/reactive-forms/**/*.spec.ts'], | ||
testPathIgnorePatterns: ['node_modules'], | ||
transform: { | ||
'^.+\\.ts?$': 'ts-jest' | ||
}, | ||
collectCoverage: true, | ||
modulePathIgnorePatterns: ['mocks.spec.ts'] | ||
}; |
This file was deleted.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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
13 changes: 13 additions & 0 deletions
13
projects/ngneat/reactive-forms/src/lib/type-tests/formControl.spec.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,13 @@ | ||
'use strict'; | ||
exports.__esModule = true; | ||
var expect_type_1 = require('expect-type'); | ||
var rxjs_1 = require('rxjs'); | ||
var formControl_1 = require('../formControl'); | ||
test('control value should be type of string', function() { | ||
var control = new formControl_1.FormControl('a string'); | ||
expect_type_1.expectTypeOf(control.value).toBeString(); | ||
}); | ||
test('control valueChanges should be stream of strings', function() { | ||
var control = new formControl_1.FormControl('a string'); | ||
expect_type_1.expectTypeOf(control.valueChanges$).toMatchTypeOf(new rxjs_1.Observable()); | ||
}); |
13 changes: 13 additions & 0 deletions
13
projects/ngneat/reactive-forms/src/lib/type-tests/formControl.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,13 @@ | ||
import { expectTypeOf } from 'expect-type'; | ||
import { Observable } from 'rxjs'; | ||
import { FormControl } from '../formControl'; | ||
|
||
test('control value should be type of string', () => { | ||
const control = new FormControl<string>('a string'); | ||
expectTypeOf(control.value).toBeString(); | ||
}); | ||
|
||
test('control valueChanges should be stream of strings', () => { | ||
const control = new FormControl<string>('a string'); | ||
expectTypeOf(control.valueChanges$).toMatchTypeOf(new Observable<string>()); | ||
}); |
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,30 @@ | ||
import 'jest-preset-angular'; | ||
|
||
/* global mocks for jsdom */ | ||
const mock = () => { | ||
let storage: { [key: string]: string } = {}; | ||
return { | ||
getItem: (key: string) => (key in storage ? storage[key] : null), | ||
setItem: (key: string, value: string) => (storage[key] = value || ''), | ||
removeItem: (key: string) => delete storage[key], | ||
clear: () => (storage = {}) | ||
}; | ||
}; | ||
|
||
Object.defineProperty(window, 'localStorage', { value: mock() }); | ||
Object.defineProperty(window, 'sessionStorage', { value: mock() }); | ||
Object.defineProperty(window, 'getComputedStyle', { | ||
value: () => ['-webkit-appearance'] | ||
}); | ||
|
||
Object.defineProperty(document.body.style, 'transform', { | ||
value: () => { | ||
return { | ||
enumerable: true, | ||
configurable: true | ||
}; | ||
} | ||
}); | ||
|
||
/* output shorter and more meaningful Zone error stack traces */ | ||
// Error.stackTraceLimit = 2; |
This file was deleted.
Oops, something went wrong.
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,21 @@ | ||
import { TestBed } from '@angular/core/testing'; | ||
|
||
type CompilerOptions = Partial<{ | ||
providers: any[]; | ||
useJit: boolean; | ||
preserveWhitespaces: boolean; | ||
}>; | ||
export type ConfigureFn = (testBed: typeof TestBed) => void; | ||
|
||
export const configureTests = (configure: ConfigureFn, compilerOptions: CompilerOptions = {}) => { | ||
const compilerConfig: CompilerOptions = { | ||
preserveWhitespaces: false, | ||
...compilerOptions | ||
}; | ||
|
||
const configuredTestBed = TestBed.configureCompiler(compilerConfig); | ||
|
||
configure(configuredTestBed); | ||
|
||
return configuredTestBed.compileComponents().then(() => configuredTestBed); | ||
}; |
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