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

Commit 0368b76

Browse files
test(formly-run): stub and test for addCustomTags
1 parent 329711a commit 0368b76

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

src/index.test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import './directives/formly-custom-validation.test';
99
import './directives/formly-field.test';
1010
import './directives/formly-focus.test';
1111
import './directives/formly-form.test';
12+
import './run/formlyCustomTags.test';
1213
import './run/formlyNgModelAttrsManipulator.test';
1314
import './other/utils.test';
1415

src/run/formlyCustomTags.test.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import angular from 'angular';
2+
3+
describe(`formlyCustomTags`, () => {
4+
5+
beforeEach(window.module(`formly`, $provide => {
6+
const docStub = {
7+
get: sinon.stub().withArgs(0).returnsThis(),
8+
createElement: sinon.stub().withArgs(`div`).returns({
9+
getElementsByTagName: sinon.stub().withArgs(`i`).returns([1])
10+
})
11+
};
12+
13+
$provide.value(`$document`, docStub);
14+
}));
15+
16+
let $document;
17+
18+
beforeEach(inject((_$document_) => {
19+
$document = _$document_;
20+
}));
21+
22+
describe(`addCustomTags`, () => {
23+
it(`should create custom formly tags`, () => {
24+
const customElements = [
25+
`div`, `formly-field`, `formly-form`, `formly-custom-validation`, `formly-focus`, `formly-transpose`
26+
];
27+
28+
expect($document.get).to.have.been.calledOnce;
29+
30+
angular.forEach(customElements, el => {
31+
expect($document.createElement).to.have.been.calledWith(el);
32+
});
33+
});
34+
});
35+
});

0 commit comments

Comments
 (0)