Skip to content

Commit 23262fb

Browse files
committed
add more tests for checking preproc. type
1 parent 5916a23 commit 23262fb

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

__tests__/index.spec.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,9 @@ describe('js-to-styles-vars-loader', () => {
126126
const [ moduleData, stylesContent ] = operator.divideContent(content);
127127
const modulePath = operator.getModulePath(moduleData);
128128
const varData = operator.getVarData(modulePath, context);
129-
const vars = operator.transformToStyleVars(varData);
129+
const vars = operator.transformToStyleVars({ type: 'less', varData });
130130

131-
expect(operator.mergeVarsToContent(content, context)).toEqual(vars + stylesContent);
131+
expect(operator.mergeVarsToContent(content, context, 'less')).toEqual(vars + stylesContent);
132132
});
133133

134134
it('gives back content as is if there is no requre', () => {
@@ -176,5 +176,13 @@ describe('js-to-styles-vars-loader', () => {
176176
operator.transformToStyleVars({ type: 'less', varData: {} });
177177
expect(operator.transformToLessVars).toHaveBeenCalled();
178178
});
179+
180+
it('throws error is type is unknown', () => {
181+
const caller = () => {
182+
operator.transformToStyleVars({ type: 'unknown' });
183+
};
184+
185+
expect(caller).toThrow();
186+
});
179187
});
180188
});

index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ const operator = {
6363
return this.transformToSassVars(varData);
6464
case 'less':
6565
return this.transformToLessVars(varData);
66+
default:
67+
throw Error(`Unknown preprocessor type: ${type}`);
6668

6769
}
6870
},

0 commit comments

Comments
 (0)