Skip to content

Commit 5c539fe

Browse files
committed
Simplify tests with better naming
1 parent ee63fa8 commit 5c539fe

File tree

1 file changed

+12
-15
lines changed

1 file changed

+12
-15
lines changed

test/test.js

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -163,53 +163,50 @@ describe('suitcss', function() {
163163
});
164164
});
165165

166-
describe('beforeLint option', function() {
167-
var lintImportedFilesStub, bemLintStub, beforeLintStub, revert;
166+
describe('transforming css before linting', function() {
167+
var lintImportedFilesStub, beforeLintStub, revert;
168168

169169
beforeEach(function() {
170-
lintImportedFilesStub = sinon.stub();
171-
bemLintStub = sinon.stub().returns('/* lint */');
172-
beforeLintStub = sinon.stub().returns('/* before lint */');
173-
174-
lintImportedFilesStub.onFirstCall().returns(bemLintStub);
170+
lintImportedFilesStub = sinon.stub().returns('/*linting done*/');
171+
beforeLintStub = sinon.stub().returns('/*before lint*/');
175172
revert = suitcss.__set__('lintImportedFiles', lintImportedFilesStub);
176173
});
177174

178175
afterEach(function() {
179176
revert();
180177
});
181178

182-
it('should call user supplied function before linting', function(done) {
179+
it('should call `beforeLint` function before linting', function(done) {
183180
suitcss(read('fixtures/component'), {
184181
root: 'test/fixtures',
185182
beforeLint: beforeLintStub
186183
}).catch(done);
187184

188-
expect(bemLintStub.calledOnce).to.be.ok;
189-
expect(beforeLintStub.calledOnce).to.be.ok;
190-
expect(beforeLintStub.calledBefore(bemLintStub)).to.be.ok;
185+
expect(lintImportedFilesStub.calledOnce).to.be.true;
186+
expect(beforeLintStub.calledOnce).to.be.true;
187+
expect(beforeLintStub.calledBefore(lintImportedFilesStub)).to.be.true;
191188

192189
done();
193190
});
194191

195-
it('should pass processed CSS to the linting transform function', function(done) {
192+
it('should pass the result of `beforeLint` to `lintImportedFiles`', function(done) {
196193
suitcss(read('fixtures/component'), {
197194
root: 'test/fixtures',
198195
beforeLint: beforeLintStub
199196
}).catch(done);
200197

201-
expect(bemLintStub.args[0][0]).to.equal('/* before lint */');
198+
expect(lintImportedFilesStub.args[0][1]).to.equal('/*before lint*/');
202199

203200
done();
204201
});
205202

206-
it('should pass the merged options to the beforeLint function', function(done) {
203+
it('should pass the options object to the beforeLint function as the third parameter', function(done) {
207204
suitcss(read('fixtures/component'), {
208205
root: 'test/fixtures',
209206
beforeLint: beforeLintStub
210207
}).catch(done);
211208

212-
expect(beforeLintStub.args[0][2].root).to.equal('test/fixtures');
209+
expect(beforeLintStub.args[0][2]).to.contain({root: 'test/fixtures'});
213210

214211
done();
215212
});

0 commit comments

Comments
 (0)