forked from a64f7bb4-7358-4778-9fbe-3b882c34cc1d/v1
28 lines
983 B
JavaScript
28 lines
983 B
JavaScript
const postcss = require('postcss')
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
|
|
const plugin = require('./')
|
|
|
|
async function run (input, contains, opts = { }) {
|
|
await postcss([plugin(opts).generate]).process(input, { from: undefined })
|
|
const data = JSON.parse(fs.readFileSync(opts.targetPath, 'utf8') );
|
|
contains.forEach((item)=>{
|
|
expect(data.includes(item)).toEqual(true)
|
|
})
|
|
|
|
}
|
|
it('Check simple classes.', async () => {
|
|
const targetPath = path.join(__dirname, 'export.json');
|
|
await run('.parent{ } .glb-selector { } ', ['glb-selector'], { targetPath })
|
|
});
|
|
|
|
it('Check sub selectors.', async () => {
|
|
const targetPath = path.join(__dirname, 'export.json');
|
|
await run('.parent .glb-selector { } ', ['glb-selector'], { targetPath })
|
|
});
|
|
it('Check not selectors.', async () => {
|
|
const targetPath = path.join(__dirname, 'export.json');
|
|
await run('.glb-not-selector:not(.glb-not-inner) {}', ['glb-not-selector', 'glb-not-inner'], { targetPath })
|
|
});
|