-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathindex-test.js
43 lines (33 loc) · 1.07 KB
/
index-test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/**
* @copyright 2016-present, React CSS Components team
* @flow
*/
import assert from 'assert';
import fs from 'fs';
import path from 'path';
import {render} from '../';
const REACT_CSS_RE = /\.react\.css$/;
declare function describe(description: string, body: any): void;
declare function it(description: string, body: any): void;
describe('react-css-components', function() {
function readFixture(filename) {
filename = path.join(__dirname, 'fixtures', filename);
return fs.readFileSync(filename, 'utf8').trim();
}
fs.readdirSync(path.join(__dirname, 'fixtures')).forEach(filename => {
if (!REACT_CSS_RE.exec(filename)) {
return;
}
let jsExpect = filename.replace(REACT_CSS_RE, '.js');
let cssExpect = filename.replace(REACT_CSS_RE, '.css');
it('renders: ' + filename, function() {
let source = readFixture(filename);
let {js, css} = render(source, {
loadCSS: 'css',
filename: filename,
});
assert.equal(js, readFixture(jsExpect));
assert.equal(css, readFixture(cssExpect));
});
});
});