Skip to content

Commit

Permalink
chore: Use transient file support instead of mock-fs.
Browse files Browse the repository at this point in the history
  • Loading branch information
chriseppstein committed Dec 4, 2018
1 parent e0418cf commit fe07de6
Show file tree
Hide file tree
Showing 14 changed files with 26 additions and 36 deletions.
1 change: 1 addition & 0 deletions packages/@css-blocks/jsx/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
"@css-blocks/runtime": "^0.18.0"
},
"dependencies": {
"@css-blocks/build": "^0.20.0-beta.4",
"@css-blocks/core": "^0.20.0-beta.4",
"@opticss/template-api": "^0.4.0",
"@opticss/util": "^0.4.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import mock from "@css-blocks/build/dist/src/testing/transient-fs";
import { assert } from "chai";
import { suite, test } from "mocha-typescript";

import { CSSBlocksJSXAnalyzer as Analyzer } from "../../src/Analyzer";
import { testParse as parse } from "../util";

const mock = require("mock-fs");

@suite("Analyzer | External Objstr Class States")
export class Test {
after() {
Expand Down
4 changes: 2 additions & 2 deletions packages/@css-blocks/jsx/test/analyzer/dynamic-styles-test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import mock from "@css-blocks/build/dist/src/testing/transient-fs";

import { assert } from "chai";
import { suite, test } from "mocha-typescript";

import { CSSBlocksJSXAnalyzer as Analyzer } from "../../src/Analyzer";
import { testParse as parse } from "../util";

const mock = require("mock-fs");

@suite("Analyzer | Dynamic Styles")
export class Test {
after() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import mock from "@css-blocks/build/dist/src/testing/transient-fs";

import { assert } from "chai";
import { suite, test } from "mocha-typescript";

import { CSSBlocksJSXAnalyzer as Analyzer } from "../../src/Analyzer";
import { testParse as parse } from "../util";

const mock = require("mock-fs");

@suite("Analyzer | External Objstr Class Styles")
export class Test {
after() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import mock from "@css-blocks/build/dist/src/testing/transient-fs";
import { assert } from "chai";
import { suite, test } from "mocha-typescript";

import { CSSBlocksJSXAnalyzer as Analyzer } from "../../src/Analyzer";
import { testParse as parse } from "../util";

const mock = require("mock-fs");

@suite("Analyzer | External Objstr Root Styles")
export class Test {
after() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import mock from "@css-blocks/build/dist/src/testing/transient-fs";
import { assert } from "chai";
import { suite, test } from "mocha-typescript";

import { CSSBlocksJSXAnalyzer as Analyzer } from "../../src/Analyzer";
import { testParse as parse } from "../util";

const mock = require("mock-fs");

@suite("Analyzer | Inline Class Styles")
export class Test {
after() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import mock from "@css-blocks/build/dist/src/testing/transient-fs";
import { assert } from "chai";
import { suite, test } from "mocha-typescript";

import { CSSBlocksJSXAnalyzer as Analyzer } from "../../src/Analyzer";
import { testParse as parse } from "../util";

const mock = require("mock-fs");

@suite("Analyzer | Inline Objstr Styles")
export class Test {
after() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import mock from "@css-blocks/build/dist/src/testing/transient-fs";
import { assert } from "chai";
import { suite, test } from "mocha-typescript";

import { CSSBlocksJSXAnalyzer as Analyzer } from "../../src/Analyzer";
import { testParse as parse } from "../util";

const mock = require("mock-fs");

@suite("Analyzer | Inline Root Styles")
export class Test {
after() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import mock from "@css-blocks/build/dist/src/testing/transient-fs";
import { assert } from "chai";
import { suite, test } from "mocha-typescript";

import { CSSBlocksJSXAnalyzer as Analyzer } from "../../src/Analyzer";
import { testParse as parse } from "../util";

const mock = require("mock-fs");

@suite("Analyzer | External Objstr Root States")
export class Test {
after() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import mock from "@css-blocks/build/dist/src/testing/transient-fs";
import { assert } from "chai";
import { skip, suite, test } from "mocha-typescript";

import { CSSBlocksJSXAnalyzer as Analyzer } from "../../src/Analyzer";
import { testParse as parse } from "../util";

const mock = require("mock-fs");

// This suite is skipped because we don't currently support state attributes because jsx parser doesn't support it
// and we don't want to use a fork.
@suite("Analyzer | State Attributes")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import mock from "@css-blocks/build/dist/src/testing/transient-fs";
import { assert } from "chai";
import { skip, suite, test } from "mocha-typescript";

import { CSSBlocksJSXAnalyzer as Analyzer } from "../../src/Analyzer";
import { testParse as parse } from "../util";

const mock = require("mock-fs");

@suite("Analyzer | Is able to parse typed files")
export class Test {
after() {
Expand Down
3 changes: 1 addition & 2 deletions packages/@css-blocks/jsx/test/blockImporter-test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import mock from "@css-blocks/build/dist/src/testing/transient-fs";
import { Block } from "@css-blocks/core";
import { assert } from "chai";
import { suite, test } from "mocha-typescript";
Expand All @@ -6,8 +7,6 @@ import { CSSBlocksJSXAnalyzer as Analyzer } from "../src/Analyzer";

import { testParse as parse } from "./util";

const mock = require("mock-fs");

@suite("Block Importer")
export class Test {
after() {
Expand Down
17 changes: 9 additions & 8 deletions packages/@css-blocks/jsx/test/parser-test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import mock from "@css-blocks/build/dist/src/testing/transient-fs";
import { assert } from "chai";
import { suite, test } from "mocha-typescript";

import { testParse as parse, testParseFile as parseFile } from "./util";

const mock = require("mock-fs");

@suite("Parser Test")
export class Test {
after() {
Expand Down Expand Up @@ -38,13 +37,15 @@ export class Test {

@test "parser takes an optional options hash with baseDir"() {
mock({
"/foo/baz/bar.js": `class Foo {
method(){
1;
}
}`,
"foo": {
"bar.js": `class Foo {
method(){
1;
}
}`,
},
});
return parseFile("bar.js", { baseDir: "/foo/baz"}).then((analysis) => {
return parseFile("bar.js", { baseDir: "foo"}).then((analysis) => {
assert.ok(analysis);
});
}
Expand Down
9 changes: 3 additions & 6 deletions packages/@css-blocks/jsx/test/transformer/transformer-test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import mock from "@css-blocks/build/dist/src/testing/transient-fs";
import { Analysis, BlockCompiler, Options as CSSBlocksOptions, StyleMapping, resolveConfiguration as resolveBlocksConfiguration } from "@css-blocks/core";
import c$$ from "@css-blocks/runtime";
import { TemplateIntegrationOptions } from "@opticss/template-api";

import { Analysis } from "@css-blocks/core";
import { BlockCompiler, Options as CSSBlocksOptions, StyleMapping, resolveConfiguration as resolveBlocksConfiguration } from "@css-blocks/core";

import * as babel from "babel-core";
import { assert } from "chai";
import { skip, suite, test } from "mocha-typescript";
Expand All @@ -17,8 +16,6 @@ import { CSSBlocksJSXAnalyzer as Analyzer } from "../../src/Analyzer";
import { babelPlugin } from "../../src/transformer/babel";
import { testParse as parse } from "../util";

const mock = require("mock-fs");

// Reduce whitespace.
function minify(s: string) {
mock.restore();
Expand Down Expand Up @@ -376,8 +373,8 @@ export class Test {

return transform(code, analysis.getAnalysis(0)).then(res => {
assert.equal(minify(res.jsx.code!), minify(`
<div className="a"></div>;
<div className="b"></div>;
<div className="a"></div>;
`));
});
});
Expand Down

0 comments on commit fe07de6

Please sign in to comment.