Created
February 19, 2019 07:58
-
-
Save gearmobile/55034c4179f143d187034b15d3e88d2c to your computer and use it in GitHub Desktop.
angular-testing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Тему тестирования по Angular только осваиваю (Karma+Jasmine). Есть точная копия компонента contributor, вырванного из контекста - https://stackblitz.com/edit/angular-xldsny | |
Проблема для меня заключается в следующем. | |
Если закомментировать блок кода в компоненте (стр. 152): | |
```js | |
const rulesTreeSecondary = Object.keys(namesMapSecondary).map(child => { | |
const temp: any = filter(rules['references'], el => el.name.toLowerCase() === child)[0]; | |
return { | |
name: child, | |
displayName: temp.displayName, | |
selected: temp.selected || true, | |
id: uniqueId() | |
}; | |
}); | |
``` | |
стр. 164: | |
```js | |
this.rulesTreeSecondary = cloneDeep(rulesTreeSecondary); | |
``` | |
и в файле спецификации (стр. 120): | |
```js | |
expect(component.rulesTreeSecondary).toEqual([ | |
[ | |
{ | |
name: 'store', | |
displayName: 'Склад', | |
selected: true, | |
id: '114' | |
}, | |
{ | |
name: 'employee', | |
displayName: 'Сотрудник', | |
selected: true, | |
id: '115' | |
}, | |
{ | |
name: 'outlet', | |
displayName: 'Торговая точка', | |
selected: true, | |
id: '116' | |
}, | |
{ | |
name: 'sku', | |
displayName: 'Товар', | |
selected: true, | |
id: '117' | |
} | |
] | |
] as any); | |
``` | |
... то тесты проходят успешно. | |
Если их раскомментировать, то тесты падают с ошибкой: | |
```js | |
19 02 2019 09:32:56.743:INFO [HeadlessChrome 72.0.3626 (Linux 0.0.0)]: Connected on socket oGFu6oxmu-WZ3DGLAAAA with id 11237741 | |
HeadlessChrome 72.0.3626 (Linux 0.0.0) [Modules] Component: DistributorsConfigurationComponent .getDistributorsConfiguration should fetch settings and merge rules from backend FAILED | |
Expected undefined to equal Object({ name: 'documents', displayName: 'Документы', children: [ Object({ name: 'name', typeId: 100, displayName: 'displayName', attributes: [ Object({ name: 'attr1', displayName: 'attr1D', updatable: true }), Object({ name: 'attr2', displayName: 'attr2D', updatable: true }), Object({ name: 'attr3', displayName: 'attr3D', updatable: true }), Object({ name: 'attr4', displayName: 'attr4D', updatable: true }) ], children: [ Object({ name: 'attr1', displayName: 'attr1D', updatable: true, id: <jasmine.any(String)>, selected: true }), Object({ name: 'attr2', displayName: 'attr2D', updatable: true, id: <jasmine.any(String)>, selected: true }), Object({ name: 'attr3', displayName: 'attr3D', updatable: true, id: <jasmine.any(String)>, selected: true }), Object({ name: 'attr4', displayName: 'attr4D', updatable: true, id: <jasmine.any(String)>, selected: true }) ], id: <jasmine.any(String)> }) ], id: <jasmine.any(String)> }). | |
at UserContext.eval (./@modules/configuration/module/components/distributors-configuration/distributors-configuration.component.spec.ts?:77:44) | |
at TestBedViewEngine.execute (./node_modules/@angular/core/fesm5/testing.js?:1805:19) | |
at UserContext.eval (./node_modules/@angular/core/fesm5/testing.js?:1974:45) | |
at ZoneDelegate.invoke (./node_modules/zone.js/dist/zone.js?:387:26) | |
``` | |
Возможно, кто-то захочет и сможет подсказать-помочь нубу? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment