Skip to content

Commit

Permalink
mock process.platform
Browse files Browse the repository at this point in the history
  • Loading branch information
wsmd committed May 4, 2019
1 parent 26b0f55 commit 9aa1b23
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
4 changes: 4 additions & 0 deletions tests/osascript-jxa.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ import osascript from '../lib';

jest.mock('child_process');

beforeEach(() => {
Object.defineProperty(process, 'platform', { value: 'darwin' });
});

describe('osascript.jxa', () => {
it('calls osascript with correct arguments', async () => {
await osascript.jxa`test`;
Expand Down
5 changes: 4 additions & 1 deletion tests/osascript.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@ import osascript from '../lib';

jest.mock('child_process');

beforeEach(() => {
Object.defineProperty(process, 'platform', { value: 'darwin' });
});

describe('osascript', () => {
it('throws when not using macOS', () => {
const original = process.platform;
Object.defineProperty(process, 'platform', { value: 'lcars' });
expect(osascript``).rejects.toThrowError('osascript-tag requires macOS');
Object.defineProperty(process, 'platform', { value: original });
});

it('calls osascript', async () => {
Expand Down

0 comments on commit 9aa1b23

Please sign in to comment.