Skip to content

Commit 6b891b7

Browse files
committed
fixed tests
1 parent c429f3f commit 6b891b7

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

test/test.ts

+9-8
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,29 @@ import * as expect from 'expect.js';
44

55
process.chdir(__dirname);
66

7-
let cross = path.resolve(__dirname, '../source/index.js');
7+
const cross = path.resolve(__dirname, '../source/index.js');
8+
const { platform } = process
89

910
describe('Loader', () => {
1011

1112
it('should fail if it\'s invoked with an invalid script', () => {
1213

1314
const stdout = execSync(`node ${cross} invalid`)
14-
expect(stdout.toString()).to.match(/script: 'invalid' not found\./)
15+
expect(stdout.toString()).to.match(new RegExp(`script: 'invalid' not found for the current platform: ${platform}`))
1516

1617
})
1718

1819
it('should run the correct script on the right OS', () => {
1920

2021
const stdout = execSync(`node ${cross} first`)
21-
expect(stdout.toString()).to.match(new RegExp(`hello from ${process.platform}`))
22+
expect(stdout.toString()).to.match(new RegExp(`hello from ${platform}`))
2223

2324
})
2425

2526
it('should fail silently if script for an specific OS is not found', () => {
2627

2728
const stdout = execSync(`node ${cross} second`)
28-
expect(stdout.toString()).to.be.empty();
29+
expect(stdout.toString().trim()).to.match(new RegExp(`script: 'second' not found for the current platform: ${platform}`));
2930

3031
})
3132

@@ -58,7 +59,7 @@ describe('Loader', () => {
5859
})
5960

6061
child.on('exit', code => {
61-
expect(output.trim()).to.match(new RegExp(`hello from ${process.platform}`))
62+
expect(output.trim()).to.match(new RegExp(`hello from ${platform}`))
6263
expect(code).to.be(0)
6364
done()
6465
})
@@ -68,7 +69,7 @@ describe('Loader', () => {
6869
it('should run scripts defined in cross-os attributes', () => {
6970

7071
const stdout = execSync(`node ${cross} fifth`)
71-
expect(stdout.toString()).to.match(new RegExp(`hello from cross-os ${process.platform}`))
72+
expect(stdout.toString()).to.match(new RegExp(`hello from cross-os ${platform}`))
7273

7374
})
7475

@@ -83,7 +84,7 @@ describe('Loader', () => {
8384
})
8485

8586
child.on('exit', code => {
86-
expect(output.trim()).to.match(new RegExp(`hello from cross-os ${process.platform}`))
87+
expect(output.trim()).to.match(new RegExp(`hello from cross-os ${platform}`))
8788
expect(code).to.be(0)
8889
done()
8990
})
@@ -101,7 +102,7 @@ describe('Loader', () => {
101102
})
102103

103104
child.on('exit', code => {
104-
expect(output.trim()).to.match(new RegExp(`hello from ${process.platform}`))
105+
expect(output.trim()).to.match(new RegExp(`hello from ${platform}`))
105106
expect(code).to.be(0)
106107
done()
107108
})

0 commit comments

Comments
 (0)