Skip to content

Commit

Permalink
Add test case for #29
Browse files Browse the repository at this point in the history
  • Loading branch information
iureffid committed Mar 10, 2017
1 parent 3a00657 commit c9cfdbe
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 0 deletions.
3 changes: 3 additions & 0 deletions test/fixtures/dependencies/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import style1 from './style1.scss';

export default style1;
3 changes: 3 additions & 0 deletions test/fixtures/dependencies/style1.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@import 'style2.scss';

body {color: red;}
3 changes: 3 additions & 0 deletions test/fixtures/dependencies/style2.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@import 'style3.scss';

body {color: white;}
1 change: 1 addition & 0 deletions test/fixtures/dependencies/style3.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
body {color:blue;}
20 changes: 20 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import test from 'ava'
import { resolve } from 'path'
import { readFileSync, writeFileSync } from 'fs'
import { removeSync } from 'fs-extra'
import { rollup } from 'rollup'
Expand Down Expand Up @@ -191,3 +192,22 @@ test('should insert CSS into head tag', t => {
new Function(code)() // eslint-disable-line
})
})

test('should flatten stylesheets dependencies in return object', t => {
return rollup({
entry: 'fixtures/dependencies/index.js',
plugins: [
sass({
options: sassOptions
})
]
}).then(bundle => {
const pathOfStyle1 = resolve('fixtures/dependencies/style1.scss')
const pathOfStyle2 = resolve('fixtures/dependencies/style2.scss')
const pathOfStyle3 = resolve('fixtures/dependencies/style3.scss')
const styleModule = bundle.modules.find(m => m.id === pathOfStyle1)

t.true(styleModule.dependencies.indexOf(pathOfStyle2) > -1)
t.true(styleModule.dependencies.indexOf(pathOfStyle3) > -1)
})
})

0 comments on commit c9cfdbe

Please sign in to comment.