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

Commit 956c12d

Browse files
author
Kamil Kisiela
committed
style(tests): lint error free
1 parent 5de2fda commit 956c12d

22 files changed

+923
-974
lines changed

tests/helpers/ng-model-attrs-manipulator-spec.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import {
33
}
44
from './../../src/helpers';
55

6-
describe("formlyMaterial - ngModelAttrsManipulator", () => {
7-
it("should skip on skipNgModelAttrsManipulator", () => {
6+
describe('formlyMaterial - ngModelAttrsManipulator', () => {
7+
it('should skip on skipNgModelAttrsManipulator', () => {
88
const tpl = 'test';
99
const result = ngModelAttrsManipulator(tpl, {
1010
extras: {
@@ -15,15 +15,15 @@ describe("formlyMaterial - ngModelAttrsManipulator", () => {
1515
expect(result).toBe(tpl);
1616
});
1717

18-
it("should not modify on missing ngModel", () => {
18+
it('should not modify on missing ngModel', () => {
1919
const tpl = 'test';
2020
const result = ngModelAttrsManipulator(tpl, {});
2121

2222
expect(result).toBe(tpl);
2323
});
2424

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

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

53-
it("should not overwrite attribute on ngModel", () => {
53+
it('should not overwrite attribute on ngModel', () => {
5454
const name = 'baz';
55-
const tpl = `<div><input ng-model="${name}" foo="${name}"/></div>`;
55+
const tpl = `<div><input ng-model='${name}' foo='${name}'/></div>`;
5656
const attr = {
5757
name: 'foo',
5858
value: 'bar'

tests/index-spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ import './../src';
22

33
import './helpers';
44
import './runs';
5-
import './types'
5+
import './types';
66
import './wrappers';

tests/runs/grow-spec.js

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
import testUtils from './../test-utils';
2+
3+
describe('formlyMaterial - textarea no autogrow manipulator', () => {
4+
//
5+
// vars
6+
//
7+
let $compile;
8+
let $rootScope;
9+
let $scope;
10+
let element;
11+
12+
//
13+
// helpers
14+
//
15+
16+
function compile(options) {
17+
$scope = $rootScope.$new();
18+
$scope.fields = [angular.merge({}, {
19+
key: 'testField',
20+
type: 'textarea',
21+
templateOptions: {
22+
label: 'test field',
23+
grow: false
24+
}
25+
}, options)];
26+
27+
const form = $compile(testUtils.getFormTemplate())($scope);
28+
29+
$scope.$digest();
30+
element = form.find('[ng-model]');
31+
}
32+
33+
//
34+
// tests
35+
//
36+
37+
beforeEach(() => {
38+
window.module('formlyMaterial');
39+
40+
inject((_$compile_, _$rootScope_) => {
41+
$compile = _$compile_;
42+
$rootScope = _$rootScope_;
43+
});
44+
45+
compile();
46+
});
47+
48+
it('should be able to add md-no-autogrow attribute when grow equals false', () => {
49+
compile();
50+
expect(element.attr('md-no-autogrow')).toBeDefined();
51+
});
52+
53+
it('should not add md-no-autogrow on non textarea type', () => {
54+
compile({
55+
type: 'input'
56+
});
57+
expect(element.attr('md-no-autogrow')).toBeUndefined();
58+
});
59+
});

tests/runs/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
import './md-theme-manipulator-spec';
2-
import './md-no-autogrow-spec';
1+
import './theme-spec';
2+
import './grow-spec';

tests/runs/md-no-autogrow-spec.js

Lines changed: 0 additions & 65 deletions
This file was deleted.

tests/runs/md-theme-manipulator-spec.js

Lines changed: 0 additions & 58 deletions
This file was deleted.

tests/runs/theme-spec.js

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import testUtils from './../test-utils';
2+
3+
describe('formlyMaterial - theme manipulator', () => {
4+
//
5+
// vars
6+
//
7+
let $compile;
8+
let $rootScope;
9+
let $scope;
10+
let element;
11+
12+
//
13+
// helpers
14+
//
15+
16+
function compile(options) {
17+
$scope = $rootScope.$new();
18+
$scope.fields = [angular.merge({}, {
19+
key: 'testField',
20+
type: 'switch',
21+
templateOptions: {
22+
theme: 'custom',
23+
label: 'test field'
24+
}
25+
}, options)];
26+
27+
const form = $compile(testUtils.getFormTemplate())($scope);
28+
29+
$scope.$digest();
30+
element = form.find('[ng-model]');
31+
}
32+
33+
//
34+
// tests
35+
//
36+
37+
beforeEach(() => {
38+
window.module('formlyMaterial');
39+
40+
inject((_$compile_, _$rootScope_) => {
41+
$compile = _$compile_;
42+
$rootScope = _$rootScope_;
43+
});
44+
45+
compile();
46+
});
47+
48+
it('should be able to add md-theme attribute', () => {
49+
compile();
50+
expect(element.attr('md-theme')).toBe('custom');
51+
});
52+
});

tests/test-utils.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
export default class testUtils {
2-
static getFormTemplate() {
3-
return `<form name="testForm"><formly-form fields="fields" form="testForm"></formly-form></form>`;
4-
}
5-
};
2+
static getFormTemplate() {
3+
return `<form name="testForm"><formly-form fields="fields" form="testForm"></formly-form></form>`;
4+
}
5+
}

0 commit comments

Comments
 (0)