This repository has been archived by the owner on Jan 18, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 148
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
335 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
const config = require('./jest.config') | ||
|
||
module.exports = { | ||
...config, | ||
testMatch: ['**/*.e2e.ts'], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import { rollup, RollupOutput, RollupWarning } from 'rollup' | ||
|
||
describe('simple', () => { | ||
let result!: RollupOutput | ||
|
||
beforeAll(async () => { | ||
result = await roll('simple') | ||
}) | ||
|
||
it('should compile <template>', () => { | ||
expect(result.output[0].code).toEqual(expect.stringContaining('.render =')) | ||
}) | ||
}) | ||
|
||
describe('css-modules', () => { | ||
let result!: RollupOutput | ||
|
||
beforeAll(async () => { | ||
result = await roll('css-modules') | ||
}) | ||
|
||
it('should process <style module> blocks', () => { | ||
expect(result.output[0].code).toEqual( | ||
expect.stringContaining('cssModules["$style"] =') | ||
) | ||
expect(result.output[0].code).not.toEqual( | ||
expect.stringContaining('.red {\n color: red;\n}') | ||
) | ||
expect(result.output[0].code).toEqual(expect.stringContaining('._red_')) | ||
expect(result.output[0].code).toEqual( | ||
expect.stringContaining('{"red":"_red_') | ||
) | ||
}) | ||
|
||
it('should process <style scoped> blocks', () => { | ||
expect(result.output[0].code).toEqual( | ||
expect.stringContaining('.__scopeId = "data-v-') | ||
) | ||
expect(result.output[0].code).not.toEqual( | ||
expect.stringContaining('.green {\n color: red;\n}') | ||
) | ||
expect(result.output[0].code).toEqual( | ||
expect.stringContaining('.green[data-v-') | ||
) | ||
}) | ||
}) | ||
|
||
import Path from 'path' | ||
async function roll(name: string) { | ||
const configFile = `../examples/${name}/rollup.config.js` | ||
const configModule = require(configFile) | ||
const configs = configModule.__esModule ? configModule.default : configModule | ||
const config = Array.isArray(configs) ? configs[0] : configs | ||
|
||
config.input = Path.resolve(__dirname, Path.dirname(configFile), config.input) | ||
delete config.output | ||
|
||
config.onwarn = function (warning: RollupWarning, warn: Function) { | ||
switch (warning.code) { | ||
case 'UNUSED_EXTERNAL_IMPORT': | ||
return | ||
default: | ||
warning.message = `(${name}) ${warning.message}` | ||
warn(warning) | ||
} | ||
} | ||
|
||
const bundle = await rollup(config) | ||
|
||
return bundle.generate({ format: 'esm' }) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.