diff --git a/test/runtime/__snapshots__/api.test.js.snap b/test/runtime/__snapshots__/api.test.js.snap index 23ba2486..3304a234 100644 --- a/test/runtime/__snapshots__/api.test.js.snap +++ b/test/runtime/__snapshots__/api.test.js.snap @@ -2,6 +2,10 @@ exports[`api should import modules 1`] = `"body { b: 2; }body { c: 3; }body { b: 2; }@media print {body { b: 2; }}@media print {body { d: 4; }}@media screen and (orientation:landscape) {body { a: 1; }}@media (orientation:landscape) {body { a: 1; }}"`; +exports[`api should import modules when module string 1`] = `".button { b: 2; }"`; + +exports[`api should import modules with dedupe 1`] = `"body { b: 1; }body { b: 2; }.button { b: 3; }"`; + exports[`api should import named modules 1`] = `"body { b: 2; }body { c: 3; }body { b: 2; }@media print {body { b: 2; }}@media print {body { d: 4; }}@media screen {body { a: 1; }}"`; exports[`api should toString a single module 1`] = `"body { a: 1; }"`; diff --git a/test/runtime/api.test.js b/test/runtime/api.test.js index ced44a64..f945c4b2 100644 --- a/test/runtime/api.test.js +++ b/test/runtime/api.test.js @@ -137,4 +137,30 @@ describe('api', () => { expect(m.toString()).toMatchSnapshot(); }); + + it('should import modules with dedupe', () => { + const m = api(); + + const m1 = [null, 'body { b: 1; }', '']; + const m2 = ['./module2', 'body { b: 2; }', '']; + const m3 = ['./module3', '.button { b: 3; }', '']; + + m.i([m1], '', true); + m.i([m2], '', true); + m.i([m3], '', true); + m.i([m3], '', true); + m.i([m3], '', true); + + expect(m.toString()).toMatchSnapshot(); + expect(m.length).toBe(3); + }); + + it('should import modules when module string', () => { + const m = api(); + + m.i('.button { b: 2; }'); + m.i(''); + + expect(m.toString()).toMatchSnapshot(); + }); });