Skip to content

Commit

Permalink
refactor/add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
eGavr committed Mar 29, 2016
1 parent e6c9404 commit 168c096
Showing 1 changed file with 79 additions and 15 deletions.
94 changes: 79 additions & 15 deletions test/lib/tests-reader.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,35 +42,64 @@ describe('tests-reader', function() {
it('should assign specified browsers to specified test files in specs', function() {
pathUtils.expandPaths
.withArgs(['test1']).returns(q(['/test1']))
.withArgs(['test2']).returns(q(['/test2']));
.withArgs(['dir']).returns(q(['/dir/test2', '/dir/test3']));

var params = {
config: {
specs: [
{files: ['test1'], browsers: ['browser1']},
{files: ['test2'], browsers: ['browser2']}
{files: ['dir'], browsers: ['browser2']}
],
browsers: ['browser1', 'browser2']
}
};

return assert.becomes(readTests_(params), {browser1: ['/test1'], browser2: ['/test2']});
return assert.becomes(readTests_(params), {
browser1: ['/test1'],
browser2: ['/dir/test2', '/dir/test3']
});
});

it('should support intersection of test files in specs', function() {
pathUtils.expandPaths.withArgs(['test']).returns(q(['/test']));
it('should support intersection of test paths in specs', function() {
pathUtils.expandPaths
.withArgs(['dir', 'dir1']).returns(q(['/dir/test', '/dir1/test']))
.withArgs(['dir', 'dir2']).returns(q(['/dir/test', '/dir2/test']));

var params = {
config: {
specs: [
{files: ['test'], browsers: ['browser1']},
{files: ['test'], browsers: ['browser2']}
{files: ['dir', 'dir1'], browsers: ['browser1']},
{files: ['dir', 'dir2'], browsers: ['browser2']}
],
browsers: ['browser1', 'browser2']
}
};

return assert.becomes(readTests_(params), {browser1: ['/test'], browser2: ['/test']});
return assert.becomes(readTests_(params), {
browser1: ['/dir/test', '/dir1/test'],
browser2: ['/dir/test', '/dir2/test']
});
});

it('should support intersection of subpaths in specs', function() {
pathUtils.expandPaths
.withArgs(['dir']).returns(q(['/dir/sub-dir/test']))
.withArgs(['dir/sub-dir']).returns(q(['/dir/sub-dir/test']));

var params = {
config: {
specs: [
{files: ['dir'], browsers: ['browser1']},
{files: ['dir/sub-dir'], browsers: ['browser2']}
],
browsers: ['browser1', 'browser2']
}
};

return assert.becomes(readTests_(params), {
browser1: ['/dir/sub-dir/test'],
browser2: ['/dir/sub-dir/test']
});
});

it('should support intersection of browsers in specs', function() {
Expand All @@ -81,14 +110,18 @@ describe('tests-reader', function() {
var params = {
config: {
specs: [
{files: ['test1'], browsers: ['browser']},
{files: ['test2'], browsers: ['browser']}
{files: ['test1'], browsers: ['browser', 'browser1']},
{files: ['test2'], browsers: ['browser', 'browser2']}
],
browsers: ['browser']
browsers: ['browser', 'browser1', 'browser2']
}
};

return assert.becomes(readTests_(params), {browser: ['/test1', '/test2']});
return assert.becomes(readTests_(params), {
browser: ['/test1', '/test2'],
browser1: ['/test1'],
browser2: ['/test2']
});
});

it('should assign all browsers to test files which are specified as strings in specs', function() {
Expand All @@ -103,7 +136,10 @@ describe('tests-reader', function() {
}
};

return assert.becomes(readTests_(params), {browser1: ['/test1', '/test2'], browser2: ['/test1', '/test2']});
return assert.becomes(readTests_(params), {
browser1: ['/test1', '/test2'],
browser2: ['/test1', '/test2']
});
});

it('should assign all browsers to test files which are specified as objects without `browsers` property', function() {
Expand All @@ -118,7 +154,28 @@ describe('tests-reader', function() {
}
};

return assert.becomes(readTests_(params), {browser1: ['/test1', '/test2'], browser2: ['/test1', '/test2']});
return assert.becomes(readTests_(params), {
browser1: ['/test1', '/test2'],
browser2: ['/test1', '/test2']
});
});

it('should support string and object notations in specs', function() {
pathUtils.expandPaths
.withArgs(['test1']).returns(q(['/test1']))
.withArgs(['test2']).returns(q(['/test2']));

var params = {
config: {
specs: ['test1', {files: ['test2']}],
browsers: ['browser1', 'browser2']
}
};

return assert.becomes(readTests_(params), {
browser1: ['/test1', '/test2'],
browser2: ['/test1', '/test2']
});
});

it('should not assign unknown browsers to test files', function() {
Expand All @@ -135,7 +192,14 @@ describe('tests-reader', function() {
});

it('should log warning in case of unknown browsers in specs', function() {
return readTests_({config: {specs: [{browsers: ['unknown-browser']}], browsers: ['browser']}})
var params = {
config: {
specs: [{browsers: 'unknown-browser'}],
browsers: ['browser']
}
};

return readTests_(params)
.then(function() {
assert.calledWithMatch(logger.warn, /id: unknown-browser.+browser/);
});
Expand Down

0 comments on commit 168c096

Please sign in to comment.