Skip to content
This repository was archived by the owner on Oct 30, 2020. It is now read-only.

Commit cb18f88

Browse files
committed
add test cases for namedExport and camelCase option
1 parent b0a97b4 commit cb18f88

9 files changed

+58
-6
lines changed

package.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,13 @@
66
"scripts": {
77
"build": "babel src -d lib",
88
"prepublish": "npm run build",
9-
"pretest": "rm -f ./test/example.css.d.ts && touch ./test/example.css.d.ts",
10-
"test:run": "babel-node ./node_modules/webpack/bin/webpack --config ./test/webpack.config.babel.js && diff ./test/example.css.d.ts ./test/expected-example.css.d.ts",
9+
"pretest": "rm -f ./test/example*.css.d.ts",
10+
"test:base": "diff ./test/example.css.d.ts ./test/expected-example.css.d.ts",
11+
"test:camelcase": "diff ./test/example-camelcase.css.d.ts ./test/expected-example-camelcase.css.d.ts",
12+
"test:namedexport": "diff ./test/example-namedexport.css.d.ts ./test/expected-example-namedexport.css.d.ts",
13+
"test:camelcase-namedexport": "diff ./test/example-camelcase-namedexport.css.d.ts ./test/expected-example-camelcase-namedexport.css.d.ts",
14+
"test:steps": "npm run test:base && npm run test:camelcase && npm run test:namedexport && npm run test:camelcase-namedexport",
15+
"test:run": "babel-node ./node_modules/webpack/bin/webpack --config ./test/webpack.config.babel.js && npm run test:steps",
1116
"test": "npm run test:run > /dev/null 2>&1 && npm run test:run"
1217
},
1318
"author": "Tim Sebastian <[email protected]>",

test/entry.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,16 @@
1-
import styles from './example.css';
1+
import stylesBase from './example.css';
2+
import stylesCamelCase from './example-camelcase.css';
3+
import * as stylesNamedExport from './example-namedexport.css';
4+
import * as stylesCamelCasedNamedExport from './example-camelcase-namedexport.css';
25

3-
const foo = styles.foo;
4-
const barBaz = styles['bar-baz'];
6+
const foo = stylesBase.foo;
7+
const barBaz = stylesBase['bar-baz'];
8+
9+
const fooCamelCase = stylesCamelCase.foo;
10+
const barBazCamelCase = stylesCamelCase.barBaz;
11+
const barBazDashedCamelCase = stylesCamelCase['bar-baz'];
12+
13+
const fooNamedExport = stylesNamedExport.foo;
14+
15+
const fooCamelCaseNamedExport = stylesCamelCasedNamedExport.foo;
16+
const barBazCamelCaseNamedExport = stylesCamelCasedNamedExport.barBaz;
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.foo {
2+
color: white;
3+
}
4+
5+
.bar-baz {
6+
color: green;
7+
}

test/example-camelcase.css

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.foo {
2+
color: white;
3+
}
4+
5+
.bar-baz {
6+
color: green;
7+
}

test/example-namedexport.css

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.foo {
2+
color: white;
3+
}
4+
5+
.bar-baz {
6+
color: green;
7+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export const foo: string;
2+
export const barBaz: string;
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
export interface IExampleCamelcaseCss {
2+
'foo': string;
3+
'bar-baz': string;
4+
'barBaz': string;
5+
}
6+
declare const styles: IExampleCamelcaseCss;
7+
8+
export default styles;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const foo: string;

test/webpack.config.babel.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@ module.exports = {
77
module: {
88
loaders: [
99
{ test: /\.ts$/, loaders: ['babel', 'ts'] },
10-
{ test: /\.css$/, loader: '../src/index.js?modules' }
10+
{ test: /example.css$/, loader: '../src/index.js?modules' },
11+
{ test: /example-camelcase.css$/, loader: '../src/index.js?modules&camelCase' },
12+
{ test: /example-namedexport.css$/, loader: '../src/index.js?modules&namedExport' },
13+
{ test: /example-camelcase-namedexport.css$/, loader: '../src/index.js?modules&camelCase&namedExport' }
1114
]
1215
}
1316
};

0 commit comments

Comments
 (0)