Skip to content

Commit

Permalink
Lint test/test.js.
Browse files Browse the repository at this point in the history
  • Loading branch information
XhmikosR committed Aug 8, 2019
1 parent 4c4264d commit a30d313
Showing 1 changed file with 72 additions and 72 deletions.
144 changes: 72 additions & 72 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,86 +12,86 @@ const serveStatic = require('serve-static');
const plugin = require('../');

function read(filename) {
return fs.readFileSync(path.join(__dirname, 'fixtures', 'styles', filename), 'utf8');
return fs.readFileSync(path.join(__dirname, 'fixtures', 'styles', filename), 'utf8');
}

const test = function (input, output, opts, done) {
input = read(input);
output = read(output);

opts = defaults(opts || {}, {
assetPaths: ['//localhost:3000/styles/']
});

postcss([plugin(opts)]).process(input).then(result => {
assert.equal(result.css, output);
assert.isEmpty(result.warnings());
}).then(done).catch(err => {
done(err);
});
input = read(input);
output = read(output);

opts = defaults(opts || {}, {
assetPaths: ['//localhost:3000/styles/']
});

postcss([plugin(opts)]).process(input).then(result => {
assert.equal(result.css, output);
assert.isEmpty(result.warnings());
}).then(done).catch(err => {
done(err);
});
};

function startServer(docroot) {
const serve = serveStatic(docroot);
const server = http.createServer((req, res) => {
const done = finalhandler(req, res);
serve(req, res, done);
});
server.listen(3000);

return server;
const serve = serveStatic(docroot);
const server = http.createServer((req, res) => {
const done = finalhandler(req, res);
serve(req, res, done);
});
server.listen(3000);

return server;
}

/* eslint max-len:0 */
describe('postcss-image-inliner', () => {
let server;

beforeEach(() => {
server = startServer(path.join(__dirname, 'fixtures'));
});
afterEach(done => {
server.close(done);
});

it('should skip too big images', done => {
test('big.css', 'big.css', {maxFileSize: 1}, done);
});

it('should handle multiple background images', done => {
test('multi.in.css', 'multi.out.css', {}, done);
});

it('should handle background shorthand', done => {
test('shorthand.in.css', 'shorthand.out.css', {}, done);
});

it('should handle media queries', done => {
test('media.in.css', 'media.out.css', {}, done);
});

it('should consider base64Svg option', done => {
test('b64svg.in.css', 'b64svg.out.css', {b64Svg: true, maxFileSize: 0}, done);
});

it('should do nothing on missing files in non strict mode', done => {
test('missing.in.css', 'missing.out.css', {}, done);
});

it('should handle urls used for content property', done => {
test('pseudo.in.css', 'pseudo.out.css', {}, done);
});

it('should fail on missing files in strict mode', done => {
test('missing.in.css', 'missing.out.css', {strict: true}, error => {
if (error) {
done();
} else {
done(new Error('Should fail'));
}
});
});

it('should allow globbing', done => {
test('glob.in.css', 'glob.out.css', {assetPaths: 'test/*/images/'}, done);
});
let server;

beforeEach(() => {
server = startServer(path.join(__dirname, 'fixtures'));
});
afterEach(done => {
server.close(done);
});

it('should skip too big images', done => {
test('big.css', 'big.css', {maxFileSize: 1}, done);
});

it('should handle multiple background images', done => {
test('multi.in.css', 'multi.out.css', {}, done);
});

it('should handle background shorthand', done => {
test('shorthand.in.css', 'shorthand.out.css', {}, done);
});

it('should handle media queries', done => {
test('media.in.css', 'media.out.css', {}, done);
});

it('should consider base64Svg option', done => {
test('b64svg.in.css', 'b64svg.out.css', {b64Svg: true, maxFileSize: 0}, done);
});

it('should do nothing on missing files in non strict mode', done => {
test('missing.in.css', 'missing.out.css', {}, done);
});

it('should handle urls used for content property', done => {
test('pseudo.in.css', 'pseudo.out.css', {}, done);
});

it('should fail on missing files in strict mode', done => {
test('missing.in.css', 'missing.out.css', {strict: true}, error => {
if (error) {
done();
} else {
done(new Error('Should fail'));
}
});
});

it('should allow globbing', done => {
test('glob.in.css', 'glob.out.css', {assetPaths: 'test/*/images/'}, done);
});
});

0 comments on commit a30d313

Please sign in to comment.