mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
test(ngmodule): update to ngmodule
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
import { Component } from '@angular/core';
|
||||
import { App, ionicBootstrap } from '../../../../../src';
|
||||
import { NgModule, Component } from '@angular/core';
|
||||
import { IonicApp, IonicModule } from '../../../..';
|
||||
|
||||
|
||||
@Component({
|
||||
templateUrl: 'main.html'
|
||||
})
|
||||
class E2EPage {
|
||||
export class E2EPage {
|
||||
isFull: boolean = true;
|
||||
isBlock: boolean = true;
|
||||
isBarClear: boolean = true;
|
||||
@@ -20,10 +20,6 @@ class E2EPage {
|
||||
isDanger: string = 'danger';
|
||||
isDark: string = 'dark';
|
||||
|
||||
constructor(app: App) {
|
||||
|
||||
}
|
||||
|
||||
toggleBlock() {
|
||||
this.isFull = !this.isFull;
|
||||
this.isBlock = !this.isBlock;
|
||||
@@ -50,15 +46,28 @@ class E2EPage {
|
||||
removeColors() {
|
||||
this.isSecondary = null;
|
||||
this.isDanger = null;
|
||||
this.isDark = null;
|
||||
this.isDark = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Component({
|
||||
template: '<ion-nav [root]="rootPage"></ion-nav>'
|
||||
})
|
||||
class E2EApp {
|
||||
export class E2EApp {
|
||||
rootPage = E2EPage;
|
||||
}
|
||||
|
||||
ionicBootstrap(E2EApp);
|
||||
@NgModule({
|
||||
declarations: [
|
||||
E2EApp,
|
||||
E2EPage
|
||||
],
|
||||
imports: [
|
||||
IonicModule.forRoot(E2EApp)
|
||||
],
|
||||
bootstrap: [IonicApp],
|
||||
entryComponents: [
|
||||
E2EPage
|
||||
]
|
||||
})
|
||||
export class AppModule {}
|
||||
@@ -1,11 +1,11 @@
|
||||
import { Component } from '@angular/core';
|
||||
import { App, ionicBootstrap } from '../../../../../src';
|
||||
import { NgModule, Component } from '@angular/core';
|
||||
import { IonicApp, IonicModule, App } from '../../../..';
|
||||
|
||||
|
||||
@Component({
|
||||
templateUrl: 'main.html'
|
||||
})
|
||||
class E2EPage {
|
||||
export class E2EPage {
|
||||
btnColor: string;
|
||||
testingColors = ['primary', 'secondary', 'danger', 'dark'];
|
||||
testingColorIndex = 0;
|
||||
@@ -25,8 +25,22 @@ class E2EPage {
|
||||
@Component({
|
||||
template: '<ion-nav [root]="rootPage"></ion-nav>'
|
||||
})
|
||||
class E2EApp {
|
||||
export class E2EApp {
|
||||
rootPage = E2EPage;
|
||||
}
|
||||
|
||||
ionicBootstrap(E2EApp);
|
||||
|
||||
@NgModule({
|
||||
declarations: [
|
||||
E2EApp,
|
||||
E2EPage
|
||||
],
|
||||
imports: [
|
||||
IonicModule.forRoot(E2EApp)
|
||||
],
|
||||
bootstrap: [IonicApp],
|
||||
entryComponents: [
|
||||
E2EPage
|
||||
]
|
||||
})
|
||||
export class AppModule {}
|
||||
38
src/components/button/test/block/app-module.ts
Normal file
38
src/components/button/test/block/app-module.ts
Normal file
@@ -0,0 +1,38 @@
|
||||
import { Component, NgModule } from '@angular/core';
|
||||
import { IonicApp, IonicModule } from '../../../..';
|
||||
|
||||
|
||||
@Component({
|
||||
templateUrl: 'main.html'
|
||||
})
|
||||
export class E2EPage {
|
||||
blockButton = true;
|
||||
|
||||
toggleBlock() {
|
||||
this.blockButton = !this.blockButton;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Component({
|
||||
template: '<ion-nav [root]="rootPage"></ion-nav>'
|
||||
})
|
||||
export class E2EApp {
|
||||
rootPage = E2EPage;
|
||||
}
|
||||
|
||||
|
||||
@NgModule({
|
||||
declarations: [
|
||||
E2EApp,
|
||||
E2EPage
|
||||
],
|
||||
imports: [
|
||||
IonicModule.forRoot(E2EApp)
|
||||
],
|
||||
bootstrap: [IonicApp],
|
||||
entryComponents: [
|
||||
E2EPage
|
||||
]
|
||||
})
|
||||
export class AppModule {}
|
||||
@@ -1,23 +0,0 @@
|
||||
import { Component } from '@angular/core';
|
||||
import { ionicBootstrap } from '../../../../../src';
|
||||
|
||||
|
||||
@Component({
|
||||
templateUrl: 'main.html'
|
||||
})
|
||||
class E2EPage {
|
||||
blockButton = true;
|
||||
|
||||
toggleBlock() {
|
||||
this.blockButton = !this.blockButton;
|
||||
}
|
||||
}
|
||||
|
||||
@Component({
|
||||
template: '<ion-nav [root]="rootPage"></ion-nav>'
|
||||
})
|
||||
class E2EApp {
|
||||
rootPage = E2EPage;
|
||||
}
|
||||
|
||||
ionicBootstrap(E2EApp);
|
||||
@@ -1,261 +1,251 @@
|
||||
import { Button, Config } from '../../../../src';
|
||||
import { Button } from '../button';
|
||||
import { Config } from '../../../config/config';
|
||||
import { mockConfig, mockElementRef, mockRenderer } from '../../../util/mock-providers';
|
||||
|
||||
|
||||
export function run() {
|
||||
describe('button', () => {
|
||||
|
||||
describe('button', () => {
|
||||
it('should set a different button role', () => {
|
||||
let b = mockButton();
|
||||
b.outline = true;
|
||||
b.small = true;
|
||||
b.full = true;
|
||||
b.color = 'primary';
|
||||
b.setRole('bar-button');
|
||||
b._assignCss(true);
|
||||
|
||||
it('should set a different button role', () => {
|
||||
let b = mockButton();
|
||||
b.outline = true;
|
||||
b.small = true;
|
||||
b.full = true;
|
||||
b.color = 'primary';
|
||||
b.setRole('bar-button');
|
||||
b._assignCss(true);
|
||||
|
||||
expect(hasClass(b, 'bar-button-outline')).toEqual(true);
|
||||
expect(hasClass(b, 'bar-button-small')).toEqual(true);
|
||||
expect(hasClass(b, 'bar-button-full')).toEqual(true);
|
||||
expect(hasClass(b, 'bar-button-outline-primary')).toEqual(true);
|
||||
|
||||
expect(hasClass(b, 'button-outline')).toEqual(false);
|
||||
expect(hasClass(b, 'button-small')).toEqual(false);
|
||||
expect(hasClass(b, 'button-full')).toEqual(false);
|
||||
expect(hasClass(b, 'button-primary')).toEqual(false);
|
||||
});
|
||||
|
||||
it('should remove button color attributes and add different role', () => {
|
||||
let b = mockButton();
|
||||
b.outline = true;
|
||||
b.small = true;
|
||||
b.full = true;
|
||||
b.color = 'primary';
|
||||
|
||||
b._assignCss(true);
|
||||
expect(hasClass(b, 'button-outline')).toEqual(true);
|
||||
expect(hasClass(b, 'button-small')).toEqual(true);
|
||||
expect(hasClass(b, 'button-full')).toEqual(true);
|
||||
expect(hasClass(b, 'button-outline-primary')).toEqual(true);
|
||||
|
||||
b._assignCss(false);
|
||||
expect(hasClass(b, 'button-outline')).toEqual(false);
|
||||
expect(hasClass(b, 'button-small')).toEqual(false);
|
||||
expect(hasClass(b, 'button-full')).toEqual(false);
|
||||
expect(hasClass(b, 'button-outline-primary')).toEqual(false);
|
||||
});
|
||||
|
||||
it('should read button color attributes with styles', () => {
|
||||
let b = mockButton();
|
||||
b.outline = true;
|
||||
b.small = true;
|
||||
b.full = true;
|
||||
b.color = 'primary';
|
||||
|
||||
b._assignCss(true);
|
||||
expect(hasClass(b, 'button')).toEqual(true);
|
||||
expect(hasClass(b, 'button-outline')).toEqual(true);
|
||||
expect(hasClass(b, 'button-small')).toEqual(true);
|
||||
expect(hasClass(b, 'button-full')).toEqual(true);
|
||||
expect(hasClass(b, 'button-outline-primary')).toEqual(true);
|
||||
|
||||
b = mockButton();
|
||||
b.clear = true;
|
||||
b.color = 'primary';
|
||||
b.color = 'secondary';
|
||||
|
||||
b._assignCss(true);
|
||||
expect(hasClass(b, 'button')).toEqual(true);
|
||||
expect(hasClass(b, 'button-clear')).toEqual(true);
|
||||
expect(hasClass(b, 'button-clear-primary')).toEqual(false);
|
||||
expect(hasClass(b, 'button-clear-secondary')).toEqual(true);
|
||||
|
||||
b = mockButton();
|
||||
b.solid = true;
|
||||
b.color = 'primary';
|
||||
b.color = 'secondary';
|
||||
|
||||
b._assignCss(true);
|
||||
expect(hasClass(b, 'button')).toEqual(true);
|
||||
expect(hasClass(b, 'button-solid')).toEqual(true);
|
||||
expect(hasClass(b, 'button-primary')).toEqual(false);
|
||||
expect(hasClass(b, 'button-secondary')).toEqual(true);
|
||||
|
||||
b = mockButton();
|
||||
b.solid = true;
|
||||
b.color = 'primary';
|
||||
b.color = 'secondary';
|
||||
|
||||
b.setRole('bar-button');
|
||||
b._assignCss(true);
|
||||
expect(hasClass(b, 'bar-button-solid')).toEqual(true);
|
||||
expect(hasClass(b, 'bar-button-solid-primary')).toEqual(false);
|
||||
expect(hasClass(b, 'bar-button-solid-secondary')).toEqual(true);
|
||||
});
|
||||
|
||||
it('should auto add the default style', () => {
|
||||
let b = mockButton();
|
||||
b._assignCss(true);
|
||||
expect(hasClass(b, 'button')).toEqual(true);
|
||||
expect(hasClass(b, 'button-default')).toEqual(true);
|
||||
|
||||
b = mockButton();
|
||||
b.clear = true;
|
||||
|
||||
b._assignCss(true);
|
||||
expect(hasClass(b, 'button')).toEqual(true);
|
||||
expect(hasClass(b, 'button-default')).toEqual(false);
|
||||
expect(hasClass(b, 'button-clear')).toEqual(true);
|
||||
});
|
||||
|
||||
it('should read button color attributes', () => {
|
||||
let b = mockButton();
|
||||
b.color = 'primary';
|
||||
b._assignCss(true);
|
||||
expect(hasClass(b, 'button-primary')).toEqual(true);
|
||||
|
||||
b = mockButton();
|
||||
b.color = 'primary';
|
||||
b.color = 'secondary';
|
||||
b._assignCss(true);
|
||||
expect(hasClass(b, 'button-primary')).toEqual(false);
|
||||
expect(hasClass(b, 'button-secondary')).toEqual(true);
|
||||
});
|
||||
|
||||
it('should read button style attributes', () => {
|
||||
let b = mockButton();
|
||||
b.clear = true;
|
||||
b._assignCss(true);
|
||||
expect(hasClass(b, 'button-clear')).toEqual(true);
|
||||
|
||||
b = mockButton();
|
||||
b.outline = true;
|
||||
b._assignCss(true);
|
||||
expect(hasClass(b, 'button-outline')).toEqual(true);
|
||||
|
||||
b = mockButton();
|
||||
b.solid = true;
|
||||
b._assignCss(true);
|
||||
expect(hasClass(b, 'button-solid')).toEqual(true);
|
||||
|
||||
b = mockButton();
|
||||
b.clear = true;
|
||||
b.outline = true;
|
||||
b.small = true;
|
||||
b.full = true;
|
||||
b._assignCss(true);
|
||||
expect(hasClass(b, 'button-clear')).toEqual(false);
|
||||
expect(hasClass(b, 'button-outline')).toEqual(true);
|
||||
expect(hasClass(b, 'button-small')).toEqual(true);
|
||||
expect(hasClass(b, 'button-full')).toEqual(true);
|
||||
|
||||
b = mockButton();
|
||||
b.outline = true;
|
||||
b.setRole('bar-button');
|
||||
b._assignCss(true);
|
||||
expect(hasClass(b, 'bar-button-outline')).toEqual(true);
|
||||
});
|
||||
|
||||
it('should read button shape attributes', () => {
|
||||
let b = mockButton();
|
||||
b.round = true;
|
||||
b._assignCss(true);
|
||||
expect(hasClass(b, 'button-round')).toEqual(true);
|
||||
|
||||
b = mockButton();
|
||||
b.fab = true;
|
||||
b._assignCss(true);
|
||||
expect(hasClass(b, 'button-fab')).toEqual(true);
|
||||
});
|
||||
|
||||
it('should read button display attributes', () => {
|
||||
let b = mockButton();
|
||||
b.block = true;
|
||||
b._assignCss(true);
|
||||
expect(hasClass(b, 'button-block')).toEqual(true);
|
||||
|
||||
b = mockButton();
|
||||
b.full = true;
|
||||
b._assignCss(true);
|
||||
expect(hasClass(b, 'button-full')).toEqual(true);
|
||||
|
||||
b = mockButton();
|
||||
b.block = true;
|
||||
b.full = true;
|
||||
b._assignCss(true);
|
||||
expect(hasClass(b, 'button-block')).toEqual(false);
|
||||
expect(hasClass(b, 'button-full')).toEqual(true);
|
||||
});
|
||||
|
||||
it('should read button size attributes', () => {
|
||||
let b = mockButton();
|
||||
b.small = true;
|
||||
b._assignCss(true);
|
||||
expect(hasClass(b, 'button-small')).toEqual(true);
|
||||
|
||||
b = mockButton();
|
||||
b.large = true;
|
||||
b._assignCss(true);
|
||||
expect(hasClass(b, 'button-large')).toEqual(true);
|
||||
|
||||
b = mockButton();
|
||||
b.large = true;
|
||||
b.small = true;
|
||||
b._assignCss(true);
|
||||
expect(hasClass(b, 'button-large')).toEqual(false);
|
||||
expect(hasClass(b, 'button-small')).toEqual(true);
|
||||
});
|
||||
|
||||
it('should add button css class', () => {
|
||||
let b = mockButton();
|
||||
b._assignCss(true);
|
||||
expect(hasClass(b, 'button')).toEqual(true);
|
||||
});
|
||||
|
||||
it('should add disable-hover css class', () => {
|
||||
let config = new Config({
|
||||
hoverCSS: false
|
||||
});
|
||||
let b = mockButton(config);
|
||||
|
||||
expect(hasClass(b, 'disable-hover')).toEqual(true);
|
||||
});
|
||||
|
||||
it('should set defaults', () => {
|
||||
let b = mockButton();
|
||||
expect(b._role).toEqual('button');
|
||||
expect(b._size).toEqual(null);
|
||||
expect(b._color).toEqual(null);
|
||||
expect(b._style).toEqual('default');
|
||||
expect(b._display).toEqual(null);
|
||||
});
|
||||
|
||||
it('should add alert-button css class', () => {
|
||||
let b = mockButton(null, 'alert-button');
|
||||
b._assignCss(true);
|
||||
expect(hasClass(b, 'alert-button')).toEqual(true);
|
||||
});
|
||||
expect(hasClass(b, 'bar-button-outline')).toEqual(true);
|
||||
expect(hasClass(b, 'bar-button-small')).toEqual(true);
|
||||
expect(hasClass(b, 'bar-button-full')).toEqual(true);
|
||||
expect(hasClass(b, 'bar-button-outline-primary')).toEqual(true);
|
||||
|
||||
expect(hasClass(b, 'button-outline')).toEqual(false);
|
||||
expect(hasClass(b, 'button-small')).toEqual(false);
|
||||
expect(hasClass(b, 'button-full')).toEqual(false);
|
||||
expect(hasClass(b, 'button-primary')).toEqual(false);
|
||||
});
|
||||
|
||||
function mockButton(config?, ionButton?) {
|
||||
config = config || new Config();
|
||||
ionButton = ionButton || '';
|
||||
let elementRef = {
|
||||
nativeElement: document.createElement('button')
|
||||
};
|
||||
let renderer: any = {
|
||||
setElementClass: function(nativeElement, className, shouldAdd) {
|
||||
nativeElement.classList[shouldAdd ? 'add' : 'remove'](className);
|
||||
}
|
||||
};
|
||||
let b = new Button(null, ionButton, config, elementRef, renderer);
|
||||
b._init = true;
|
||||
return b;
|
||||
}
|
||||
it('should remove button color attributes and add different role', () => {
|
||||
let b = mockButton();
|
||||
b.outline = true;
|
||||
b.small = true;
|
||||
b.full = true;
|
||||
b.color = 'primary';
|
||||
|
||||
function hasClass(button, className) {
|
||||
return button._elementRef.nativeElement.classList.contains(className);
|
||||
}
|
||||
b._assignCss(true);
|
||||
expect(hasClass(b, 'button-outline')).toEqual(true);
|
||||
expect(hasClass(b, 'button-small')).toEqual(true);
|
||||
expect(hasClass(b, 'button-full')).toEqual(true);
|
||||
expect(hasClass(b, 'button-outline-primary')).toEqual(true);
|
||||
|
||||
b._assignCss(false);
|
||||
expect(hasClass(b, 'button-outline')).toEqual(false);
|
||||
expect(hasClass(b, 'button-small')).toEqual(false);
|
||||
expect(hasClass(b, 'button-full')).toEqual(false);
|
||||
expect(hasClass(b, 'button-outline-primary')).toEqual(false);
|
||||
});
|
||||
|
||||
it('should read button color attributes with styles', () => {
|
||||
let b = mockButton();
|
||||
b.outline = true;
|
||||
b.small = true;
|
||||
b.full = true;
|
||||
b.color = 'primary';
|
||||
|
||||
b._assignCss(true);
|
||||
expect(hasClass(b, 'button')).toEqual(true);
|
||||
expect(hasClass(b, 'button-outline')).toEqual(true);
|
||||
expect(hasClass(b, 'button-small')).toEqual(true);
|
||||
expect(hasClass(b, 'button-full')).toEqual(true);
|
||||
expect(hasClass(b, 'button-outline-primary')).toEqual(true);
|
||||
|
||||
b = mockButton();
|
||||
b.clear = true;
|
||||
b.color = 'primary';
|
||||
b.color = 'secondary';
|
||||
|
||||
b._assignCss(true);
|
||||
expect(hasClass(b, 'button')).toEqual(true);
|
||||
expect(hasClass(b, 'button-clear')).toEqual(true);
|
||||
expect(hasClass(b, 'button-clear-primary')).toEqual(false);
|
||||
expect(hasClass(b, 'button-clear-secondary')).toEqual(true);
|
||||
|
||||
b = mockButton();
|
||||
b.solid = true;
|
||||
b.color = 'primary';
|
||||
b.color = 'secondary';
|
||||
|
||||
b._assignCss(true);
|
||||
expect(hasClass(b, 'button')).toEqual(true);
|
||||
expect(hasClass(b, 'button-solid')).toEqual(true);
|
||||
expect(hasClass(b, 'button-primary')).toEqual(false);
|
||||
expect(hasClass(b, 'button-secondary')).toEqual(true);
|
||||
|
||||
b = mockButton();
|
||||
b.solid = true;
|
||||
b.color = 'primary';
|
||||
b.color = 'secondary';
|
||||
|
||||
b.setRole('bar-button');
|
||||
b._assignCss(true);
|
||||
expect(hasClass(b, 'bar-button-solid')).toEqual(true);
|
||||
expect(hasClass(b, 'bar-button-solid-primary')).toEqual(false);
|
||||
expect(hasClass(b, 'bar-button-solid-secondary')).toEqual(true);
|
||||
});
|
||||
|
||||
it('should auto add the default style', () => {
|
||||
let b = mockButton();
|
||||
b._assignCss(true);
|
||||
expect(hasClass(b, 'button')).toEqual(true);
|
||||
expect(hasClass(b, 'button-default')).toEqual(true);
|
||||
|
||||
b = mockButton();
|
||||
b.clear = true;
|
||||
|
||||
b._assignCss(true);
|
||||
expect(hasClass(b, 'button')).toEqual(true);
|
||||
expect(hasClass(b, 'button-default')).toEqual(false);
|
||||
expect(hasClass(b, 'button-clear')).toEqual(true);
|
||||
});
|
||||
|
||||
it('should read button color attributes', () => {
|
||||
let b = mockButton();
|
||||
b.color = 'primary';
|
||||
b._assignCss(true);
|
||||
expect(hasClass(b, 'button-primary')).toEqual(true);
|
||||
|
||||
b = mockButton();
|
||||
b.color = 'primary';
|
||||
b.color = 'secondary';
|
||||
b._assignCss(true);
|
||||
expect(hasClass(b, 'button-primary')).toEqual(false);
|
||||
expect(hasClass(b, 'button-secondary')).toEqual(true);
|
||||
});
|
||||
|
||||
it('should read button style attributes', () => {
|
||||
let b = mockButton();
|
||||
b.clear = true;
|
||||
b._assignCss(true);
|
||||
expect(hasClass(b, 'button-clear')).toEqual(true);
|
||||
|
||||
b = mockButton();
|
||||
b.outline = true;
|
||||
b._assignCss(true);
|
||||
expect(hasClass(b, 'button-outline')).toEqual(true);
|
||||
|
||||
b = mockButton();
|
||||
b.solid = true;
|
||||
b._assignCss(true);
|
||||
expect(hasClass(b, 'button-solid')).toEqual(true);
|
||||
|
||||
b = mockButton();
|
||||
b.clear = true;
|
||||
b.outline = true;
|
||||
b.small = true;
|
||||
b.full = true;
|
||||
b._assignCss(true);
|
||||
expect(hasClass(b, 'button-clear')).toEqual(false);
|
||||
expect(hasClass(b, 'button-outline')).toEqual(true);
|
||||
expect(hasClass(b, 'button-small')).toEqual(true);
|
||||
expect(hasClass(b, 'button-full')).toEqual(true);
|
||||
|
||||
b = mockButton();
|
||||
b.outline = true;
|
||||
b.setRole('bar-button');
|
||||
b._assignCss(true);
|
||||
expect(hasClass(b, 'bar-button-outline')).toEqual(true);
|
||||
});
|
||||
|
||||
it('should read button shape attributes', () => {
|
||||
let b = mockButton();
|
||||
b.round = true;
|
||||
b._assignCss(true);
|
||||
expect(hasClass(b, 'button-round')).toEqual(true);
|
||||
|
||||
b = mockButton();
|
||||
b.fab = true;
|
||||
b._assignCss(true);
|
||||
expect(hasClass(b, 'button-fab')).toEqual(true);
|
||||
});
|
||||
|
||||
it('should read button display attributes', () => {
|
||||
let b = mockButton();
|
||||
b.block = true;
|
||||
b._assignCss(true);
|
||||
expect(hasClass(b, 'button-block')).toEqual(true);
|
||||
|
||||
b = mockButton();
|
||||
b.full = true;
|
||||
b._assignCss(true);
|
||||
expect(hasClass(b, 'button-full')).toEqual(true);
|
||||
|
||||
b = mockButton();
|
||||
b.block = true;
|
||||
b.full = true;
|
||||
b._assignCss(true);
|
||||
expect(hasClass(b, 'button-block')).toEqual(false);
|
||||
expect(hasClass(b, 'button-full')).toEqual(true);
|
||||
});
|
||||
|
||||
it('should read button size attributes', () => {
|
||||
let b = mockButton();
|
||||
b.small = true;
|
||||
b._assignCss(true);
|
||||
expect(hasClass(b, 'button-small')).toEqual(true);
|
||||
|
||||
b = mockButton();
|
||||
b.large = true;
|
||||
b._assignCss(true);
|
||||
expect(hasClass(b, 'button-large')).toEqual(true);
|
||||
|
||||
b = mockButton();
|
||||
b.large = true;
|
||||
b.small = true;
|
||||
b._assignCss(true);
|
||||
expect(hasClass(b, 'button-large')).toEqual(false);
|
||||
expect(hasClass(b, 'button-small')).toEqual(true);
|
||||
});
|
||||
|
||||
it('should add button css class', () => {
|
||||
let b = mockButton();
|
||||
b._assignCss(true);
|
||||
expect(hasClass(b, 'button')).toEqual(true);
|
||||
});
|
||||
|
||||
it('should add disable-hover css class', () => {
|
||||
let config = mockConfig({
|
||||
hoverCSS: false
|
||||
});
|
||||
let b = mockButton(config);
|
||||
|
||||
expect(hasClass(b, 'disable-hover')).toEqual(true);
|
||||
});
|
||||
|
||||
it('should set defaults', () => {
|
||||
let b = mockButton();
|
||||
expect(b._role).toEqual('button');
|
||||
expect(b._size).toEqual(undefined);
|
||||
expect(b._color).toEqual(undefined);
|
||||
expect(b._style).toEqual('default');
|
||||
expect(b._display).toEqual(undefined);
|
||||
});
|
||||
|
||||
it('should add alert-button css class', () => {
|
||||
let b = mockButton(null, 'alert-button');
|
||||
b._assignCss(true);
|
||||
expect(hasClass(b, 'alert-button')).toEqual(true);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
function mockButton(config?: Config, ionButton?: string) {
|
||||
config = config || mockConfig();
|
||||
ionButton = ionButton || '';
|
||||
let b = new Button(null, ionButton, config, mockElementRef(), mockRenderer());
|
||||
b._init = true;
|
||||
return b;
|
||||
}
|
||||
|
||||
function hasClass(button, className) {
|
||||
return button._elementRef.nativeElement.classList.contains(className);
|
||||
}
|
||||
|
||||
36
src/components/button/test/clear/app-module.ts
Normal file
36
src/components/button/test/clear/app-module.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
import { Component, NgModule } from '@angular/core';
|
||||
import { IonicApp, IonicModule } from '../../../..';
|
||||
|
||||
|
||||
@Component({
|
||||
templateUrl: 'main.html'
|
||||
})
|
||||
export class E2EPage {
|
||||
clearButton = true;
|
||||
|
||||
toggleClear() {
|
||||
this.clearButton = !this.clearButton;
|
||||
}
|
||||
}
|
||||
|
||||
@Component({
|
||||
template: '<ion-nav [root]="rootPage"></ion-nav>'
|
||||
})
|
||||
export class E2EApp {
|
||||
rootPage = E2EPage;
|
||||
}
|
||||
|
||||
@NgModule({
|
||||
declarations: [
|
||||
E2EApp,
|
||||
E2EPage
|
||||
],
|
||||
imports: [
|
||||
IonicModule.forRoot(E2EApp)
|
||||
],
|
||||
bootstrap: [IonicApp],
|
||||
entryComponents: [
|
||||
E2EPage
|
||||
]
|
||||
})
|
||||
export class AppModule {}
|
||||
@@ -1,23 +0,0 @@
|
||||
import { Component } from '@angular/core';
|
||||
import { ionicBootstrap } from '../../../../../src';
|
||||
|
||||
|
||||
@Component({
|
||||
templateUrl: 'main.html'
|
||||
})
|
||||
class E2EPage {
|
||||
clearButton = true;
|
||||
|
||||
toggleClear() {
|
||||
this.clearButton = !this.clearButton;
|
||||
}
|
||||
}
|
||||
|
||||
@Component({
|
||||
template: '<ion-nav [root]="rootPage"></ion-nav>'
|
||||
})
|
||||
class E2EApp {
|
||||
rootPage = E2EPage;
|
||||
}
|
||||
|
||||
ionicBootstrap(E2EApp);
|
||||
@@ -1,11 +1,11 @@
|
||||
import { Component } from '@angular/core';
|
||||
import { ionicBootstrap } from '../../../../../src';
|
||||
import { Component, NgModule } from '@angular/core';
|
||||
import { IonicApp, IonicModule } from '../../../..';
|
||||
|
||||
|
||||
@Component({
|
||||
templateUrl: 'main.html'
|
||||
})
|
||||
class E2EPage {
|
||||
export class E2EPage {
|
||||
isDestructive: boolean;
|
||||
isSecondary: boolean;
|
||||
isCustom: boolean;
|
||||
@@ -54,8 +54,21 @@ class E2EPage {
|
||||
@Component({
|
||||
template: '<ion-nav [root]="rootPage"></ion-nav>'
|
||||
})
|
||||
class E2EApp {
|
||||
export class E2EApp {
|
||||
rootPage = E2EPage;
|
||||
}
|
||||
|
||||
ionicBootstrap(E2EApp);
|
||||
@NgModule({
|
||||
declarations: [
|
||||
E2EApp,
|
||||
E2EPage
|
||||
],
|
||||
imports: [
|
||||
IonicModule.forRoot(E2EApp)
|
||||
],
|
||||
bootstrap: [IonicApp],
|
||||
entryComponents: [
|
||||
E2EPage
|
||||
]
|
||||
})
|
||||
export class AppModule {}
|
||||
30
src/components/button/test/fab/app-module.ts
Normal file
30
src/components/button/test/fab/app-module.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import { Component, NgModule } from '@angular/core';
|
||||
import { IonicApp, IonicModule } from '../../../..';
|
||||
|
||||
|
||||
@Component({
|
||||
templateUrl: 'main.html'
|
||||
})
|
||||
export class E2EPage {}
|
||||
|
||||
@Component({
|
||||
template: '<ion-nav [root]="rootPage"></ion-nav>'
|
||||
})
|
||||
export class E2EApp {
|
||||
rootPage = E2EPage;
|
||||
}
|
||||
|
||||
@NgModule({
|
||||
declarations: [
|
||||
E2EApp,
|
||||
E2EPage
|
||||
],
|
||||
imports: [
|
||||
IonicModule.forRoot(E2EApp)
|
||||
],
|
||||
bootstrap: [IonicApp],
|
||||
entryComponents: [
|
||||
E2EPage
|
||||
]
|
||||
})
|
||||
export class AppModule {}
|
||||
@@ -1,17 +0,0 @@
|
||||
import { Component } from '@angular/core';
|
||||
import { ionicBootstrap } from '../../../../../src';
|
||||
|
||||
|
||||
@Component({
|
||||
templateUrl: 'main.html'
|
||||
})
|
||||
class E2EPage {}
|
||||
|
||||
@Component({
|
||||
template: '<ion-nav [root]="rootPage"></ion-nav>'
|
||||
})
|
||||
class E2EApp {
|
||||
rootPage = E2EPage;
|
||||
}
|
||||
|
||||
ionicBootstrap(E2EApp);
|
||||
30
src/components/button/test/full/app-module.ts
Normal file
30
src/components/button/test/full/app-module.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import { Component, NgModule } from '@angular/core';
|
||||
import { IonicApp, IonicModule } from '../../../..';
|
||||
|
||||
|
||||
@Component({
|
||||
templateUrl: 'main.html'
|
||||
})
|
||||
export class E2EPage {}
|
||||
|
||||
@Component({
|
||||
template: '<ion-nav [root]="rootPage"></ion-nav>'
|
||||
})
|
||||
export class E2EApp {
|
||||
rootPage = E2EPage;
|
||||
}
|
||||
|
||||
@NgModule({
|
||||
declarations: [
|
||||
E2EApp,
|
||||
E2EPage
|
||||
],
|
||||
imports: [
|
||||
IonicModule.forRoot(E2EApp)
|
||||
],
|
||||
bootstrap: [IonicApp],
|
||||
entryComponents: [
|
||||
E2EPage
|
||||
]
|
||||
})
|
||||
export class AppModule {}
|
||||
@@ -1,17 +0,0 @@
|
||||
import { Component } from '@angular/core';
|
||||
import { ionicBootstrap } from '../../../../../src';
|
||||
|
||||
|
||||
@Component({
|
||||
templateUrl: 'main.html'
|
||||
})
|
||||
class E2EPage {}
|
||||
|
||||
@Component({
|
||||
template: '<ion-nav [root]="rootPage"></ion-nav>'
|
||||
})
|
||||
class E2EApp {
|
||||
rootPage = E2EPage;
|
||||
}
|
||||
|
||||
ionicBootstrap(E2EApp);
|
||||
30
src/components/button/test/icons/app-module.ts
Normal file
30
src/components/button/test/icons/app-module.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import { Component, NgModule } from '@angular/core';
|
||||
import { IonicApp, IonicModule } from '../../../..';
|
||||
|
||||
|
||||
@Component({
|
||||
templateUrl: 'main.html'
|
||||
})
|
||||
export class E2EPage {}
|
||||
|
||||
@Component({
|
||||
template: '<ion-nav [root]="rootPage"></ion-nav>'
|
||||
})
|
||||
export class E2EApp {
|
||||
rootPage = E2EPage;
|
||||
}
|
||||
|
||||
@NgModule({
|
||||
declarations: [
|
||||
E2EApp,
|
||||
E2EPage
|
||||
],
|
||||
imports: [
|
||||
IonicModule.forRoot(E2EApp)
|
||||
],
|
||||
bootstrap: [IonicApp],
|
||||
entryComponents: [
|
||||
E2EPage
|
||||
]
|
||||
})
|
||||
export class AppModule {}
|
||||
@@ -1,17 +0,0 @@
|
||||
import { Component } from '@angular/core';
|
||||
import { ionicBootstrap } from '../../../../../src';
|
||||
|
||||
|
||||
@Component({
|
||||
templateUrl: 'main.html'
|
||||
})
|
||||
class E2EPage {}
|
||||
|
||||
@Component({
|
||||
template: '<ion-nav [root]="rootPage"></ion-nav>'
|
||||
})
|
||||
class E2EApp {
|
||||
rootPage = E2EPage;
|
||||
}
|
||||
|
||||
ionicBootstrap(E2EApp);
|
||||
36
src/components/button/test/outline/app-module.ts
Normal file
36
src/components/button/test/outline/app-module.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
import { Component, NgModule } from '@angular/core';
|
||||
import { IonicApp, IonicModule } from '../../../..';
|
||||
|
||||
|
||||
@Component({
|
||||
templateUrl: 'main.html'
|
||||
})
|
||||
export class E2EPage {
|
||||
outlineButton = true;
|
||||
|
||||
toggleOutline() {
|
||||
this.outlineButton = !this.outlineButton;
|
||||
}
|
||||
}
|
||||
|
||||
@Component({
|
||||
template: '<ion-nav [root]="rootPage"></ion-nav>'
|
||||
})
|
||||
export class E2EApp {
|
||||
rootPage = E2EPage;
|
||||
}
|
||||
|
||||
@NgModule({
|
||||
declarations: [
|
||||
E2EApp,
|
||||
E2EPage
|
||||
],
|
||||
imports: [
|
||||
IonicModule.forRoot(E2EApp)
|
||||
],
|
||||
bootstrap: [IonicApp],
|
||||
entryComponents: [
|
||||
E2EPage
|
||||
]
|
||||
})
|
||||
export class AppModule {}
|
||||
@@ -1,23 +0,0 @@
|
||||
import { Component } from '@angular/core';
|
||||
import { ionicBootstrap } from '../../../../../src';
|
||||
|
||||
|
||||
@Component({
|
||||
templateUrl: 'main.html'
|
||||
})
|
||||
class E2EPage {
|
||||
outlineButton = true;
|
||||
|
||||
toggleOutline() {
|
||||
this.outlineButton = !this.outlineButton;
|
||||
}
|
||||
}
|
||||
|
||||
@Component({
|
||||
template: '<ion-nav [root]="rootPage"></ion-nav>'
|
||||
})
|
||||
class E2EApp {
|
||||
rootPage = E2EPage;
|
||||
}
|
||||
|
||||
ionicBootstrap(E2EApp);
|
||||
30
src/components/button/test/raised/app-module.ts
Normal file
30
src/components/button/test/raised/app-module.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import { Component, NgModule } from '@angular/core';
|
||||
import { IonicApp, IonicModule } from '../../../..';
|
||||
|
||||
|
||||
@Component({
|
||||
templateUrl: 'main.html'
|
||||
})
|
||||
export class E2EPage {}
|
||||
|
||||
@Component({
|
||||
template: '<ion-nav [root]="rootPage"></ion-nav>'
|
||||
})
|
||||
export class E2EApp {
|
||||
rootPage = E2EPage;
|
||||
}
|
||||
|
||||
@NgModule({
|
||||
declarations: [
|
||||
E2EApp,
|
||||
E2EPage
|
||||
],
|
||||
imports: [
|
||||
IonicModule.forRoot(E2EApp)
|
||||
],
|
||||
bootstrap: [IonicApp],
|
||||
entryComponents: [
|
||||
E2EPage
|
||||
]
|
||||
})
|
||||
export class AppModule {}
|
||||
@@ -1,17 +0,0 @@
|
||||
import { Component } from '@angular/core';
|
||||
import { ionicBootstrap } from '../../../../../src';
|
||||
|
||||
|
||||
@Component({
|
||||
templateUrl: 'main.html'
|
||||
})
|
||||
class E2EPage {}
|
||||
|
||||
@Component({
|
||||
template: '<ion-nav [root]="rootPage"></ion-nav>'
|
||||
})
|
||||
class E2EApp {
|
||||
rootPage = E2EPage;
|
||||
}
|
||||
|
||||
ionicBootstrap(E2EApp);
|
||||
37
src/components/button/test/round/app-module.ts
Normal file
37
src/components/button/test/round/app-module.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
import { Component, NgModule } from '@angular/core';
|
||||
import { IonicApp, IonicModule } from '../../../..';
|
||||
|
||||
|
||||
@Component({
|
||||
templateUrl: 'main.html'
|
||||
})
|
||||
export class E2EPage {
|
||||
dynamicColor: string = 'secondary';
|
||||
|
||||
toggleColor() {
|
||||
this.dynamicColor = (this.dynamicColor === 'secondary' ? 'danger' : 'secondary');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Component({
|
||||
template: '<ion-nav [root]="rootPage"></ion-nav>'
|
||||
})
|
||||
export class E2EApp {
|
||||
rootPage = E2EPage;
|
||||
}
|
||||
|
||||
@NgModule({
|
||||
declarations: [
|
||||
E2EApp,
|
||||
E2EPage
|
||||
],
|
||||
imports: [
|
||||
IonicModule.forRoot(E2EApp)
|
||||
],
|
||||
bootstrap: [IonicApp],
|
||||
entryComponents: [
|
||||
E2EPage
|
||||
]
|
||||
})
|
||||
export class AppModule {}
|
||||
@@ -1,17 +0,0 @@
|
||||
import { Component } from '@angular/core';
|
||||
import { ionicBootstrap } from '../../../../../src';
|
||||
|
||||
|
||||
@Component({
|
||||
templateUrl: 'main.html'
|
||||
})
|
||||
class E2EPage {}
|
||||
|
||||
@Component({
|
||||
template: '<ion-nav [root]="rootPage"></ion-nav>'
|
||||
})
|
||||
class E2EApp {
|
||||
rootPage = E2EPage;
|
||||
}
|
||||
|
||||
ionicBootstrap(E2EApp);
|
||||
31
src/components/button/test/sizes/app-module.ts
Normal file
31
src/components/button/test/sizes/app-module.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
import { Component, NgModule } from '@angular/core';
|
||||
import { IonicApp, IonicModule } from '../../../..';
|
||||
|
||||
|
||||
@Component({
|
||||
templateUrl: 'main.html'
|
||||
})
|
||||
export class E2EPage {}
|
||||
|
||||
|
||||
@Component({
|
||||
template: '<ion-nav [root]="rootPage"></ion-nav>'
|
||||
})
|
||||
export class E2EApp {
|
||||
rootPage = E2EPage;
|
||||
}
|
||||
|
||||
@NgModule({
|
||||
declarations: [
|
||||
E2EApp,
|
||||
E2EPage
|
||||
],
|
||||
imports: [
|
||||
IonicModule.forRoot(E2EApp)
|
||||
],
|
||||
bootstrap: [IonicApp],
|
||||
entryComponents: [
|
||||
E2EPage
|
||||
]
|
||||
})
|
||||
export class AppModule {}
|
||||
@@ -1,17 +0,0 @@
|
||||
import { Component } from '@angular/core';
|
||||
import { ionicBootstrap } from '../../../../../src';
|
||||
|
||||
|
||||
@Component({
|
||||
templateUrl: 'main.html'
|
||||
})
|
||||
class E2EPage {}
|
||||
|
||||
@Component({
|
||||
template: '<ion-nav [root]="rootPage"></ion-nav>'
|
||||
})
|
||||
class E2EApp {
|
||||
rootPage = E2EPage;
|
||||
}
|
||||
|
||||
ionicBootstrap(E2EApp);
|
||||
Reference in New Issue
Block a user