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

Commit 9564786

Browse files
author
Kamil Kisiela
committed
Add tests for formlyMaterial provider
1 parent 3a0ed55 commit 9564786

File tree

3 files changed

+65
-2
lines changed

3 files changed

+65
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
55
## [Unreleased]
66
### Added
77
- datepicker with date range and filtering _(currently in angular-material 1.0_RC4)_
8+
- Tests of formlyMaterial provider
89

910
## [0.2.0] - 2015-11-17
1011
### Added

package.js

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
var both = ['client', 'server'];
21
var client = 'client';
3-
var server = 'server';
42

53
Package.describe({
64
name: "wieldo:angular-formly-templates-material",
@@ -94,4 +92,20 @@ Package.onUse(function (api) {
9492

9593
], client);
9694

95+
});
96+
97+
Package.onTest(function(api) {
98+
api.use([
99+
'pbastowski:[email protected]',
100+
'pbastowski:[email protected]',
101+
102+
'velocity:helpers',
103+
'velocity:console-reporter',
104+
'angular:[email protected]',
105+
'wieldo:angular-formly-templates-material'
106+
]);
107+
108+
api.addFiles([
109+
'tests/client/formly-material-spec.js'
110+
], client);
97111
});

tests/client/formly-material-spec.js

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
describe('formlyMaterial', () => {
2+
//
3+
// vars
4+
//
5+
let formlyMaterial;
6+
let formlyMaterialPr;
7+
8+
//
9+
// tests
10+
//
11+
12+
beforeEach(() => {
13+
angular.module('formlyMaterialMock', [])
14+
.config((formlyMaterialProvider) => {
15+
formlyMaterialPr = formlyMaterialProvider
16+
});
17+
module('formlyMaterial', 'formlyMaterialMock');
18+
19+
angular.module('testApp', ['angular-meteor', 'formly', 'formlyMaterial', 'ngMock']);
20+
module('testApp');
21+
22+
inject(function ($templateCache, $httpBackend, _formlyMaterial_) {
23+
$httpBackend.whenGET(/\.html$/i).respond((method, url) => $templateCache.get(url));
24+
formlyMaterial = _formlyMaterial_;
25+
});
26+
});
27+
28+
it("should be injectable", () => {
29+
expect(formlyMaterial).toBeDefined();
30+
});
31+
32+
it("should be able to add prefix to templateUrl using factory", () => {
33+
const prefix = "/packages/wieldo:angular-formly-templates-material/";
34+
35+
expect(formlyMaterial.templateUrl("test.html")).toBe(prefix + "test.html");
36+
expect(formlyMaterial.templateUrl("/test.html")).toBe(prefix + "test.html");
37+
expect(formlyMaterial.templateUrl("/test/test.html")).toBe(prefix + "test/test.html");
38+
});
39+
40+
it("should be able to add prefix to templateUrl using provider", () => {
41+
const prefix = "/packages/wieldo:angular-formly-templates-material/";
42+
43+
expect(formlyMaterialPr.templateUrl("test.html")).toBe(prefix + "test.html");
44+
expect(formlyMaterialPr.templateUrl("/test.html")).toBe(prefix + "test.html");
45+
expect(formlyMaterialPr.templateUrl("/test/test.html")).toBe(prefix + "test/test.html");
46+
});
47+
48+
});

0 commit comments

Comments
 (0)