UNPKG

babel-plugin-react-ssr

Version:

Adds the ssrWaitsFor array and ssrFetchData HOC on required components automatically for react-ssr.

27 lines (22 loc) 792 B
import path from 'path'; import fs from 'fs'; import assert from 'assert'; import { transformFileSync } from 'babel-core'; import plugin from '../src'; function trim(str) { return str.replace(/^\s+|\s+$/, ''); } describe('Add a description for the plugin here', () => { const fixturesDir = path.join(__dirname, 'fixtures'); fs.readdirSync(fixturesDir).map((caseName) => { it(`should ${caseName.split('-').join(' ')}`, () => { const fixtureDir = path.join(fixturesDir, caseName); const actualPath = path.join(fixtureDir, 'actual.js'); const actual = transformFileSync(actualPath).code; const expected = fs.readFileSync( path.join(fixtureDir, 'expected.js') ).toString(); assert.equal(trim(actual), trim(expected)); }); }); });