I want to test the existence of an input that is inside an ng-if, without the ng-if the test passes perfectly but not with the ng-if which is normal since ng-if removes the element from the DOM.
Here is the ng-if
<div ng-ig="$ctrl.model.joineryTypes">
<input type="" name="">
</div>
The test
import angular from 'angular'
import 'angular-mocks'
let scope
let rootScope
let compile
let htmlElement
let ctrl
fdescribe('roomsCommonForm', () => {
beforeEach(() => {
angular.mock.module('roomsCommonModule')
})
beforeEach(inject((_$compile_, _$rootScope_) => {
rootScope = _$rootScope_
compile = _$compile_
scope = rootScope.$new()
htmlElement = compile(`<rooms-common-form></rooms-common-form>`)(scope)
rootScope.$digest()
}))
beforeEach(inject(($componentController) => {
let bindings = {
model: {}
}
ctrl = $componentController('roomsCommonForm', null, bindings)
}))
it('should contain one input', () => {
const inputItem = htmlElement.get(0).querySelectorAll('input')
expect(inputItem.length).toBe(1)
})
})
How I can simulate that object $ctrl.model.joineryTypes ?