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

93 lines (73 loc) 3.27 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-scss', 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.scss";'); // @ts-ignore _assert().default.ok(_().default.ast); }); describe('scss', function () { it('returns the dependencies of the given .scss file content', function () { // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX! test('@import "_foo.scss";', ['_foo.scss']); // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX! test('@import "_foo.scss";', ['_foo.scss']); // @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.scss';", ['bar.scss']); // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX! test('@import "_foo.scss";\n@import "_bar.scss";', ['_foo.scss', '_bar.scss']); // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX! test('@import "_foo.scss";\n@import "_bar.scss";\n@import "_baz";\n@import "_buttons";', ['_foo.scss', '_bar.scss', '_baz', '_buttons']); // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX! test('@import "_nested.scss"; body { color: blue; a { text-decoration: underline; }}', ['_nested.scss']); }); it('handles comma-separated imports (#2)', function () { // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX! test('@import "_foo.scss", "bar";', ['_foo.scss', 'bar']); }); it('allows imports with no semicolon', function () { // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX! test('@import "_foo.scss"\n@import "_bar.scss"', ['_foo.scss', '_bar.scss']); }); }); });