Skip to content

Commit cec582a

Browse files
committed
test(adapter): add test for scoped npm modules
Add a test for scoped npm modules to confirm that they are not treated incorrectly as paths. Closes #403
1 parent b8b51cf commit cec582a

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

test/tests/adapter.js

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,48 @@ describe('adapter', function() {
6060
expect(function() {adapter.resolveAdapterPath('IAMANIMPOSSIBLEPATH'); }).to.throw(Error);
6161
expect(function() {adapter.resolveAdapterPath(adapterConfig.path); }).not.to.throw(Error);
6262
expect(function() {adapter.resolveAdapterPath(path.join(adapterConfig.path, 'index.js')); }).not.to.throw(Error);
63+
64+
// This line is only here to make sure that cz-conventional-changelog
65+
// was installed for the purposes of running tests, it is not needed
66+
// for testing any other adapters.
6367
expect(function() {adapter.resolveAdapterPath('cz-conventional-changelog'); }).not.to.throw(Error);
6468
});
69+
70+
it('resolves scoped adapter paths', function() {
71+
72+
this.timeout(config.maxTimeout); // this could take a while
73+
74+
// SETUP
75+
76+
// Describe a repo and some files to add and commit
77+
let repoConfig = {
78+
path: config.paths.endUserRepo,
79+
files: {
80+
dummyfile: {
81+
contents: `duck-duck-goose`,
82+
filename: `mydummyfile.txt`,
83+
},
84+
gitignore: {
85+
contents: `node_modules/`,
86+
filename: `.gitignore`
87+
}
88+
}
89+
};
90+
91+
// Describe an adapter
92+
let adapterConfig = {
93+
path: path.join(repoConfig.path, '/node_modules/@commitizen/cz-conventional-changelog'),
94+
npmName: '@commitizen/cz-conventional-changelog'
95+
};
96+
97+
// Install an adapter
98+
commitizenInit(sh, config.paths.endUserRepo, '@commitizen/cz-conventional-changelog');
99+
100+
// TEST
101+
expect(function() {adapter.resolveAdapterPath('IAMANIMPOSSIBLEPATH'); }).to.throw(Error);
102+
expect(function() {adapter.resolveAdapterPath(adapterConfig.path); }).not.to.throw(Error);
103+
expect(function() {adapter.resolveAdapterPath(path.join(adapterConfig.path, 'index.js')); }).not.to.throw(Error);
104+
});
65105

66106
it('gets adapter prompter functions', function(){
67107

0 commit comments

Comments
 (0)