ng-mocks 13.0.1 → 13.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +22 -0
- package/README.md +1 -1
- package/examples/TestDirectiveLetOf/dynamic.spec.ts +44 -0
- package/examples/TestDirectiveLetOf/static.spec.ts +51 -0
- package/index.js +1 -1
- package/index.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,25 @@
|
|
|
1
|
+
## [13.0.3](https://github.com/ike18t/ng-mocks/compare/v13.0.2...v13.0.3) (2022-02-20)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* **mock-render:** apply overrides to components with no selectors [#1876](https://github.com/ike18t/ng-mocks/issues/1876) ([b032746](https://github.com/ike18t/ng-mocks/commit/b032746161e307000afb8bafc368ae0d655c9c81))
|
|
7
|
+
|
|
8
|
+
## [13.0.2](https://github.com/ike18t/ng-mocks/compare/v13.0.1...v13.0.2) (2022-02-06)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* **ie:** running IE on A5 and old nodejs ([087d58d](https://github.com/ike18t/ng-mocks/commit/087d58d873536921bc3b1745e38ac5213457eef3))
|
|
14
|
+
|
|
15
|
+
## [13.0.1](https://github.com/ike18t/ng-mocks/compare/v13.0.0...v13.0.1) (2022-02-06)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Bug Fixes
|
|
19
|
+
|
|
20
|
+
* **e2e:** support for A14 ([c0bdcbf](https://github.com/ike18t/ng-mocks/commit/c0bdcbfe1416ed18be46b2c2cd1feec274bfa0c5))
|
|
21
|
+
* looking in vcr.createComponent on root node [#1596](https://github.com/ike18t/ng-mocks/issues/1596) ([5aa0d9a](https://github.com/ike18t/ng-mocks/commit/5aa0d9abf76bca49b45c3cd57db49964b5c532a4))
|
|
22
|
+
|
|
1
23
|
# [13.0.0](https://github.com/ike18t/ng-mocks/compare/v12.5.1...v13.0.0) (2022-01-23)
|
|
2
24
|
|
|
3
25
|
|
package/README.md
CHANGED
|
@@ -44,7 +44,7 @@ The current version of the library **has been tested** and **can be used** with:
|
|
|
44
44
|
## Very short introduction
|
|
45
45
|
|
|
46
46
|
Global configuration for mocks in `src/test.ts`.
|
|
47
|
-
In case of jest, `src/
|
|
47
|
+
In case of jest, `src/setup-jest.ts` / `src/test-setup.ts` should be used.
|
|
48
48
|
|
|
49
49
|
```ts title="src/test.ts"
|
|
50
50
|
// All methods in mock declarations and providers
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Directive,
|
|
3
|
+
Input,
|
|
4
|
+
TemplateRef,
|
|
5
|
+
ViewContainerRef,
|
|
6
|
+
} from '@angular/core';
|
|
7
|
+
import { MockBuilder, MockRender, ngMocks } from 'ng-mocks';
|
|
8
|
+
|
|
9
|
+
@Directive({
|
|
10
|
+
selector: '[dxTemplate]',
|
|
11
|
+
})
|
|
12
|
+
class DxTemplateDirective {
|
|
13
|
+
@Input() public readonly dxTemplateOf: string | null = null;
|
|
14
|
+
|
|
15
|
+
public constructor(
|
|
16
|
+
protected templateRef: TemplateRef<any>,
|
|
17
|
+
protected viewContainerRef: ViewContainerRef,
|
|
18
|
+
) {}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
describe('TestDirectiveLetOf:dynamic', () => {
|
|
22
|
+
beforeEach(() => MockBuilder().mock(DxTemplateDirective));
|
|
23
|
+
|
|
24
|
+
it('renders a mock of structural directives', () => {
|
|
25
|
+
const fixture = MockRender(`
|
|
26
|
+
<div *dxTemplate="let cellTemplate of 'actionsCellTemplate'">
|
|
27
|
+
{{ cellTemplate.data }}
|
|
28
|
+
</div>
|
|
29
|
+
`);
|
|
30
|
+
|
|
31
|
+
// firstly, let's check that we passed 'actionsCellTemplate' as input value.
|
|
32
|
+
const instance = ngMocks.findInstance(DxTemplateDirective);
|
|
33
|
+
expect(instance.dxTemplateOf).toEqual('actionsCellTemplate');
|
|
34
|
+
|
|
35
|
+
// secondly, let's render the structural directive,
|
|
36
|
+
// and assert that MOCK_DATA is present.
|
|
37
|
+
ngMocks.render(instance, instance, {
|
|
38
|
+
data: 'MOCK_DATA',
|
|
39
|
+
});
|
|
40
|
+
expect(ngMocks.formatHtml(fixture)).toEqual(
|
|
41
|
+
'<div> MOCK_DATA </div>',
|
|
42
|
+
);
|
|
43
|
+
});
|
|
44
|
+
});
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Directive,
|
|
3
|
+
Input,
|
|
4
|
+
TemplateRef,
|
|
5
|
+
ViewContainerRef,
|
|
6
|
+
} from '@angular/core';
|
|
7
|
+
import { MockBuilder, MockRender, ngMocks } from 'ng-mocks';
|
|
8
|
+
|
|
9
|
+
@Directive({
|
|
10
|
+
selector: '[dxTemplate]',
|
|
11
|
+
})
|
|
12
|
+
class DxTemplateDirective {
|
|
13
|
+
@Input() public readonly dxTemplateOf: string | null = null;
|
|
14
|
+
|
|
15
|
+
public constructor(
|
|
16
|
+
protected templateRef: TemplateRef<any>,
|
|
17
|
+
protected viewContainerRef: ViewContainerRef,
|
|
18
|
+
) {}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
describe('TestDirectiveLetOf:static', () => {
|
|
22
|
+
beforeEach(() =>
|
|
23
|
+
MockBuilder().mock(DxTemplateDirective, {
|
|
24
|
+
// We should not only render the structural directive,
|
|
25
|
+
// but also provide its context variables.
|
|
26
|
+
render: {
|
|
27
|
+
$implicit: {
|
|
28
|
+
data: 'MOCK_DATA',
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
}),
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
it('renders a mock of structural directives', () => {
|
|
35
|
+
const fixture = MockRender(`
|
|
36
|
+
<div *dxTemplate="let cellTemplate of 'actionsCellTemplate'">
|
|
37
|
+
{{ cellTemplate.data }}
|
|
38
|
+
</div>
|
|
39
|
+
`);
|
|
40
|
+
|
|
41
|
+
// firstly, let's check that we passed 'actionsCellTemplate' as input value.
|
|
42
|
+
expect(
|
|
43
|
+
ngMocks.findInstance(DxTemplateDirective).dxTemplateOf,
|
|
44
|
+
).toEqual('actionsCellTemplate');
|
|
45
|
+
|
|
46
|
+
// secondly, let's check that MOCK_DATA has been rendered.
|
|
47
|
+
expect(ngMocks.formatHtml(fixture)).toEqual(
|
|
48
|
+
'<div> MOCK_DATA </div>',
|
|
49
|
+
);
|
|
50
|
+
});
|
|
51
|
+
});
|