test(ion): fix ion tests

This commit is contained in:
Adam Bradley
2016-09-13 22:16:26 -05:00
parent 95bcaca362
commit f368abee26
3 changed files with 11 additions and 17 deletions

View File

@ -7,39 +7,34 @@ describe('Ion', () => {
describe('color', () => {
it('should set color when it hasnt been set yet', () => {
ion._setMode('icon', 'md');
ion._setColor('icon', 'primary');
expect(hasClass(ion, 'icon-primary')).toEqual(true);
expect(className(ion)).toEqual('icon-md icon-md-primary');
});
it('should remove color when it has already been set', () => {
ion._setMode('icon', 'md');
ion._setColor('icon', 'primary');
ion._setColor('icon', null);
expect(hasClass(ion, 'icon-primary')).toEqual(false);
expect(className(ion)).toEqual('icon-md');
});
it('should update color when it has already been set', () => {
ion._setMode('icon', 'md');
ion._setColor('icon', 'primary');
ion._setColor('icon', 'secondary');
expect(hasClass(ion, 'icon-primary')).toEqual(false);
expect(hasClass(ion, 'icon-secondary')).toEqual(true);
expect(className(ion)).toEqual('icon-md icon-md-secondary');
});
it('should not setElementClass if its the same value', () => {
ion._setMode('icon', 'ios');
ion._setColor('icon', 'primary');
spyOn(ion, 'setElementClass');
expect(ion.setElementClass).not.toHaveBeenCalled();
ion._setColor('icon', 'primary');
expect(hasClass(ion, 'icon-primary')).toEqual(true);
});
});
describe('mode', () => {
it('', () => {
expect(className(ion)).toEqual('icon-ios icon-ios-primary');
});
});
@ -50,8 +45,8 @@ describe('Ion', () => {
ion = new Ion(mockConfig(), mockElementRef(), mockRenderer());
});
function hasClass(ion: Ion, className: string) {
return ion._elementRef.nativeElement.classList.contains(className);
function className(ion: Ion) {
return ion._elementRef.nativeElement.className;
}
});

View File

@ -3,7 +3,6 @@ export { Config } from './config/config';
export { IonicModule } from './module';
export * from './directives';
export * from './providers';
export * from './gestures/drag-gesture';
export * from './gestures/gesture';

View File

@ -31,7 +31,7 @@ import { Translate } from './translation/translate';
import { TransitionController } from './transitions/transition-controller';
import { UserRoot } from './components/app/app-root';
)
/**
* Export Providers
*/