-
Notifications
You must be signed in to change notification settings - Fork 778
wip(test): add text normalization test #598
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Need to figure out how to reset the mock each time. The first run |
|
@andrewda have you tried with |
|
@alejandronanez What should I use them for? |
|
@andrewda I think you can reset the mock for every test that is run. (or I am just misunderstanding everything 😞 ) |
|
Yea, but I'm not sure how to reset just the Dimension and PixelRatio mocks, instead of everything (like the ones defined in testenv.js). |
|
@andrewda I had a look at this PR and after a lot of trial and error, the only working thing I can come up with is chaining .mockReturnValueOnce() calls: jest.mock('Dimensions', () => ({
get: jest
.fn()
.mockReturnValueOnce(mockScreens.iPhone5)
.mockReturnValueOnce(mockScreens.iPhone6),
}));
jest.mock('PixelRatio', () => ({
get: jest
.fn()
.mockReturnValueOnce(2)
.mockReturnValueOnce(2),
}));
describe('Normalize Text', () => {
// iOS Devices
it('should normalize correctly on iPhone 5', () => {
const { normalize } = require('config');
expect(normalize(1)).toEqual(0.95);
});
it('should normalize correctly on iPhone 6', () => {
const { normalize } = require('config');
expect(normalize(1)).toEqual(0.95);
});This require a change in the |
|
How about |
|
Didn't work for me. If you console.log() in mockClassWithGetter , you'll see the log only once |
|
Jest@24 provides jest.isolateModules(fn). I think it is what we want. |
|
Closing in favor of #899 (thanks @chinesedfan!) |
* test: cherry-pick files from #598 * test: jest.isolateModules works * fix: device info * fix: pass tests * fix: consider as intervals
Description
Adds a test for the
text-normalizefile. Currently WIP.