UNPKG

810 BJavaScriptView Raw
1var path = require('path');
2var sinon = require('sinon');
3var chai = require('chai');
4var expect = chai.expect;
5var testFramework = require('../index');
6var filters = testFramework.filters;
7var tests = [];
8
9'a b c'.split(' ').forEach(function(f) {
10 // create two tests per file
11 for (var i = 0; i < 2; i++) {
12 tests.push({filename: 'path/to/' + f + '.js'});
13 }
14});
15
16describe('single test filter', function() {
17 beforeEach(function() {
18 sinon.stub(path, 'resolve', function(path) {
19 return path;
20 });
21 });
22
23 afterEach(function() {
24 path.resolve.restore();
25 });
26
27 it('returns the tests matching the given file', function() {
28 var filtered = filters.test(tests, 'path/to/b.js');
29 expect(filtered).to.have.length(2);
30 expect(filtered[0]).to.have.property('filename').that.equals('path/to/b.js');
31 });
32});