I would like to test against real, changing data.
We have a user-notes.service.js:
- A service that displays a message to user if they have unactivated ID-numbers
- If we already warned the user about their unactivated ID, the number is stored in Angular $cookies, message is not shown for future log ins
A test user-notes.service.TEST.js
- Expects message to be shown if ID-number unactivated (1)
- Expects message not to be shown if number activated (2)
I recently added logic display or hide the message based on whether the user has an unactivated new IDs or unactivated known ID. Our test (1) will expect the warning message to be displayed on all unactivated ID-numbers, but the new logic in our service now prevents that.
Our tests will pass the first time it runs against an ID-number, but after it sees it - the warning message won't be displayed and it will fail.
How can I access real changing data from our service inside our test? Do I need to? For most other things like, whether a number is 'activated' or 'unactivated' we're just setting the state in our test.
Unactivated:
expect(message).toBeDisplayed()
Activated:
expect(message).not.toBeDisplayed()
Aucun commentaire:
Enregistrer un commentaire