Skip to content
This repository has been archived by the owner on Jan 22, 2018. It is now read-only.

Commit

Permalink
style(tests): lint error free
Browse files Browse the repository at this point in the history
  • Loading branch information
Kamil Kisiela committed Dec 18, 2015
1 parent 5de2fda commit 956c12d
Show file tree
Hide file tree
Showing 22 changed files with 923 additions and 974 deletions.
18 changes: 9 additions & 9 deletions tests/helpers/ng-model-attrs-manipulator-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import {
}
from './../../src/helpers';

describe("formlyMaterial - ngModelAttrsManipulator", () => {
it("should skip on skipNgModelAttrsManipulator", () => {
describe('formlyMaterial - ngModelAttrsManipulator', () => {
it('should skip on skipNgModelAttrsManipulator', () => {
const tpl = 'test';
const result = ngModelAttrsManipulator(tpl, {
extras: {
Expand All @@ -15,15 +15,15 @@ describe("formlyMaterial - ngModelAttrsManipulator", () => {
expect(result).toBe(tpl);
});

it("should not modify on missing ngModel", () => {
it('should not modify on missing ngModel', () => {
const tpl = 'test';
const result = ngModelAttrsManipulator(tpl, {});

expect(result).toBe(tpl);
});

it("should add attribute with value to ngModel", () => {
const tpl = '<div><input ng-model="baz"/></div>';
it('should add attribute with value to ngModel', () => {
const tpl = `<div><input ng-model='baz'/></div>`;
const attr = {
name: 'foo',
value: 'bar'
Expand All @@ -35,8 +35,8 @@ describe("formlyMaterial - ngModelAttrsManipulator", () => {
expect(element.find('[ng-model]').attr(attr.name)).toBe(attr.value);
});

it("should add attribute with value to few elements with ngModel", () => {
const tpl = '<div><input ng-model="baz1"/><input ng-model="baz2"/></div>';
it('should add attribute with value to few elements with ngModel', () => {
const tpl = `<div><input ng-model='baz1'/><input ng-model='baz2'/></div>`;
const attr = {
name: 'foo',
value: 'bar'
Expand All @@ -50,9 +50,9 @@ describe("formlyMaterial - ngModelAttrsManipulator", () => {
expect(element.find('[ng-model]:eq(1)').attr(attr.name)).toBe(attr.value);
});

it("should not overwrite attribute on ngModel", () => {
it('should not overwrite attribute on ngModel', () => {
const name = 'baz';
const tpl = `<div><input ng-model="${name}" foo="${name}"/></div>`;
const tpl = `<div><input ng-model='${name}' foo='${name}'/></div>`;
const attr = {
name: 'foo',
value: 'bar'
Expand Down
2 changes: 1 addition & 1 deletion tests/index-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ import './../src';

import './helpers';
import './runs';
import './types'
import './types';
import './wrappers';
59 changes: 59 additions & 0 deletions tests/runs/grow-spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import testUtils from './../test-utils';

describe('formlyMaterial - textarea no autogrow manipulator', () => {
//
// vars
//
let $compile;
let $rootScope;
let $scope;
let element;

//
// helpers
//

function compile(options) {
$scope = $rootScope.$new();
$scope.fields = [angular.merge({}, {
key: 'testField',
type: 'textarea',
templateOptions: {
label: 'test field',
grow: false
}
}, options)];

const form = $compile(testUtils.getFormTemplate())($scope);

$scope.$digest();
element = form.find('[ng-model]');
}

//
// tests
//

beforeEach(() => {
window.module('formlyMaterial');

inject((_$compile_, _$rootScope_) => {
$compile = _$compile_;
$rootScope = _$rootScope_;
});

compile();
});

it('should be able to add md-no-autogrow attribute when grow equals false', () => {
compile();
expect(element.attr('md-no-autogrow')).toBeDefined();
});

it('should not add md-no-autogrow on non textarea type', () => {
compile({
type: 'input'
});
expect(element.attr('md-no-autogrow')).toBeUndefined();
});
});
4 changes: 2 additions & 2 deletions tests/runs/index.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
import './md-theme-manipulator-spec';
import './md-no-autogrow-spec';
import './theme-spec';
import './grow-spec';
65 changes: 0 additions & 65 deletions tests/runs/md-no-autogrow-spec.js

This file was deleted.

58 changes: 0 additions & 58 deletions tests/runs/md-theme-manipulator-spec.js

This file was deleted.

52 changes: 52 additions & 0 deletions tests/runs/theme-spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import testUtils from './../test-utils';

describe('formlyMaterial - theme manipulator', () => {
//
// vars
//
let $compile;
let $rootScope;
let $scope;
let element;

//
// helpers
//

function compile(options) {
$scope = $rootScope.$new();
$scope.fields = [angular.merge({}, {
key: 'testField',
type: 'switch',
templateOptions: {
theme: 'custom',
label: 'test field'
}
}, options)];

const form = $compile(testUtils.getFormTemplate())($scope);

$scope.$digest();
element = form.find('[ng-model]');
}

//
// tests
//

beforeEach(() => {
window.module('formlyMaterial');

inject((_$compile_, _$rootScope_) => {
$compile = _$compile_;
$rootScope = _$rootScope_;
});

compile();
});

it('should be able to add md-theme attribute', () => {
compile();
expect(element.attr('md-theme')).toBe('custom');
});
});
8 changes: 4 additions & 4 deletions tests/test-utils.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export default class testUtils {
static getFormTemplate() {
return `<form name="testForm"><formly-form fields="fields" form="testForm"></formly-form></form>`;
}
};
static getFormTemplate() {
return `<form name="testForm"><formly-form fields="fields" form="testForm"></formly-form></form>`;
}
}
Loading

0 comments on commit 956c12d

Please sign in to comment.