Skip to content

Commit 71dcfef

Browse files
committed
Update tests
1 parent 1255b04 commit 71dcfef

File tree

3 files changed

+44
-69
lines changed

3 files changed

+44
-69
lines changed

tasks/index.js

+38-42
Original file line numberDiff line numberDiff line change
@@ -29,36 +29,34 @@ module.exports = yargs
2929
desc: 'has new remote commits',
3030
handler: () => {
3131
run('git rev-parse --is-inside-work-tree')
32-
.then(() =>
33-
run('git remote -v update')
34-
.then(() =>
35-
Promise.all([
36-
run('git rev-parse @'),
37-
run('git rev-parse @{u}'),
38-
run('git merge-base @ @{u}'),
39-
])
40-
.then(values => {
41-
const [{ stdout: $local }, { stdout: $remote }, { stdout: $base }] = values;
32+
.then(() => run('git remote -v update')
33+
.then(() => Promise.all([
34+
run('git rev-parse @'),
35+
run('git rev-parse @{u}'),
36+
run('git merge-base @ @{u}'),
37+
])
38+
.then(values => {
39+
const [{ stdout: $local }, { stdout: $remote }, { stdout: $base }] = values;
4240

43-
if ($local === $remote) {
44-
console.log(chalk.green('✔ Repo is up-to-date!'));
45-
}
46-
else if ($local === $base) {
47-
console.log(chalk.red('⊘ Error'), 'You need to pull, there are new commits.');
48-
process.exit(1);
49-
}
50-
})
51-
.catch(err => {
52-
if (err.message.includes('no upstream configured ')) {
53-
console.log(chalk.yellow('⚠ Warning'), 'No upstream. Is this a new branch?');
54-
return;
55-
}
56-
57-
console.log(chalk.yellow('⚠ Warning'), err.message);
58-
}))
41+
if ($local === $remote) {
42+
console.log(chalk.green('✔ Repo is up-to-date!'));
43+
}
44+
else if ($local === $base) {
45+
console.log(chalk.red('⊘ Error'), 'You need to pull, there are new commits.');
46+
process.exit(1);
47+
}
48+
})
5949
.catch(err => {
60-
throw new Error(err);
50+
if (err.message.includes('no upstream configured ')) {
51+
console.log(chalk.yellow('⚠ Warning'), 'No upstream. Is this a new branch?');
52+
return;
53+
}
54+
55+
console.log(chalk.yellow('⚠ Warning'), err.message);
6156
}))
57+
.catch(err => {
58+
throw new Error(err);
59+
}))
6260
.catch(() => {
6361
console.log('not under git');
6462
});
@@ -67,21 +65,19 @@ module.exports = yargs
6765
.command({
6866
command: 'update',
6967
desc: 'run `npm update` if package.json has changed',
70-
handler: () => {
71-
return run('git diff-tree -r --name-only --no-commit-id ORIG_HEAD HEAD')
72-
.then(({ stdout }) => {
73-
if (stdout.match('package.json')) {
74-
console.log(chalk.yellow('▼ Updating...'));
75-
exec('npm update').stdout.pipe(process.stdout);
76-
}
77-
else {
78-
console.log(chalk.green('✔ Nothing to update'));
79-
}
80-
})
81-
.catch(err => {
82-
throw new Error(err);
83-
});
84-
},
68+
handler: () => run('git diff-tree -r --name-only --no-commit-id ORIG_HEAD HEAD')
69+
.then(({ stdout }) => {
70+
if (stdout.match('package.json')) {
71+
console.log(chalk.yellow('▼ Updating...'));
72+
exec('npm update').stdout.pipe(process.stdout);
73+
}
74+
else {
75+
console.log(chalk.green('✔ Nothing to update'));
76+
}
77+
})
78+
.catch(err => {
79+
throw new Error(err);
80+
}),
8581
})
8682
.demandCommand()
8783
.help()

test/__setup__/index.js

+5-26
Original file line numberDiff line numberDiff line change
@@ -3,34 +3,13 @@ import Adapter from 'enzyme-adapter-react-16';
33

44
Enzyme.configure({ adapter: new Adapter() });
55

6-
Object.defineProperty(window.location, 'href', {
7-
writable: true,
8-
value: 'http://localhost:3000/',
9-
});
10-
11-
Object.defineProperty(window.location, 'pathname', {
12-
writable: true,
13-
value: '/',
14-
});
15-
16-
Object.defineProperty(window.location, 'search', {
17-
writable: true,
18-
value: '',
19-
});
20-
21-
Object.defineProperty(window, 'pageYOffset', {
22-
writable: true,
23-
value: '',
24-
});
25-
266
const react = document.createElement('div');
277
react.id = 'react';
288
react.style.height = '100vh';
299
document.body.appendChild(react);
3010

31-
window.matchMedia = () =>
32-
({
33-
matches: false,
34-
addListener: () => {},
35-
removeListener: () => {},
36-
});
11+
window.matchMedia = () => ({
12+
matches: false,
13+
addListener: () => {},
14+
removeListener: () => {},
15+
});

test/component.spec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ describe('ReactCreditCards', () => {
326326

327327
it('should handle empty expiry props', () => {
328328
wrapper.setProps({
329-
expiry: undefined,
329+
expiry: '',
330330
focused: 'expiry',
331331
});
332332

0 commit comments

Comments
 (0)