fix(@embark/ens): fix broken test due to async API

As part of 8ed5376533 we made `ENS.getEnsConfig()`
asynchronous, hence it needs a callback. This change was not done in one of the
ENS tests, resulting in the test to fail. The test mocked that particular API,
turning it into noop, which is why the test kept timing out.

This commit fixes the test by not mocking the API and adding the needed configuration
to the environment.
This commit is contained in:
Pascal Precht 2019-12-11 12:42:49 +01:00 committed by Iuri Matias
parent a208db97b3
commit 9df24309e7
2 changed files with 13 additions and 11 deletions

View File

@ -34,7 +34,7 @@
"ci": "npm run qa", "ci": "npm run qa",
"clean": "npm run reset", "clean": "npm run reset",
"lint": "eslint src/", "lint": "eslint src/",
"qa": "npm-run-all lint _build", "qa": "npm-run-all lint _build test",
"reset": "npx rimraf dist embark-*.tgz package", "reset": "npx rimraf dist embark-*.tgz package",
"solo": "embark-solo", "solo": "embark-solo",
"test": "jest" "test": "jest"

View File

@ -19,7 +19,8 @@ describe('embark-ens', () => {
namesystemConfig: { namesystemConfig: {
register: { register: {
rootDomain: 'root.eth' rootDomain: 'root.eth'
} },
dappConnection: []
} }
}; };
}); });
@ -29,17 +30,18 @@ describe('embark-ens', () => {
}); });
it("should register the right artifact", (done) => { it("should register the right artifact", (done) => {
const pipelineRegisterHandler = jest.fn((args, cb) => { const pipelineRegisterHandler = jest.fn(async (args, cb) => {
expect(args).toEqual({ ens.getEnsConfig((err, config) => {
path: ['test-dir', 'config'], expect(args).toEqual({
file: 'namesystem.json', path: ['test-dir', 'config'],
format: 'json', file: 'namesystem.json',
content: Object.assign({}, embark.config.namesystemConfig, ens.getEnsConfig()) format: 'json',
content: Object.assign({}, embark.config.namesystemConfig, config)
});
cb();
done();
}); });
cb();
done();
}); });
ens.getEnsConfig = jest.fn();
embark.events.setCommandHandler('pipeline:register', pipelineRegisterHandler); embark.events.setCommandHandler('pipeline:register', pipelineRegisterHandler);