Skip to content

Commit 362eb29

Browse files
committed
test: make expectations work for npm 5 to 7
This addresses the following changes in behavior. Saved GitHub URL format in package.json: - npm 6: git+https://github.com/apache/cordova-android.git#4.1.x - npm 7: github:apache/cordova-android#4.1.x Empty devDependencies format in package.json: - npm 6: `{}` - npm 7: `undefined`
1 parent d42544b commit 362eb29

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

spec/fetch.spec.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ function expectNotToBeInstalled (pkgName) {
5757

5858
function expectDevDependenciesToBe (deps) {
5959
const rootPJ = fs.readJsonSync(path.join(tmpDir, 'package.json'));
60-
expect(rootPJ.devDependencies).toEqual(deps);
60+
expect(rootPJ.devDependencies || {}).toEqual(deps);
6161
}
6262

6363
describe('fetch/uninstall tests via npm & git', () => {
@@ -101,7 +101,7 @@ describe('fetch/uninstall with --save', () => {
101101
name: 'cordova-ios',
102102
version: '5.0.1'
103103
}))
104-
.then(_ => expectDevDependenciesToBe({ 'cordova-ios': 'git+https://github.com/apache/cordova-ios.git#rel/5.0.1' }))
104+
.then(_ => expectDevDependenciesToBe({ 'cordova-ios': jasmine.stringMatching('#rel/5.0.1') }))
105105
.then(_ => uninstall('cordova-ios', tmpDir, opts))
106106
.then(_ => expectDevDependenciesToBe({}))
107107
.then(_ => expectNotToBeInstalled('cordova-ios'))
@@ -111,18 +111,19 @@ describe('fetch/uninstall with --save', () => {
111111
name: 'cordova-android',
112112
version: '4.1.1'
113113
}))
114-
.then(_ => expectDevDependenciesToBe({ 'cordova-android': 'git+https://github.com/apache/cordova-android.git#4.1.x' }))
114+
.then(_ => expectDevDependenciesToBe({ 'cordova-android': jasmine.stringMatching('#4.1.x') }))
115115
.then(_ => uninstall('cordova-android', tmpDir, opts));
116116
}, 150000);
117117

118118
it('should fetch and uninstall a cordova plugin via git commit sha', () => {
119-
const URL = 'https://github.com/apache/cordova-plugin-contacts.git#7db612115755c2be73a98dda76ff4c5fd9d8a575';
119+
const SHA = '7db612115755c2be73a98dda76ff4c5fd9d8a575';
120+
const URL = `https://github.com/apache/cordova-plugin-contacts.git#${SHA}`;
120121
return Promise.resolve()
121122
.then(_ => fetchAndMatch(URL, {
122123
name: 'cordova-plugin-contacts',
123124
version: '2.0.2-dev'
124125
}))
125-
.then(_ => expectDevDependenciesToBe({ 'cordova-plugin-contacts': `git+${URL}` }))
126+
.then(_ => expectDevDependenciesToBe({ 'cordova-plugin-contacts': jasmine.stringMatching(`#${SHA}`) }))
126127
.then(_ => uninstall('cordova-plugin-contacts', tmpDir, opts))
127128
.then(_ => expectDevDependenciesToBe({}))
128129
.then(_ => expectNotToBeInstalled('cordova-plugin-contacts'));

0 commit comments

Comments
 (0)