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

Commit ae2f17b

Browse files
author
Kamil Kisiela
committed
test(messages): check transclude order and existance
1 parent 1d1d5b8 commit ae2f17b

File tree

2 files changed

+71
-0
lines changed

2 files changed

+71
-0
lines changed

package.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ Package.onTest(function(api) {
121121
// wrappers
122122
'tests/client/wrappers/input-container-spec.js',
123123
'tests/client/wrappers/label-spec.js',
124+
'tests/client/wrappers/messages-spec.js',
124125
// types
125126
'tests/client/types/checkbox-spec.js',
126127
'tests/client/types/chips-spec.js',
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
describe("formlyMaterial - messages wrapper", () => {
2+
3+
//
4+
// vars
5+
//
6+
let formlyConfig;
7+
let $compile;
8+
let $rootScope;
9+
let $scope;
10+
let element;
11+
let field;
12+
13+
//
14+
// helpers
15+
//
16+
17+
function compile() {
18+
$scope = $rootScope.$new();
19+
$scope.fields = [{
20+
key: 'testField',
21+
type: 'checkbox',
22+
wrapper: ['messages'],
23+
templateOptions: {
24+
label: 'test field'
25+
}
26+
}];
27+
28+
let form = $compile(testUtils.formTemplate)($scope);
29+
$scope.$digest();
30+
element = form.find('[ng-messages]');
31+
field = $scope.fields[0];
32+
}
33+
34+
//
35+
// tests
36+
//
37+
38+
beforeEach(() => {
39+
angular.module('testApp', ['angular-meteor', 'formly', 'formlyMaterial']);
40+
module('testApp');
41+
42+
inject((_$compile_, _$rootScope_, _formlyConfig_) => {
43+
$compile = _$compile_;
44+
$rootScope = _$rootScope_;
45+
formlyConfig = _formlyConfig_;
46+
});
47+
48+
const types = ['checkbox'];
49+
const wrappers = ['messages'];
50+
51+
types.forEach((name) => {
52+
testUtils.fixTypeTemplateUrl(formlyConfig, name);
53+
});
54+
wrappers.forEach((name) => {
55+
testUtils.fixWrapperTemplateUrl(formlyConfig, name);
56+
});
57+
58+
compile();
59+
});
60+
61+
it('should exist', () => {
62+
expect(element.length).toBe(1);
63+
});
64+
65+
it("should be after the field", () => {
66+
expect(element.find('md-checkbox').length).toBe(0);
67+
expect(element.before('[ng-messages]').length).toBe(1);
68+
});
69+
70+
});

0 commit comments

Comments
 (0)