Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('should return parsed tests grouped by browser', async () => {
const groupByBrowser = sinon.stub().returns({
bro1: ['file1'],
bro2: ['file2']
});
SetsBuilder.prototype.build.resolves({groupByBrowser});
const test1 = {title: 'test1'};
const test2 = {title: 'test2'};
const test3 = {title: 'test3'};
const test4 = {title: 'test4'};
TestParser.prototype.loadFiles
.withArgs(['file1']).callsFake(function() {
this._tests = [test1, test2];
return this;
})
.withArgs(['file2']).callsFake(function() {
this._tests = [test3, test4];
return this;
});
beforeEach(() => {
sandbox.stub(utils, 'requireWithNoCache');
sandbox.stub(globExtra, 'expandPaths').returns(Promise.resolve([]));
sandbox.stub(SetsBuilder.prototype, 'useFiles').returnsThis();
sandbox.stub(SetsBuilder.prototype, 'useSets').returnsThis();
sandbox.stub(SetsBuilder.prototype, 'useBrowsers').returnsThis();
const groupByFile = () => {
return {
'/some/path/file1.js': [],
'/other/path/file2.js': []
};
};
sandbox.stub(SetsBuilder.prototype, 'build').returns(Promise.resolve({groupByFile}));
testsApi = sandbox.stub();
readTests = proxyquire('lib/test-reader', {
'./tests-api': testsApi
});
});
beforeEach(() => {
sandbox.spy(SetsBuilder, 'create');
sandbox.stub(SetsBuilder.prototype, 'useFiles').returnsThis();
sandbox.stub(SetsBuilder.prototype, 'useSets').returnsThis();
sandbox.stub(SetsBuilder.prototype, 'useBrowsers').returnsThis();
sandbox.stub(SetsBuilder.prototype, 'build').resolves({groupByBrowser: () => ({})});
sandbox.stub(TestParser, 'prepare');
sandbox.spy(TestParser, 'create');
sandbox.stub(TestParser.prototype, 'applySkip').returnsThis();
sandbox.stub(TestParser.prototype, 'applyConfigController').returnsThis();
sandbox.stub(TestParser.prototype, 'applyGrep').returnsThis();
sandbox.stub(TestParser.prototype, 'loadFiles').returnsThis();
sandbox.stub(TestParser.prototype, 'parse');
sandbox.spy(TestSkipper, 'create');
});
beforeEach(() => {
sandbox.stub(utils, 'requireWithNoCache');
sandbox.stub(globExtra, 'expandPaths').returns(Promise.resolve([]));
sandbox.stub(SetsBuilder.prototype, 'useFiles').returnsThis();
sandbox.stub(SetsBuilder.prototype, 'useSets').returnsThis();
sandbox.stub(SetsBuilder.prototype, 'useBrowsers').returnsThis();
const groupByFile = () => {
return {
'/some/path/file1.js': [],
'/other/path/file2.js': []
};
};
sandbox.stub(SetsBuilder.prototype, 'build').returns(Promise.resolve({groupByFile}));
testsApi = sandbox.stub();
readTests = proxyquire('lib/test-reader', {
'./tests-api': testsApi
});
});
.then(() => {
assert.callOrder(
createSetsBuilder,
SetsBuilder.prototype.useSets,
SetsBuilder.prototype.useFiles,
SetsBuilder.prototype.useBrowsers,
SetsBuilder.prototype.build
);
});
});