jimdo-templateflow
Version:
jimdo template grunt workflow
61 lines (54 loc) • 2.19 kB
JavaScript
'use-strict'
var config = require('../fixtures/config.js')
var task = require('../../tasks/csslint.js')
var proxyquire = require('proxyquire')
describe('csslint task', function () {
it('does return css directory in source given in config', function () {
expect(task(config).default.src).toContain('css/**/*.css')
})
it('does return default linter options when no csslintr file given', function () {
this.task = proxyquire('../../tasks/csslint.js', {
fs: {
existsSync: function (_) { return false }
},
'../config/csslintDefault.js': function () { return { property: 'test'} }
})
expect(this.task(config).default.options).toEqual({ property: 'test'})
})
it('does return merged linter options when csslintrc file given', function () {
this.task = proxyquire('../../tasks/csslint.js', {
fs: {
existsSync: function (_) { return true },
readFileSync: function (_) { return '{}'; }
},
merge: function (_, _) { return { property: 'test', property2: 'test' } }
})
expect(this.task(config).default.options).toEqual({ property: 'test', property2: 'test' })
})
it('does pass two objects to merge function', function () {
var spy = jasmine.createSpy('spy');
this.task = proxyquire('../../tasks/csslint.js', {
fs: {
existsSync: function (_) { return true },
readFileSync: function (_) { return '{}'; }
},
merge: spy.and.returnValue({ property: 'test', property2: 'test' })
})
this.task(config)
expect(spy).toHaveBeenCalledWith(jasmine.any(Object), jasmine.any(Object))
})
it('does pass path to .csslintrc file to existSync and readFileSync function', function () {
var spy = jasmine.createSpy('spy');
var spy2 = jasmine.createSpy('spy');
this.task = proxyquire('../../tasks/csslint.js', {
fs: {
existsSync: spy.and.returnValue(true),
readFileSync: spy2.and.returnValue('{}')
},
merge: function (_, _) { return { } }
})
this.task(config)
expect(spy.calls.mostRecent().args[0]).toMatch(/(.*)\.csslintrc$/)
expect(spy2.calls.mostRecent().args[0]).toMatch(/(.*)\.csslintrc$/)
})
})