forked from postcss/postcss-import
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathimport-events.js
39 lines (36 loc) · 1.12 KB
/
import-events.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
"use strict"
// builtin tooling
const { readFileSync } = require("fs")
const { resolve } = require("path")
// external tooling
const test = require("ava")
const postcss = require("postcss")
// plugin
const atImport = require("..")
test("should add dependency message for each import", t => {
return postcss()
.use(atImport({ path: "test/fixtures/imports" }))
.process(readFileSync("test/fixtures/media-import.css"), {
from: "test/fixtures/media-import.css",
})
.then(result => {
const deps = result.messages.filter(
message => message.type === "dependency"
)
const expected = [
{
type: "dependency",
plugin: "postcss-import",
file: resolve("test/fixtures/imports/media-import-level-2.css"),
parent: resolve("test/fixtures/media-import.css"),
},
{
type: "dependency",
plugin: "postcss-import",
file: resolve("test/fixtures/imports/media-import-level-3.css"),
parent: resolve("test/fixtures/imports/media-import-level-2.css"),
},
]
t.deepEqual(deps, expected)
})
})