UNPKG

bit-bin

Version:

<a href="https://opensource.org/licenses/Apache-2.0"><img alt="apache" src="https://img.shields.io/badge/License-Apache%202.0-blue.svg"></a> <a href="https://github.com/teambit/bit/blob/master/CONTRIBUTING.md"><img alt="prs" src="https://img.shields.io/b

103 lines (84 loc) 3.66 kB
"use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); function _assert() { const data = _interopRequireDefault(require("assert")); _assert = function () { return data; }; return data; } function _() { const data = _interopRequireDefault(require("./")); _ = function () { return data; }; return data; } describe('detective-css', function () { function test(src, deps, opts) { // @ts-ignore _assert().default.deepEqual((0, _().default)(src, opts), deps); } describe('throws', function () { it('does not throw for empty files', function () { _assert().default.doesNotThrow(function () { (0, _().default)(''); }); }); it('throws if the given content is not a string', function () { _assert().default.throws(function () { (0, _().default)(function () {}); }); }); it('throws if called with no arguments', function () { _assert().default.throws(function () { // @ts-ignore (0, _().default)(); }); }); it.skip('throws on broken syntax', function () { _assert().default.throws(function () { (0, _().default)('@'); }); }); }); it('dangles the parsed AST', function () { (0, _().default)('@import "_foo.css";'); // @ts-ignore _assert().default.ok(_().default.ast); }); describe('css', function () { it('returns the dependencies of the given .css file content', function () { // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX! test('@import "_foo.css";', ['_foo.css']); // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX! test('@import "_foo.css";', ['_foo.css']); // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX! test('@import "_foo";', ['_foo']); // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX! test('body { color: blue; } @import "_foo";', ['_foo']); // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX! test('@import "bar";', ['bar']); // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX! test('@import "bar"; @import "foo";', ['bar', 'foo']); // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX! test("@import 'bar';", ['bar']); // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX! test("@import 'bar.css';", ['bar.css']); // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX! test('@import "_foo.css";\n@import "_bar.css";', ['_foo.css', '_bar.css']); // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX! test('@import "_foo.css";\n@import "_bar.css";\n@import "_baz";\n@import "_buttons";', ['_foo.css', '_bar.css', '_baz', '_buttons']); }); it('handles simple import', function () { // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX! test('@import "_foo.css"', ['_foo.css']); }); it('handles comma-separated imports (#2)', function () { // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX! test('@import "_foo.css", "bar";', ['_foo.css', 'bar']); }); it('allows imports with no semicolon', function () { // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX! test('@import "_foo.css"\n@import "_bar.css"', ['_foo.css', '_bar.css']); }); it('not allow https and http', function () { // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX! test('@import url("https://fonts.googleapis.com/css?family=Lato:100,300,400,700,900");"', []); }); it('not allow ftp', function () { // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX! test('@import url("ftp://fonts.googleapis.com/css?family=Lato:100,300,400,700,900");"', []); }); }); });