type
stringclasses 7
values | content
stringlengths 4
9.55k
| repo
stringlengths 7
96
| path
stringlengths 4
178
| language
stringclasses 1
value |
|---|---|---|---|---|
ArrowFunction
|
(key) => expect(keys.includes(key)).toBeFalsy()
|
best-doctor/ke
|
src/django-spa/utils/dicts/omit.test.ts
|
TypeScript
|
ArrowFunction
|
([source, keys]) => {
const result = omit(source, keys)
Object.entries(result).forEach(([key, value]) => expect(value).toBe(source[key]))
}
|
best-doctor/ke
|
src/django-spa/utils/dicts/omit.test.ts
|
TypeScript
|
ArrowFunction
|
([key, value]) => expect(value).toBe(source[key])
|
best-doctor/ke
|
src/django-spa/utils/dicts/omit.test.ts
|
TypeScript
|
InterfaceDeclaration
|
interface PokeList {
}
|
alaindet/learn-web-components
|
courses/stencil/stencil-advanced/src/components.d.ts
|
TypeScript
|
InterfaceDeclaration
|
interface PokeSearch {
"focusInput": () => Promise<void>;
"pokemonName": string;
}
|
alaindet/learn-web-components
|
courses/stencil/stencil-advanced/src/components.d.ts
|
TypeScript
|
InterfaceDeclaration
|
interface HTMLPokeListElement extends Components.PokeList, HTMLStencilElement {
}
|
alaindet/learn-web-components
|
courses/stencil/stencil-advanced/src/components.d.ts
|
TypeScript
|
InterfaceDeclaration
|
interface HTMLPokeSearchElement extends Components.PokeSearch, HTMLStencilElement {
}
|
alaindet/learn-web-components
|
courses/stencil/stencil-advanced/src/components.d.ts
|
TypeScript
|
InterfaceDeclaration
|
interface HTMLElementTagNameMap {
"poke-list": HTMLPokeListElement;
"poke-search": HTMLPokeSearchElement;
}
|
alaindet/learn-web-components
|
courses/stencil/stencil-advanced/src/components.d.ts
|
TypeScript
|
InterfaceDeclaration
|
interface PokeList {
"onSelectedPokemonName"?: (event: CustomEvent<string>) => void;
}
|
alaindet/learn-web-components
|
courses/stencil/stencil-advanced/src/components.d.ts
|
TypeScript
|
InterfaceDeclaration
|
interface PokeSearch {
"pokemonName"?: string;
}
|
alaindet/learn-web-components
|
courses/stencil/stencil-advanced/src/components.d.ts
|
TypeScript
|
InterfaceDeclaration
|
interface IntrinsicElements {
"poke-list": PokeList;
"poke-search": PokeSearch;
}
|
alaindet/learn-web-components
|
courses/stencil/stencil-advanced/src/components.d.ts
|
TypeScript
|
InterfaceDeclaration
|
interface IntrinsicElements {
"poke-list": LocalJSX.PokeList & JSXBase.HTMLAttributes<HTMLPokeListElement>;
"poke-search": LocalJSX.PokeSearch & JSXBase.HTMLAttributes<HTMLPokeSearchElement>;
}
|
alaindet/learn-web-components
|
courses/stencil/stencil-advanced/src/components.d.ts
|
TypeScript
|
InterfaceDeclaration
|
interface FindOptions extends glob.IOptions {
src?: string;
filter?: string | ((filepath?: string, options?: any) => boolean);
nonull?: boolean;
matchBase?: boolean;
srcBase?: string;
prefixBase?: boolean;
}
|
0815Strohhut/DefinitelyTyped
|
types/globule/index.d.ts
|
TypeScript
|
InterfaceDeclaration
|
interface MappingOptions extends FindOptions {
srcBase?: string;
destBase?: string;
ext?: string;
extDot?: 'first' | 'last';
flatten?: boolean;
rename?(p: string): string;
}
|
0815Strohhut/DefinitelyTyped
|
types/globule/index.d.ts
|
TypeScript
|
InterfaceDeclaration
|
interface OneMapping {
src: string[];
dest: string;
}
|
0815Strohhut/DefinitelyTyped
|
types/globule/index.d.ts
|
TypeScript
|
InterfaceDeclaration
|
interface GlobuleStatic {
/**
* Match one or more globbing patterns against one or more file paths.
* Returns a uniqued array of all file paths that match any of the specified globbing patterns.
*/
match(patterns: string | string[], filepaths: string | string[], options?: minimatch.IOptions): string[];
/**
* Tests pattern(s) against against one or more file paths and returns true if any files were matched, otherwise false.
*/
isMatch(patterns: string | string[], filepaths: string | string[], options?: minimatch.IOptions): boolean;
/**
* Returns a unique array of all file or directory paths that match the given globbing pattern(s)
*/
find(pattern: string | string[], options?: FindOptions): string[];
/**
* Returns a unique array of all file or directory paths that match the given globbing pattern(s)
*/
find(options: FindOptions): string[];
/**
* Returns a unique array of all file or directory paths that match the given globbing pattern(s)
*/
find(pattern: string | string[], pattern2: string | string[], options?: FindOptions): string[];
/**
* Returns a unique array of all file or directory paths that match the given globbing pattern(s)
*/
find(pattern: string, pattern2: string, pattern3: string | string[], options?: FindOptions): string[];
/**
* Given a set of source file paths, returns an array of src-dest file mapping objects
*/
mapping(filepaths: string[], options?: MappingOptions): OneMapping[];
/**
* Given a set of source file paths, returns an array of src-dest file mapping objects
*/
mapping(options: MappingOptions): OneMapping[];
/**
* Given a set of source file paths, returns an array of src-dest file mapping objects
*/
mapping(filepaths: string[], filepaths2: string[], options?: MappingOptions): OneMapping[];
/**
* Given a set of source file paths, returns an array of src-dest file mapping objects
*/
mapping(filepaths: string[], filepaths2: string[], filepaths3: string[], options?: MappingOptions): OneMapping[];
}
|
0815Strohhut/DefinitelyTyped
|
types/globule/index.d.ts
|
TypeScript
|
ArrowFunction
|
item => +item
|
zaneon/ng-zorro-antd
|
components/badge/badge-sup.component.ts
|
TypeScript
|
ClassDeclaration
|
@Component({
selector: 'nz-badge-sup',
exportAs: 'nzBadgeSup',
preserveWhitespaces: false,
encapsulation: ViewEncapsulation.None,
changeDetection: ChangeDetectionStrategy.OnPush,
animations: [zoomBadgeMotion],
template: `
<ng-container *ngIf="count <= nzOverflowCount; else overflowTemplate">
<span
[nzNoAnimation]="noAnimation"
*ngFor="let n of maxNumberArray; let i = index"
class="ant-scroll-number-only"
[style.transform]="'translateY(' + -countArray[i] * 100 + '%)'"
>
<ng-container *ngIf="!nzDot && countArray[i] !== undefined">
<p *ngFor="let p of countSingleArray" class="ant-scroll-number-only-unit" [class.current]="p === countArray[i]">
{{ p }}
</p>
</ng-container>
</span>
</ng-container>
<ng-template #overflowTemplate>{{ nzOverflowCount }}+</ng-template>
`,
host: {
'[@.disabled]': `disableAnimation`,
'[@zoomBadgeMotion]': '',
'[attr.title]': `nzTitle === null ? '' : nzTitle || nzCount`,
'[style]': `nzStyle`,
'[style.right.px]': `nzOffset && nzOffset[0] ? -nzOffset[0] : null`,
'[style.margin-top.px]': `nzOffset && nzOffset[1] ? nzOffset[1] : null`,
'[class.ant-badge-count]': `!nzDot`,
'[class.ant-badge-dot]': `nzDot`,
'[class.ant-badge-multiple-words]': `countArray.length >= 2`
}
})
export class NzBadgeSupComponent implements OnInit, OnChanges {
@Input() nzOffset?: [number, number];
@Input() nzTitle?: string | null | undefined;
@Input() nzStyle: { [key: string]: string } | null = null;
@Input() nzDot = false;
@Input() nzOverflowCount: number = 99;
@Input() disableAnimation = false;
@Input() nzCount?: number | TemplateRef<NzSafeAny>;
@Input() noAnimation = false;
maxNumberArray: string[] = [];
countArray: number[] = [];
count: number = 0;
countSingleArray = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
constructor(private elementRef: ElementRef) {
// TODO: move to host after View Engine deprecation
this.elementRef.nativeElement.classList.add('ant-scroll-number');
}
generateMaxNumberArray(): void {
this.maxNumberArray = this.nzOverflowCount.toString().split('');
}
ngOnInit(): void {
this.generateMaxNumberArray();
}
ngOnChanges(changes: SimpleChanges): void {
const { nzOverflowCount, nzCount } = changes;
if (nzCount && typeof nzCount.currentValue === 'number') {
this.count = Math.max(0, nzCount.currentValue);
this.countArray = this.count
.toString()
.split('')
.map(item => +item);
}
if (nzOverflowCount) {
this.generateMaxNumberArray();
}
}
}
|
zaneon/ng-zorro-antd
|
components/badge/badge-sup.component.ts
|
TypeScript
|
MethodDeclaration
|
generateMaxNumberArray(): void {
this.maxNumberArray = this.nzOverflowCount.toString().split('');
}
|
zaneon/ng-zorro-antd
|
components/badge/badge-sup.component.ts
|
TypeScript
|
MethodDeclaration
|
ngOnInit(): void {
this.generateMaxNumberArray();
}
|
zaneon/ng-zorro-antd
|
components/badge/badge-sup.component.ts
|
TypeScript
|
MethodDeclaration
|
ngOnChanges(changes: SimpleChanges): void {
const { nzOverflowCount, nzCount } = changes;
if (nzCount && typeof nzCount.currentValue === 'number') {
this.count = Math.max(0, nzCount.currentValue);
this.countArray = this.count
.toString()
.split('')
.map(item => +item);
}
if (nzOverflowCount) {
this.generateMaxNumberArray();
}
}
|
zaneon/ng-zorro-antd
|
components/badge/badge-sup.component.ts
|
TypeScript
|
FunctionDeclaration
|
export function slotGlowEffect(): Script {
const sprite = EntityMemory.to<number>(0)
const center = EntityMemory.to<number>(1)
const width = EntityMemory.to<number>(2)
const startTime = EntityMemory.to<number>(3)
const endTime = EntityMemory.to<number>(4)
const tL = EntityMemory.to<number>(5)
const tR = EntityMemory.to<number>(6)
const bL = EntityMemory.to<number>(7)
const bR = EntityMemory.to<number>(8)
const z = EntityMemory.to<number>(9)
const tw = Multiply(lane.w, Lerp(1, 1.25, options.slotEffectSize))
const initialize = [
startTime.set(Time),
endTime.set(Add(startTime, 0.25)),
tL.set(Multiply(Subtract(center, width), tw)),
tR.set(Multiply(Add(center, width), tw)),
bL.set(Multiply(Subtract(center, width), lane.w)),
bR.set(Multiply(Add(center, width), lane.w)),
z.set(
Add(
Layer.SlotGlowEffect,
Divide(Time, 1000),
Divide(Abs(center), -10000)
)
),
]
const a = EntityMemory.to<number>(32)
const p = EntityMemory.to<number>(33)
const t = EntityMemory.to<number>(34)
const updateParallel = Or(GreaterOr(Time, endTime), [
a.set(Unlerp(endTime, startTime, Time)),
p.set(Subtract(1, Power(a, 3))),
t.set(Add(lane.b, Multiply(lane.w, 4, options.slotEffectSize, p))),
Draw(
sprite,
bL,
lane.b,
Lerp(bL, tL, p),
t,
Lerp(bR, tR, p),
t,
bR,
lane.b,
z,
a
),
])
return {
initialize: {
code: initialize,
},
updateParallel: {
code: updateParallel,
},
}
}
|
Dosugamea/sonolus-pjsekai-engine-extended
|
src/engine/data/scripts/slot-glow-effect.ts
|
TypeScript
|
FunctionDeclaration
|
export function getSlotGlowSprite(color: number) {
return customSkinSprite(engineId, 60 + color)
}
|
Dosugamea/sonolus-pjsekai-engine-extended
|
src/engine/data/scripts/slot-glow-effect.ts
|
TypeScript
|
ClassDeclaration
|
@NgModule({
declarations: [
FormGroupComponent,
FormFieldComponent,
InputMessageGroupWithTemplate
],
imports: [
CommonModule,
FormsModule,
ReactiveFormsModule,
FdFormModule,
InlineHelpModule,
PopoverModule
],
exports: [
FormGroupComponent,
FormFieldComponent
]
})
export class FdpFormGroupModule {
}
|
Toskv/fundamental-ngx
|
libs/platform/src/lib/components/form/form-group/fdp-form.module.ts
|
TypeScript
|
ClassDeclaration
|
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
// This file must match with:
// * Layouts Protocol.h
export class Protocol {
static Name_User_Persistent_Panel = "user-persistent-panel";
static Name_Action_Update_Item = 'update-item';
static Name_Action_Update_Children = 'update-children';
static Name_Action_Create_Item = 'create-item';
static Type_Dummy = "dummy";
static Type_Panel = "panel";
static Type_Connexion = "connexion";
static Name_Connexion_Name = "name";
static Name_Connexion_Host = "host";
static Name_Connexion_Port = "port";
}
|
JeroenDStout/Ap-Code-IrisBase
|
Pub_ts/Layouts Protocol.ts
|
TypeScript
|
FunctionDeclaration
|
function getWindow(element) { return element.querySelector('ngb-popover-window'); }
|
Acidburn0zzz/ng-bootstrap
|
src/popover/popover.spec.ts
|
TypeScript
|
ArrowFunction
|
(html: string) =>
createGenericTestComponent(html, TestComponent) as ComponentFixture<TestComponent>
|
Acidburn0zzz/ng-bootstrap
|
src/popover/popover.spec.ts
|
TypeScript
|
ArrowFunction
|
(html: string) => <ComponentFixture<TestOnPushComponent>>createGenericTestComponent(html, TestOnPushComponent)
|
Acidburn0zzz/ng-bootstrap
|
src/popover/popover.spec.ts
|
TypeScript
|
ArrowFunction
|
() => {
beforeEach(() => { TestBed.configureTestingModule({declarations: [TestComponent], imports: [NgbPopoverModule]}); });
afterEach(() => {
// Cleaning elements, because of a TestBed issue with the id attribute
Array.from(document.body.children).map((element: HTMLElement) => {
if (element.tagName.toLocaleLowerCase() === 'div') {
element.parentNode.removeChild(element);
}
});
});
it('should render popover on top by default', () => {
const fixture = TestBed.createComponent(NgbPopoverWindow);
fixture.componentInstance.title = 'Test title';
fixture.detectChanges();
expect(fixture.nativeElement).toHaveCssClass('popover');
expect(fixture.nativeElement).not.toHaveCssClass('bs-popover-top');
expect(fixture.nativeElement.getAttribute('role')).toBe('tooltip');
expect(fixture.nativeElement.querySelector('.popover-header').textContent).toBe('Test title');
});
it('should optionally have a custom class', () => {
const fixture = TestBed.createComponent(NgbPopoverWindow);
fixture.detectChanges();
expect(fixture.nativeElement).not.toHaveCssClass('my-custom-class');
fixture.componentInstance.popoverClass = 'my-custom-class';
fixture.detectChanges();
expect(fixture.nativeElement).toHaveCssClass('my-custom-class');
});
}
|
Acidburn0zzz/ng-bootstrap
|
src/popover/popover.spec.ts
|
TypeScript
|
ArrowFunction
|
() => { TestBed.configureTestingModule({declarations: [TestComponent], imports: [NgbPopoverModule]}); }
|
Acidburn0zzz/ng-bootstrap
|
src/popover/popover.spec.ts
|
TypeScript
|
ArrowFunction
|
() => {
// Cleaning elements, because of a TestBed issue with the id attribute
Array.from(document.body.children).map((element: HTMLElement) => {
if (element.tagName.toLocaleLowerCase() === 'div') {
element.parentNode.removeChild(element);
}
});
}
|
Acidburn0zzz/ng-bootstrap
|
src/popover/popover.spec.ts
|
TypeScript
|
ArrowFunction
|
(element: HTMLElement) => {
if (element.tagName.toLocaleLowerCase() === 'div') {
element.parentNode.removeChild(element);
}
}
|
Acidburn0zzz/ng-bootstrap
|
src/popover/popover.spec.ts
|
TypeScript
|
ArrowFunction
|
() => {
const fixture = TestBed.createComponent(NgbPopoverWindow);
fixture.componentInstance.title = 'Test title';
fixture.detectChanges();
expect(fixture.nativeElement).toHaveCssClass('popover');
expect(fixture.nativeElement).not.toHaveCssClass('bs-popover-top');
expect(fixture.nativeElement.getAttribute('role')).toBe('tooltip');
expect(fixture.nativeElement.querySelector('.popover-header').textContent).toBe('Test title');
}
|
Acidburn0zzz/ng-bootstrap
|
src/popover/popover.spec.ts
|
TypeScript
|
ArrowFunction
|
() => {
const fixture = TestBed.createComponent(NgbPopoverWindow);
fixture.detectChanges();
expect(fixture.nativeElement).not.toHaveCssClass('my-custom-class');
fixture.componentInstance.popoverClass = 'my-custom-class';
fixture.detectChanges();
expect(fixture.nativeElement).toHaveCssClass('my-custom-class');
}
|
Acidburn0zzz/ng-bootstrap
|
src/popover/popover.spec.ts
|
TypeScript
|
ArrowFunction
|
() => {
TestBed.configureTestingModule({
declarations: [TestComponent, TestOnPushComponent, DestroyableCmpt, TestHooksComponent],
imports: [NgbPopoverModule],
providers: [SpyService]
});
}
|
Acidburn0zzz/ng-bootstrap
|
src/popover/popover.spec.ts
|
TypeScript
|
ArrowFunction
|
() => {
const fixture =
createTestComponent(`<div ngbPopover="Great tip!" popoverTitle="Title" style="margin-top: 100px;"></div>`);
const directive = fixture.debugElement.query(By.directive(NgbPopover));
triggerEvent(directive, 'click');
fixture.detectChanges();
const windowEl = getWindow(fixture.nativeElement);
const id = windowEl.getAttribute('id');
expect(windowEl).toHaveCssClass('popover');
expect(windowEl).toHaveCssClass('bs-popover-top');
expect(windowEl.textContent.trim()).toBe('TitleGreat tip!');
expect(windowEl.getAttribute('role')).toBe('tooltip');
expect(windowEl.parentNode).toBe(fixture.nativeElement);
expect(directive.nativeElement.getAttribute('aria-describedby')).toBe(id);
triggerEvent(directive, 'click');
fixture.detectChanges();
expect(getWindow(fixture.nativeElement)).toBeNull();
expect(directive.nativeElement.getAttribute('aria-describedby')).toBeNull();
}
|
Acidburn0zzz/ng-bootstrap
|
src/popover/popover.spec.ts
|
TypeScript
|
ArrowFunction
|
() => {
const fixture = createTestComponent(`
<ng-template #t>Hello, {{name}}!</ng-template>
<div [ngbPopover]="t" popoverTitle="Title" style="margin-top: 100px;"></div>`);
const directive = fixture.debugElement.query(By.directive(NgbPopover));
triggerEvent(directive, 'click');
fixture.detectChanges();
const windowEl = getWindow(fixture.nativeElement);
const id = windowEl.getAttribute('id');
expect(windowEl).toHaveCssClass('popover');
expect(windowEl).toHaveCssClass('bs-popover-top');
expect(windowEl.textContent.trim()).toBe('TitleHello, World!');
expect(windowEl.getAttribute('role')).toBe('tooltip');
expect(windowEl.parentNode).toBe(fixture.nativeElement);
expect(directive.nativeElement.getAttribute('aria-describedby')).toBe(id);
triggerEvent(directive, 'click');
fixture.detectChanges();
expect(getWindow(fixture.nativeElement)).toBeNull();
expect(directive.nativeElement.getAttribute('aria-describedby')).toBeNull();
}
|
Acidburn0zzz/ng-bootstrap
|
src/popover/popover.spec.ts
|
TypeScript
|
ArrowFunction
|
() => {
const fixture = createTestComponent(`
<ng-template #t let-name="name">Hello, {{name}}!</ng-template>
<div [ngbPopover]="t" popoverTitle="Title" style="margin-top: 100px;"></div>`);
const directive = fixture.debugElement.query(By.directive(NgbPopover));
directive.context.popover.open({name: 'John'});
fixture.detectChanges();
const windowEl = getWindow(fixture.nativeElement);
const id = windowEl.getAttribute('id');
expect(windowEl).toHaveCssClass('popover');
expect(windowEl).toHaveCssClass('bs-popover-top');
expect(windowEl.textContent.trim()).toBe('TitleHello, John!');
expect(windowEl.getAttribute('role')).toBe('tooltip');
expect(windowEl.parentNode).toBe(fixture.nativeElement);
expect(directive.nativeElement.getAttribute('aria-describedby')).toBe(id);
triggerEvent(directive, 'click');
fixture.detectChanges();
expect(getWindow(fixture.nativeElement)).toBeNull();
expect(directive.nativeElement.getAttribute('aria-describedby')).toBeNull();
}
|
Acidburn0zzz/ng-bootstrap
|
src/popover/popover.spec.ts
|
TypeScript
|
ArrowFunction
|
() => {
const fixture = createTestComponent(`
<div ngbPopover="Great tip!" popoverTitle="Title" popoverClass="my-custom-class" style="margin-top: 100px;"></div>`);
const directive = fixture.debugElement.query(By.directive(NgbPopover));
triggerEvent(directive, 'click');
fixture.detectChanges();
const windowEl = getWindow(fixture.nativeElement);
const id = windowEl.getAttribute('id');
expect(windowEl).toHaveCssClass('popover');
expect(windowEl).toHaveCssClass('bs-popover-top');
expect(windowEl).toHaveCssClass('my-custom-class');
expect(windowEl.textContent.trim()).toBe('TitleGreat tip!');
expect(windowEl.getAttribute('role')).toBe('tooltip');
expect(windowEl.parentNode).toBe(fixture.nativeElement);
expect(directive.nativeElement.getAttribute('aria-describedby')).toBe(id);
triggerEvent(directive, 'click');
fixture.detectChanges();
expect(getWindow(fixture.nativeElement)).toBeNull();
expect(directive.nativeElement.getAttribute('aria-describedby')).toBeNull();
}
|
Acidburn0zzz/ng-bootstrap
|
src/popover/popover.spec.ts
|
TypeScript
|
ArrowFunction
|
() => {
const fixture =
createTestComponent(`<div ngbPopover="Great tip!" popoverTitle="Title" [popoverClass]="popoverClass"></div>`);
const directive = fixture.debugElement.query(By.directive(NgbPopover));
triggerEvent(directive, 'click');
fixture.detectChanges();
const windowEl = getWindow(fixture.nativeElement);
expect(windowEl).not.toHaveCssClass('my-popover-class');
fixture.componentInstance.popoverClass = 'my-popover-class';
fixture.detectChanges();
expect(windowEl).toHaveCssClass('my-popover-class');
}
|
Acidburn0zzz/ng-bootstrap
|
src/popover/popover.spec.ts
|
TypeScript
|
ArrowFunction
|
() => {
const fixture = createTestComponent(`
<ng-template #t>Hello, {{name}}! <destroyable-cmpt></destroyable-cmpt></ng-template>
<div ngbPopover="Body" [popoverTitle]="t"></div>`);
const directive = fixture.debugElement.query(By.directive(NgbPopover));
const spyService = fixture.debugElement.injector.get(SpyService);
triggerEvent(directive, 'click');
fixture.detectChanges();
const windowEl = getWindow(fixture.nativeElement);
expect(windowEl.textContent.trim()).toBe('Hello, World! Some contentBody');
expect(spyService.called).toBeFalsy();
triggerEvent(directive, 'click');
fixture.detectChanges();
expect(getWindow(fixture.nativeElement)).toBeNull();
expect(spyService.called).toBeTruthy();
}
|
Acidburn0zzz/ng-bootstrap
|
src/popover/popover.spec.ts
|
TypeScript
|
ArrowFunction
|
() => {
const fixture = createTestComponent(`
<ng-template #t let-greeting="greeting">{{greeting}}, {{name}}!</ng-template>
<div ngbPopover="!!" [popoverTitle]="t"></div>`);
const directive = fixture.debugElement.query(By.directive(NgbPopover));
fixture.componentInstance.name = 'tout le monde';
fixture.componentInstance.popover.open({greeting: 'Bonjour'});
fixture.detectChanges();
const windowEl = getWindow(fixture.nativeElement);
expect(windowEl.textContent.trim()).toBe('Bonjour, tout le monde!!!');
triggerEvent(directive, 'click');
fixture.detectChanges();
expect(getWindow(fixture.nativeElement)).toBeNull();
}
|
Acidburn0zzz/ng-bootstrap
|
src/popover/popover.spec.ts
|
TypeScript
|
ArrowFunction
|
() => {
const fixture = createTestComponent(`
<ng-template #t><destroyable-cmpt></destroyable-cmpt></ng-template>
<div [ngbPopover]="t" popoverTitle="Title"></div>`);
const directive = fixture.debugElement.query(By.directive(NgbPopover));
const spyService = fixture.debugElement.injector.get(SpyService);
triggerEvent(directive, 'click');
fixture.detectChanges();
expect(getWindow(fixture.nativeElement)).not.toBeNull();
expect(spyService.called).toBeFalsy();
triggerEvent(directive, 'click');
fixture.detectChanges();
expect(getWindow(fixture.nativeElement)).toBeNull();
expect(spyService.called).toBeTruthy();
}
|
Acidburn0zzz/ng-bootstrap
|
src/popover/popover.spec.ts
|
TypeScript
|
ArrowFunction
|
() => {
const fixture = createTestComponent(`<div ngbPopover="Great tip!"></div>`);
const directive = fixture.debugElement.query(By.directive(NgbPopover));
triggerEvent(directive, 'click');
fixture.detectChanges();
const windowEl = getWindow(fixture.nativeElement);
expect(windowEl.querySelector('.popover-header')).toBeNull();
}
|
Acidburn0zzz/ng-bootstrap
|
src/popover/popover.spec.ts
|
TypeScript
|
ArrowFunction
|
() => {
const fixture = createTestComponent(`<div [ngbPopover]="" [popoverTitle]=""></div>`);
const directive = fixture.debugElement.query(By.directive(NgbPopover));
triggerEvent(directive, 'click');
fixture.detectChanges();
const windowEl = getWindow(fixture.nativeElement);
expect(windowEl).toBeNull();
}
|
Acidburn0zzz/ng-bootstrap
|
src/popover/popover.spec.ts
|
TypeScript
|
ArrowFunction
|
() => {
const fixture = createTestComponent(`<div [ngbPopover]="Disabled!" [disablePopover]="true"></div>`);
const directive = fixture.debugElement.query(By.directive(NgbPopover));
triggerEvent(directive, 'click');
fixture.detectChanges();
const windowEl = getWindow(fixture.nativeElement);
expect(windowEl).toBeNull();
}
|
Acidburn0zzz/ng-bootstrap
|
src/popover/popover.spec.ts
|
TypeScript
|
ArrowFunction
|
() => {
const fixture = createTestComponent(`<div [ngbPopover]="name" [popoverTitle]="title"></div>`);
const directive = fixture.debugElement.query(By.directive(NgbPopover));
triggerEvent(directive, 'click');
fixture.detectChanges();
expect(getWindow(fixture.nativeElement)).not.toBeNull();
fixture.componentInstance.name = '';
fixture.componentInstance.title = '';
fixture.detectChanges();
expect(getWindow(fixture.nativeElement)).toBeNull();
}
|
Acidburn0zzz/ng-bootstrap
|
src/popover/popover.spec.ts
|
TypeScript
|
ArrowFunction
|
() => {
const fixture = createTestComponent(`<div [ngbPopover]="" popoverTitle="title"></div>`);
const directive = fixture.debugElement.query(By.directive(NgbPopover));
triggerEvent(directive, 'click');
fixture.detectChanges();
const windowEl = getWindow(fixture.nativeElement);
expect(windowEl).not.toBeNull();
}
|
Acidburn0zzz/ng-bootstrap
|
src/popover/popover.spec.ts
|
TypeScript
|
ArrowFunction
|
() => {
const fixture = createTestComponent(`<div [ngbPopover]="name" popoverTitle="title"></div>`);
const directive = fixture.debugElement.query(By.directive(NgbPopover));
triggerEvent(directive, 'click');
fixture.detectChanges();
expect(getWindow(fixture.nativeElement)).not.toBeNull();
fixture.componentInstance.name = '';
fixture.detectChanges();
expect(getWindow(fixture.nativeElement)).not.toBeNull();
}
|
Acidburn0zzz/ng-bootstrap
|
src/popover/popover.spec.ts
|
TypeScript
|
ArrowFunction
|
() => {
const fixture = createTestComponent(`<div ngbPopover="Great tip!" popoverTitle="Title"></div>`);
const directive = fixture.debugElement.query(By.directive(NgbPopover));
triggerEvent(directive, 'click');
fixture.detectChanges();
expect(getWindow(fixture.nativeElement)).not.toBeNull();
triggerEvent(directive, 'click');
fixture.detectChanges();
expect(getWindow(fixture.nativeElement)).toBeNull();
triggerEvent(directive, 'click');
fixture.detectChanges();
expect(getWindow(fixture.nativeElement)).not.toBeNull();
}
|
Acidburn0zzz/ng-bootstrap
|
src/popover/popover.spec.ts
|
TypeScript
|
ArrowFunction
|
() => {
const fixture = createTestComponent(
`<ng-template [ngIf]="show"><div ngbPopover="Great tip!" popoverTitle="Title"></div></ng-template>`);
const directive = fixture.debugElement.query(By.directive(NgbPopover));
triggerEvent(directive, 'click');
fixture.detectChanges();
expect(getWindow(fixture.nativeElement)).not.toBeNull();
fixture.componentInstance.show = false;
fixture.detectChanges();
expect(getWindow(fixture.nativeElement)).toBeNull();
}
|
Acidburn0zzz/ng-bootstrap
|
src/popover/popover.spec.ts
|
TypeScript
|
ArrowFunction
|
() => {
const fixture = createTestComponent(`<ng-template [ngIf]="show">
<div ngbPopover="Great tip!" triggers="manual" #p="ngbPopover" (mouseenter)="p.open()"></div>
</ng-template>`);
const directive = fixture.debugElement.query(By.directive(NgbPopover));
triggerEvent(directive, 'mouseenter');
fixture.detectChanges();
expect(getWindow(fixture.nativeElement)).not.toBeNull();
fixture.componentInstance.show = false;
fixture.detectChanges();
expect(getWindow(fixture.nativeElement)).toBeNull();
}
|
Acidburn0zzz/ng-bootstrap
|
src/popover/popover.spec.ts
|
TypeScript
|
ArrowFunction
|
() => {
const fixture = TestBed.createComponent(TestHooksComponent);
fixture.detectChanges();
const popoverWindow = fixture.debugElement.query(By.directive(NgbPopoverWindow));
expect(popoverWindow.nativeElement).toHaveCssClass('popover');
}
|
Acidburn0zzz/ng-bootstrap
|
src/popover/popover.spec.ts
|
TypeScript
|
ArrowFunction
|
() => {
it('should use requested position', () => {
const fixture = createTestComponent(`<div ngbPopover="Great tip!" placement="left"></div>`);
const directive = fixture.debugElement.query(By.directive(NgbPopover));
triggerEvent(directive, 'click');
fixture.detectChanges();
const windowEl = getWindow(fixture.nativeElement);
expect(windowEl).toHaveCssClass('popover');
expect(windowEl).toHaveCssClass('bs-popover-left');
expect(windowEl.textContent.trim()).toBe('Great tip!');
});
it('should properly position popovers when a component is using the OnPush strategy', () => {
const fixture = createOnPushTestComponent(`<div ngbPopover="Great tip!" placement="left"></div>`);
const directive = fixture.debugElement.query(By.directive(NgbPopover));
triggerEvent(directive, 'click');
fixture.detectChanges();
const windowEl = getWindow(fixture.nativeElement);
expect(windowEl).toHaveCssClass('popover');
expect(windowEl).toHaveCssClass('bs-popover-left');
expect(windowEl.textContent.trim()).toBe('Great tip!');
});
it('should have proper arrow placement', () => {
const fixture = createTestComponent(`<div ngbPopover="Great tip!" placement="right-top"></div>`);
const directive = fixture.debugElement.query(By.directive(NgbPopover));
triggerEvent(directive, 'click');
fixture.detectChanges();
const windowEl = getWindow(fixture.nativeElement);
expect(windowEl).toHaveCssClass('popover');
expect(windowEl).toHaveCssClass('bs-popover-right');
expect(windowEl).toHaveCssClass('bs-popover-right-top');
expect(windowEl.textContent.trim()).toBe('Great tip!');
});
it('should accept placement in array (second value of the array should be applied)', () => {
const fixture = createTestComponent(
`<div ngbPopover="Great tip!" [placement]="['left-top','top-left']" style="margin-top: 100px;"></div>`);
const directive = fixture.debugElement.query(By.directive(NgbPopover));
triggerEvent(directive, 'click');
fixture.detectChanges();
const windowEl = getWindow(fixture.nativeElement);
expect(windowEl).toHaveCssClass('popover');
expect(windowEl).toHaveCssClass('bs-popover-top');
expect(windowEl).toHaveCssClass('bs-popover-top-left');
expect(windowEl.textContent.trim()).toBe('Great tip!');
});
it('should accept placement with space separated values (second value should be applied)', () => {
const fixture = createTestComponent(
`<div ngbPopover="Great tip!" placement="left-top top-left" style="margin-top: 100px;"></div>`);
const directive = fixture.debugElement.query(By.directive(NgbPopover));
triggerEvent(directive, 'click');
fixture.detectChanges();
const windowEl = getWindow(fixture.nativeElement);
expect(windowEl).toHaveCssClass('popover');
expect(windowEl).toHaveCssClass('bs-popover-top');
expect(windowEl).toHaveCssClass('bs-popover-top-left');
expect(windowEl.textContent.trim()).toBe('Great tip!');
});
it('should apply auto placement', () => {
const fixture = createTestComponent(`<div ngbPopover="Great tip!" placement="auto"></div>`);
const directive = fixture.debugElement.query(By.directive(NgbPopover));
triggerEvent(directive, 'click');
fixture.detectChanges();
const windowEl = getWindow(fixture.nativeElement);
expect(windowEl).toHaveCssClass('popover');
// actual placement with auto is not known in advance, so use regex to check it
expect(windowEl.getAttribute('class')).toMatch('bs-popover-\.');
expect(windowEl.textContent.trim()).toBe('Great tip!');
});
}
|
Acidburn0zzz/ng-bootstrap
|
src/popover/popover.spec.ts
|
TypeScript
|
ArrowFunction
|
() => {
const fixture = createTestComponent(`<div ngbPopover="Great tip!" placement="left"></div>`);
const directive = fixture.debugElement.query(By.directive(NgbPopover));
triggerEvent(directive, 'click');
fixture.detectChanges();
const windowEl = getWindow(fixture.nativeElement);
expect(windowEl).toHaveCssClass('popover');
expect(windowEl).toHaveCssClass('bs-popover-left');
expect(windowEl.textContent.trim()).toBe('Great tip!');
}
|
Acidburn0zzz/ng-bootstrap
|
src/popover/popover.spec.ts
|
TypeScript
|
ArrowFunction
|
() => {
const fixture = createOnPushTestComponent(`<div ngbPopover="Great tip!" placement="left"></div>`);
const directive = fixture.debugElement.query(By.directive(NgbPopover));
triggerEvent(directive, 'click');
fixture.detectChanges();
const windowEl = getWindow(fixture.nativeElement);
expect(windowEl).toHaveCssClass('popover');
expect(windowEl).toHaveCssClass('bs-popover-left');
expect(windowEl.textContent.trim()).toBe('Great tip!');
}
|
Acidburn0zzz/ng-bootstrap
|
src/popover/popover.spec.ts
|
TypeScript
|
ArrowFunction
|
() => {
const fixture = createTestComponent(`<div ngbPopover="Great tip!" placement="right-top"></div>`);
const directive = fixture.debugElement.query(By.directive(NgbPopover));
triggerEvent(directive, 'click');
fixture.detectChanges();
const windowEl = getWindow(fixture.nativeElement);
expect(windowEl).toHaveCssClass('popover');
expect(windowEl).toHaveCssClass('bs-popover-right');
expect(windowEl).toHaveCssClass('bs-popover-right-top');
expect(windowEl.textContent.trim()).toBe('Great tip!');
}
|
Acidburn0zzz/ng-bootstrap
|
src/popover/popover.spec.ts
|
TypeScript
|
ArrowFunction
|
() => {
const fixture = createTestComponent(
`<div ngbPopover="Great tip!" [placement]="['left-top','top-left']" style="margin-top: 100px;"></div>`);
const directive = fixture.debugElement.query(By.directive(NgbPopover));
triggerEvent(directive, 'click');
fixture.detectChanges();
const windowEl = getWindow(fixture.nativeElement);
expect(windowEl).toHaveCssClass('popover');
expect(windowEl).toHaveCssClass('bs-popover-top');
expect(windowEl).toHaveCssClass('bs-popover-top-left');
expect(windowEl.textContent.trim()).toBe('Great tip!');
}
|
Acidburn0zzz/ng-bootstrap
|
src/popover/popover.spec.ts
|
TypeScript
|
ArrowFunction
|
() => {
const fixture = createTestComponent(
`<div ngbPopover="Great tip!" placement="left-top top-left" style="margin-top: 100px;"></div>`);
const directive = fixture.debugElement.query(By.directive(NgbPopover));
triggerEvent(directive, 'click');
fixture.detectChanges();
const windowEl = getWindow(fixture.nativeElement);
expect(windowEl).toHaveCssClass('popover');
expect(windowEl).toHaveCssClass('bs-popover-top');
expect(windowEl).toHaveCssClass('bs-popover-top-left');
expect(windowEl.textContent.trim()).toBe('Great tip!');
}
|
Acidburn0zzz/ng-bootstrap
|
src/popover/popover.spec.ts
|
TypeScript
|
ArrowFunction
|
() => {
const fixture = createTestComponent(`<div ngbPopover="Great tip!" placement="auto"></div>`);
const directive = fixture.debugElement.query(By.directive(NgbPopover));
triggerEvent(directive, 'click');
fixture.detectChanges();
const windowEl = getWindow(fixture.nativeElement);
expect(windowEl).toHaveCssClass('popover');
// actual placement with auto is not known in advance, so use regex to check it
expect(windowEl.getAttribute('class')).toMatch('bs-popover-\.');
expect(windowEl.textContent.trim()).toBe('Great tip!');
}
|
Acidburn0zzz/ng-bootstrap
|
src/popover/popover.spec.ts
|
TypeScript
|
ArrowFunction
|
() => {
it('should be appended to the element matching the selector passed to "container"', () => {
const selector = 'body';
const fixture = createTestComponent(`<div ngbPopover="Great tip!" container="` + selector + `"></div>`);
const directive = fixture.debugElement.query(By.directive(NgbPopover));
triggerEvent(directive, 'click');
fixture.detectChanges();
expect(getWindow(fixture.nativeElement)).toBeNull();
expect(getWindow(window.document.querySelector(selector))).not.toBeNull();
});
it('should properly destroy popovers when the "container" option is used', () => {
const selector = 'body';
const fixture =
createTestComponent(`<div *ngIf="show" ngbPopover="Great tip!" container="` + selector + `"></div>`);
const directive = fixture.debugElement.query(By.directive(NgbPopover));
triggerEvent(directive, 'click');
fixture.detectChanges();
expect(getWindow(document.querySelector(selector))).not.toBeNull();
fixture.componentRef.instance.show = false;
fixture.detectChanges();
expect(getWindow(document.querySelector(selector))).toBeNull();
});
}
|
Acidburn0zzz/ng-bootstrap
|
src/popover/popover.spec.ts
|
TypeScript
|
ArrowFunction
|
() => {
const selector = 'body';
const fixture = createTestComponent(`<div ngbPopover="Great tip!" container="` + selector + `"></div>`);
const directive = fixture.debugElement.query(By.directive(NgbPopover));
triggerEvent(directive, 'click');
fixture.detectChanges();
expect(getWindow(fixture.nativeElement)).toBeNull();
expect(getWindow(window.document.querySelector(selector))).not.toBeNull();
}
|
Acidburn0zzz/ng-bootstrap
|
src/popover/popover.spec.ts
|
TypeScript
|
ArrowFunction
|
() => {
const selector = 'body';
const fixture =
createTestComponent(`<div *ngIf="show" ngbPopover="Great tip!" container="` + selector + `"></div>`);
const directive = fixture.debugElement.query(By.directive(NgbPopover));
triggerEvent(directive, 'click');
fixture.detectChanges();
expect(getWindow(document.querySelector(selector))).not.toBeNull();
fixture.componentRef.instance.show = false;
fixture.detectChanges();
expect(getWindow(document.querySelector(selector))).toBeNull();
}
|
Acidburn0zzz/ng-bootstrap
|
src/popover/popover.spec.ts
|
TypeScript
|
ArrowFunction
|
() => {
it('should emit events when showing and hiding popover', () => {
const fixture = createTestComponent(
`<div ngbPopover="Great tip!" triggers="click" (shown)="shown()" (hidden)="hidden()"></div>`);
const directive = fixture.debugElement.query(By.directive(NgbPopover));
let shownSpy = spyOn(fixture.componentInstance, 'shown');
let hiddenSpy = spyOn(fixture.componentInstance, 'hidden');
triggerEvent(directive, 'click');
fixture.detectChanges();
expect(getWindow(fixture.nativeElement)).not.toBeNull();
expect(shownSpy).toHaveBeenCalled();
triggerEvent(directive, 'click');
fixture.detectChanges();
expect(getWindow(fixture.nativeElement)).toBeNull();
expect(hiddenSpy).toHaveBeenCalled();
});
it('should not emit close event when already closed', () => {
const fixture = createTestComponent(
`<div ngbPopover="Great tip!" triggers="manual" (shown)="shown()" (hidden)="hidden()"></div>`);
let shownSpy = spyOn(fixture.componentInstance, 'shown');
let hiddenSpy = spyOn(fixture.componentInstance, 'hidden');
fixture.componentInstance.popover.open();
fixture.detectChanges();
fixture.componentInstance.popover.open();
fixture.detectChanges();
expect(getWindow(fixture.nativeElement)).not.toBeNull();
expect(shownSpy).toHaveBeenCalled();
expect(shownSpy.calls.count()).toEqual(1);
expect(hiddenSpy).not.toHaveBeenCalled();
});
it('should not emit open event when already opened', () => {
const fixture = createTestComponent(
`<div ngbPopover="Great tip!" triggers="manual" (shown)="shown()" (hidden)="hidden()"></div>`);
let shownSpy = spyOn(fixture.componentInstance, 'shown');
let hiddenSpy = spyOn(fixture.componentInstance, 'hidden');
fixture.componentInstance.popover.close();
fixture.detectChanges();
expect(getWindow(fixture.nativeElement)).toBeNull();
expect(shownSpy).not.toHaveBeenCalled();
expect(hiddenSpy).not.toHaveBeenCalled();
});
it('should report correct visibility', () => {
const fixture = createTestComponent(`<div ngbPopover="Great tip!" triggers="manual"></div>`);
fixture.detectChanges();
expect(fixture.componentInstance.popover.isOpen()).toBeFalsy();
fixture.componentInstance.popover.open();
fixture.detectChanges();
expect(fixture.componentInstance.popover.isOpen()).toBeTruthy();
fixture.componentInstance.popover.close();
fixture.detectChanges();
expect(fixture.componentInstance.popover.isOpen()).toBeFalsy();
});
}
|
Acidburn0zzz/ng-bootstrap
|
src/popover/popover.spec.ts
|
TypeScript
|
ArrowFunction
|
() => {
const fixture = createTestComponent(
`<div ngbPopover="Great tip!" triggers="click" (shown)="shown()" (hidden)="hidden()"></div>`);
const directive = fixture.debugElement.query(By.directive(NgbPopover));
let shownSpy = spyOn(fixture.componentInstance, 'shown');
let hiddenSpy = spyOn(fixture.componentInstance, 'hidden');
triggerEvent(directive, 'click');
fixture.detectChanges();
expect(getWindow(fixture.nativeElement)).not.toBeNull();
expect(shownSpy).toHaveBeenCalled();
triggerEvent(directive, 'click');
fixture.detectChanges();
expect(getWindow(fixture.nativeElement)).toBeNull();
expect(hiddenSpy).toHaveBeenCalled();
}
|
Acidburn0zzz/ng-bootstrap
|
src/popover/popover.spec.ts
|
TypeScript
|
ArrowFunction
|
() => {
const fixture = createTestComponent(
`<div ngbPopover="Great tip!" triggers="manual" (shown)="shown()" (hidden)="hidden()"></div>`);
let shownSpy = spyOn(fixture.componentInstance, 'shown');
let hiddenSpy = spyOn(fixture.componentInstance, 'hidden');
fixture.componentInstance.popover.open();
fixture.detectChanges();
fixture.componentInstance.popover.open();
fixture.detectChanges();
expect(getWindow(fixture.nativeElement)).not.toBeNull();
expect(shownSpy).toHaveBeenCalled();
expect(shownSpy.calls.count()).toEqual(1);
expect(hiddenSpy).not.toHaveBeenCalled();
}
|
Acidburn0zzz/ng-bootstrap
|
src/popover/popover.spec.ts
|
TypeScript
|
ArrowFunction
|
() => {
const fixture = createTestComponent(
`<div ngbPopover="Great tip!" triggers="manual" (shown)="shown()" (hidden)="hidden()"></div>`);
let shownSpy = spyOn(fixture.componentInstance, 'shown');
let hiddenSpy = spyOn(fixture.componentInstance, 'hidden');
fixture.componentInstance.popover.close();
fixture.detectChanges();
expect(getWindow(fixture.nativeElement)).toBeNull();
expect(shownSpy).not.toHaveBeenCalled();
expect(hiddenSpy).not.toHaveBeenCalled();
}
|
Acidburn0zzz/ng-bootstrap
|
src/popover/popover.spec.ts
|
TypeScript
|
ArrowFunction
|
() => {
const fixture = createTestComponent(`<div ngbPopover="Great tip!" triggers="manual"></div>`);
fixture.detectChanges();
expect(fixture.componentInstance.popover.isOpen()).toBeFalsy();
fixture.componentInstance.popover.open();
fixture.detectChanges();
expect(fixture.componentInstance.popover.isOpen()).toBeTruthy();
fixture.componentInstance.popover.close();
fixture.detectChanges();
expect(fixture.componentInstance.popover.isOpen()).toBeFalsy();
}
|
Acidburn0zzz/ng-bootstrap
|
src/popover/popover.spec.ts
|
TypeScript
|
ArrowFunction
|
() => {
beforeEach(() => { TestBed.configureTestingModule({declarations: [TestComponent], imports: [NgbPopoverModule]}); });
it('should support toggle triggers', () => {
const fixture = createTestComponent(`<div ngbPopover="Great tip!" triggers="click"></div>`);
const directive = fixture.debugElement.query(By.directive(NgbPopover));
triggerEvent(directive, 'click');
fixture.detectChanges();
expect(getWindow(fixture.nativeElement)).not.toBeNull();
triggerEvent(directive, 'click');
fixture.detectChanges();
expect(getWindow(fixture.nativeElement)).toBeNull();
});
it('should non-default toggle triggers', () => {
const fixture = createTestComponent(`<div ngbPopover="Great tip!" triggers="mouseenter:click"></div>`);
const directive = fixture.debugElement.query(By.directive(NgbPopover));
triggerEvent(directive, 'mouseenter');
fixture.detectChanges();
expect(getWindow(fixture.nativeElement)).not.toBeNull();
triggerEvent(directive, 'click');
fixture.detectChanges();
expect(getWindow(fixture.nativeElement)).toBeNull();
});
it('should support multiple triggers', () => {
const fixture = createTestComponent(`<div ngbPopover="Great tip!" triggers="mouseenter:mouseleave click"></div>`);
const directive = fixture.debugElement.query(By.directive(NgbPopover));
triggerEvent(directive, 'mouseenter');
fixture.detectChanges();
expect(getWindow(fixture.nativeElement)).not.toBeNull();
triggerEvent(directive, 'click');
fixture.detectChanges();
expect(getWindow(fixture.nativeElement)).toBeNull();
});
it('should not use default for manual triggers', () => {
const fixture = createTestComponent(`<div ngbPopover="Great tip!" triggers="manual"></div>`);
const directive = fixture.debugElement.query(By.directive(NgbPopover));
triggerEvent(directive, 'mouseenter');
fixture.detectChanges();
expect(getWindow(fixture.nativeElement)).toBeNull();
});
it('should allow toggling for manual triggers', () => {
const fixture = createTestComponent(`
<div ngbPopover="Great tip!" triggers="manual" #t="ngbPopover"></div>
<button (click)="t.toggle()">T</button>`);
const button = fixture.nativeElement.querySelector('button');
triggerEvent(button, 'click');
fixture.detectChanges();
expect(getWindow(fixture.nativeElement)).not.toBeNull();
triggerEvent(button, 'click');
fixture.detectChanges();
expect(getWindow(fixture.nativeElement)).toBeNull();
});
it('should allow open / close for manual triggers', () => {
const fixture = createTestComponent(`<div ngbPopover="Great tip!" triggers="manual" #t="ngbPopover"></div>
<button (click)="t.open()">O</button>
<button (click)="t.close()">C</button>`);
const buttons = fixture.nativeElement.querySelectorAll('button');
triggerEvent(buttons[0], 'click'); // open
fixture.detectChanges();
expect(getWindow(fixture.nativeElement)).not.toBeNull();
triggerEvent(buttons[1], 'click'); // close
fixture.detectChanges();
expect(getWindow(fixture.nativeElement)).toBeNull();
});
it('should not throw when open called for manual triggers and open popover', () => {
const fixture = createTestComponent(`
<div ngbPopover="Great tip!" triggers="manual" #t="ngbPopover"></div>
<button (click)="t.open()">O</button>`);
const button = fixture.nativeElement.querySelector('button');
triggerEvent(button, 'click'); // open
fixture.detectChanges();
expect(getWindow(fixture.nativeElement)).not.toBeNull();
triggerEvent(button, 'click'); // open
fixture.detectChanges();
expect(getWindow(fixture.nativeElement)).not.toBeNull();
});
it('should not throw when closed called for manual triggers and closed popover', () => {
const fixture = createTestComponent(`
<div ngbPopover="Great tip!" triggers="manual" #t="ngbPopover"></div>
<button (click)="t.close()">C</button>`);
const button = fixture.nativeElement.querySelector('button');
triggerEvent(button, 'click'); // close
fixture.detectChanges();
expect(getWindow(fixture.nativeElement)).toBeNull();
});
}
|
Acidburn0zzz/ng-bootstrap
|
src/popover/popover.spec.ts
|
TypeScript
|
ArrowFunction
|
() => {
const fixture = createTestComponent(`<div ngbPopover="Great tip!" triggers="click"></div>`);
const directive = fixture.debugElement.query(By.directive(NgbPopover));
triggerEvent(directive, 'click');
fixture.detectChanges();
expect(getWindow(fixture.nativeElement)).not.toBeNull();
triggerEvent(directive, 'click');
fixture.detectChanges();
expect(getWindow(fixture.nativeElement)).toBeNull();
}
|
Acidburn0zzz/ng-bootstrap
|
src/popover/popover.spec.ts
|
TypeScript
|
ArrowFunction
|
() => {
const fixture = createTestComponent(`<div ngbPopover="Great tip!" triggers="mouseenter:click"></div>`);
const directive = fixture.debugElement.query(By.directive(NgbPopover));
triggerEvent(directive, 'mouseenter');
fixture.detectChanges();
expect(getWindow(fixture.nativeElement)).not.toBeNull();
triggerEvent(directive, 'click');
fixture.detectChanges();
expect(getWindow(fixture.nativeElement)).toBeNull();
}
|
Acidburn0zzz/ng-bootstrap
|
src/popover/popover.spec.ts
|
TypeScript
|
ArrowFunction
|
() => {
const fixture = createTestComponent(`<div ngbPopover="Great tip!" triggers="mouseenter:mouseleave click"></div>`);
const directive = fixture.debugElement.query(By.directive(NgbPopover));
triggerEvent(directive, 'mouseenter');
fixture.detectChanges();
expect(getWindow(fixture.nativeElement)).not.toBeNull();
triggerEvent(directive, 'click');
fixture.detectChanges();
expect(getWindow(fixture.nativeElement)).toBeNull();
}
|
Acidburn0zzz/ng-bootstrap
|
src/popover/popover.spec.ts
|
TypeScript
|
ArrowFunction
|
() => {
const fixture = createTestComponent(`<div ngbPopover="Great tip!" triggers="manual"></div>`);
const directive = fixture.debugElement.query(By.directive(NgbPopover));
triggerEvent(directive, 'mouseenter');
fixture.detectChanges();
expect(getWindow(fixture.nativeElement)).toBeNull();
}
|
Acidburn0zzz/ng-bootstrap
|
src/popover/popover.spec.ts
|
TypeScript
|
ArrowFunction
|
() => {
const fixture = createTestComponent(`
<div ngbPopover="Great tip!" triggers="manual" #t="ngbPopover"></div>
<button (click)="t.toggle()">T</button>`);
const button = fixture.nativeElement.querySelector('button');
triggerEvent(button, 'click');
fixture.detectChanges();
expect(getWindow(fixture.nativeElement)).not.toBeNull();
triggerEvent(button, 'click');
fixture.detectChanges();
expect(getWindow(fixture.nativeElement)).toBeNull();
}
|
Acidburn0zzz/ng-bootstrap
|
src/popover/popover.spec.ts
|
TypeScript
|
ArrowFunction
|
() => {
const fixture = createTestComponent(`<div ngbPopover="Great tip!" triggers="manual" #t="ngbPopover"></div>
<button (click)="t.open()">O</button>
<button (click)="t.close()">C</button>`);
const buttons = fixture.nativeElement.querySelectorAll('button');
triggerEvent(buttons[0], 'click'); // open
fixture.detectChanges();
expect(getWindow(fixture.nativeElement)).not.toBeNull();
triggerEvent(buttons[1], 'click'); // close
fixture.detectChanges();
expect(getWindow(fixture.nativeElement)).toBeNull();
}
|
Acidburn0zzz/ng-bootstrap
|
src/popover/popover.spec.ts
|
TypeScript
|
ArrowFunction
|
() => {
const fixture = createTestComponent(`
<div ngbPopover="Great tip!" triggers="manual" #t="ngbPopover"></div>
<button (click)="t.open()">O</button>`);
const button = fixture.nativeElement.querySelector('button');
triggerEvent(button, 'click'); // open
fixture.detectChanges();
expect(getWindow(fixture.nativeElement)).not.toBeNull();
triggerEvent(button, 'click'); // open
fixture.detectChanges();
expect(getWindow(fixture.nativeElement)).not.toBeNull();
}
|
Acidburn0zzz/ng-bootstrap
|
src/popover/popover.spec.ts
|
TypeScript
|
ArrowFunction
|
() => {
const fixture = createTestComponent(`
<div ngbPopover="Great tip!" triggers="manual" #t="ngbPopover"></div>
<button (click)="t.close()">C</button>`);
const button = fixture.nativeElement.querySelector('button');
triggerEvent(button, 'click'); // close
fixture.detectChanges();
expect(getWindow(fixture.nativeElement)).toBeNull();
}
|
Acidburn0zzz/ng-bootstrap
|
src/popover/popover.spec.ts
|
TypeScript
|
ArrowFunction
|
() => {
let config: NgbPopoverConfig;
beforeEach(() => {
TestBed.configureTestingModule({imports: [NgbPopoverModule]});
TestBed.overrideComponent(TestComponent, {set: {template: `<div ngbPopover="Great tip!"></div>`}});
});
beforeEach(inject([NgbPopoverConfig], (c: NgbPopoverConfig) => {
config = c;
config.placement = 'bottom';
config.triggers = 'hover';
config.container = 'body';
config.popoverClass = 'my-custom-class';
}));
it('should initialize inputs with provided config', () => {
const fixture = TestBed.createComponent(TestComponent);
fixture.detectChanges();
const popover = fixture.componentInstance.popover;
expect(popover.placement).toBe(config.placement);
expect(popover.triggers).toBe(config.triggers);
expect(popover.container).toBe(config.container);
expect(popover.popoverClass).toBe(config.popoverClass);
});
}
|
Acidburn0zzz/ng-bootstrap
|
src/popover/popover.spec.ts
|
TypeScript
|
ArrowFunction
|
() => {
TestBed.configureTestingModule({imports: [NgbPopoverModule]});
TestBed.overrideComponent(TestComponent, {set: {template: `<div ngbPopover="Great tip!"></div>`}});
}
|
Acidburn0zzz/ng-bootstrap
|
src/popover/popover.spec.ts
|
TypeScript
|
ArrowFunction
|
(c: NgbPopoverConfig) => {
config = c;
config.placement = 'bottom';
config.triggers = 'hover';
config.container = 'body';
config.popoverClass = 'my-custom-class';
}
|
Acidburn0zzz/ng-bootstrap
|
src/popover/popover.spec.ts
|
TypeScript
|
ArrowFunction
|
() => {
const fixture = TestBed.createComponent(TestComponent);
fixture.detectChanges();
const popover = fixture.componentInstance.popover;
expect(popover.placement).toBe(config.placement);
expect(popover.triggers).toBe(config.triggers);
expect(popover.container).toBe(config.container);
expect(popover.popoverClass).toBe(config.popoverClass);
}
|
Acidburn0zzz/ng-bootstrap
|
src/popover/popover.spec.ts
|
TypeScript
|
ArrowFunction
|
() => {
let config = new NgbPopoverConfig();
config.placement = 'bottom';
config.triggers = 'hover';
config.popoverClass = 'my-custom-class';
beforeEach(() => {
TestBed.configureTestingModule(
{imports: [NgbPopoverModule], providers: [{provide: NgbPopoverConfig, useValue: config}]});
});
it('should initialize inputs with provided config as provider', () => {
const fixture = createTestComponent(`<div ngbPopover="Great tip!"></div>`);
const popover = fixture.componentInstance.popover;
expect(popover.placement).toBe(config.placement);
expect(popover.triggers).toBe(config.triggers);
expect(popover.popoverClass).toBe(config.popoverClass);
});
}
|
Acidburn0zzz/ng-bootstrap
|
src/popover/popover.spec.ts
|
TypeScript
|
ArrowFunction
|
() => {
TestBed.configureTestingModule(
{imports: [NgbPopoverModule], providers: [{provide: NgbPopoverConfig, useValue: config}]});
}
|
Acidburn0zzz/ng-bootstrap
|
src/popover/popover.spec.ts
|
TypeScript
|
ArrowFunction
|
() => {
const fixture = createTestComponent(`<div ngbPopover="Great tip!"></div>`);
const popover = fixture.componentInstance.popover;
expect(popover.placement).toBe(config.placement);
expect(popover.triggers).toBe(config.triggers);
expect(popover.popoverClass).toBe(config.popoverClass);
}
|
Acidburn0zzz/ng-bootstrap
|
src/popover/popover.spec.ts
|
TypeScript
|
ArrowFunction
|
() => {
/**
* Under very specific conditions ngOnDestroy can be invoked without calling ngOnInit first.
* See discussion in https://github.com/ng-bootstrap/ng-bootstrap/issues/2199 for more details.
*/
it('should not try to call listener cleanup function when no listeners registered', () => {
const fixture = createTestComponent(`
<ng-template #tpl><div ngbPopover="Great tip!"></div></ng-template>
<button (click)="createAndDestroyTplWithAPopover(tpl)"></button>
`);
const buttonEl = fixture.debugElement.query(By.css('button'));
triggerEvent(buttonEl, 'click');
});
}
|
Acidburn0zzz/ng-bootstrap
|
src/popover/popover.spec.ts
|
TypeScript
|
ArrowFunction
|
() => {
const fixture = createTestComponent(`
<ng-template #tpl><div ngbPopover="Great tip!"></div></ng-template>
<button (click)="createAndDestroyTplWithAPopover(tpl)"></button>
`);
const buttonEl = fixture.debugElement.query(By.css('button'));
triggerEvent(buttonEl, 'click');
}
|
Acidburn0zzz/ng-bootstrap
|
src/popover/popover.spec.ts
|
TypeScript
|
ClassDeclaration
|
@Injectable()
class SpyService {
called = false;
}
|
Acidburn0zzz/ng-bootstrap
|
src/popover/popover.spec.ts
|
TypeScript
|
ClassDeclaration
|
@Component({selector: 'test-cmpt', template: ``})
export class TestComponent {
name = 'World';
show = true;
title: string;
placement: string;
popoverClass: string;
@ViewChild(NgbPopover, {static: true}) popover: NgbPopover;
constructor(private _vcRef: ViewContainerRef) {}
createAndDestroyTplWithAPopover(tpl: TemplateRef<any>) {
this._vcRef.createEmbeddedView(tpl, {}, 0);
this._vcRef.remove(0);
}
shown() {}
hidden() {}
}
|
Acidburn0zzz/ng-bootstrap
|
src/popover/popover.spec.ts
|
TypeScript
|
ClassDeclaration
|
@Component({selector: 'test-onpush-cmpt', changeDetection: ChangeDetectionStrategy.OnPush, template: ``})
export class TestOnPushComponent {
}
|
Acidburn0zzz/ng-bootstrap
|
src/popover/popover.spec.ts
|
TypeScript
|
ClassDeclaration
|
@Component({selector: 'destroyable-cmpt', template: 'Some content'})
export class DestroyableCmpt implements OnDestroy {
constructor(private _spyService: SpyService) {}
ngOnDestroy(): void { this._spyService.called = true; }
}
|
Acidburn0zzz/ng-bootstrap
|
src/popover/popover.spec.ts
|
TypeScript
|
ClassDeclaration
|
@Component({selector: 'test-hooks', template: `<div ngbPopover="popover"></div>`})
export class TestHooksComponent implements AfterViewInit {
@ViewChild(NgbPopover, {static: true}) popover;
ngAfterViewInit() { this.popover.open(); }
}
|
Acidburn0zzz/ng-bootstrap
|
src/popover/popover.spec.ts
|
TypeScript
|
MethodDeclaration
|
createAndDestroyTplWithAPopover(tpl: TemplateRef<any>) {
this._vcRef.createEmbeddedView(tpl, {}, 0);
this._vcRef.remove(0);
}
|
Acidburn0zzz/ng-bootstrap
|
src/popover/popover.spec.ts
|
TypeScript
|
MethodDeclaration
|
shown() {}
|
Acidburn0zzz/ng-bootstrap
|
src/popover/popover.spec.ts
|
TypeScript
|
MethodDeclaration
|
hidden() {}
|
Acidburn0zzz/ng-bootstrap
|
src/popover/popover.spec.ts
|
TypeScript
|
MethodDeclaration
|
ngOnDestroy(): void { this._spyService.called = true; }
|
Acidburn0zzz/ng-bootstrap
|
src/popover/popover.spec.ts
|
TypeScript
|
MethodDeclaration
|
ngAfterViewInit() { this.popover.open(); }
|
Acidburn0zzz/ng-bootstrap
|
src/popover/popover.spec.ts
|
TypeScript
|
FunctionDeclaration
|
/**
* Creates and initializes a basic panel state.
*/
export function createPanelState<
TEmbeddableInput extends EmbeddableInput,
TPlacementMethodArgs extends IPanelPlacementArgs = IPanelPlacementArgs
>(
panelState: PanelState<TEmbeddableInput>,
currentPanels: { [key: string]: DashboardPanelState },
placementMethod?: PanelPlacementMethod<TPlacementMethodArgs>,
placementArgs?: TPlacementMethodArgs
): DashboardPanelState<TEmbeddableInput> {
const defaultPlacementArgs = {
width: DEFAULT_PANEL_WIDTH,
height: DEFAULT_PANEL_HEIGHT,
currentPanels,
};
const finalPlacementArgs = placementArgs
? {
...defaultPlacementArgs,
...placementArgs,
}
: defaultPlacementArgs;
const gridDataLocation = placementMethod
? placementMethod(finalPlacementArgs as TPlacementMethodArgs)
: findTopLeftMostOpenSpace(defaultPlacementArgs);
return {
gridData: {
...gridDataLocation,
i: panelState.explicitInput.id,
},
...panelState,
};
}
|
AntonPalyok/kibana
|
src/plugins/dashboard/public/application/embeddable/panel/create_panel_state.ts
|
TypeScript
|
ClassDeclaration
|
export default class BlogPost extends Component<any, any> {
static contextTypes = {
auth: PropTypes.instanceOf(AuthService).isRequired
};
constructor() {
super();
this.state = {
post: null,
comments: []
};
}
componentWillMount() {
this.fetchBlogPost();
}
render() {
const auth: AuthService = this.context.auth;
const { post, comments } = this.state;
const user = auth.getProfile();
log.info(`Rendering post`, post);
return (
<div>
<BlogPostDetail post={post}/>
<CommentThread comments={comments} user={user}
onCommented={(content: string) => this.submitComment(user, post, content)}
|
dflor003/react-blogger
|
app/views/BlogPost/BlogPost.tsx
|
TypeScript
|
MethodDeclaration
|
componentWillMount() {
this.fetchBlogPost();
}
|
dflor003/react-blogger
|
app/views/BlogPost/BlogPost.tsx
|
TypeScript
|
MethodDeclaration
|
render() {
const auth: AuthService = this.context.auth;
const { post, comments } = this.state;
const user = auth.getProfile();
log.info(`Rendering post`, post);
return (
<div>
<BlogPostDetail post={post}/>
<CommentThread comments={comments} user={user}
onCommented={(content: string) => this.submitComment(user, post, content)}
|
dflor003/react-blogger
|
app/views/BlogPost/BlogPost.tsx
|
TypeScript
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.