This repository has been archived by the owner on Aug 16, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 52
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
4 changed files
with
18 additions
and
12 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
const compiler = require('../src/style-compiler') | ||
|
||
test('should rewrite scoped style', async () => { | ||
test('should rewrite scoped style', () => { | ||
const style = { | ||
code: '.foo { color: red }', | ||
descriptor: { | ||
scoped: true | ||
} | ||
} | ||
const compiled = await compiler([style], 'foo.vue', { scopeId: 'xxx', needMap: false }) | ||
const compiled = compiler([style], 'foo.vue', { scopeId: 'xxx', needMap: false }) | ||
expect(compiled[0].code.indexOf('.foo[xxx]')).toBeGreaterThan(-1) | ||
}) |
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 |
---|---|---|
@@ -1,32 +1,32 @@ | ||
const compiler = require('../src/template-compiler') | ||
|
||
test('should compile template to esModule', async () => { | ||
test('should compile template to esModule', () => { | ||
const template = { | ||
code: '<div>{{foo}}</div>\n' | ||
} | ||
const compiled = await compiler(template, 'foo.vue', { scopeId: 'xxx', isProduction: false }) | ||
const compiled = compiler(template, 'foo.vue', { scopeId: 'xxx', isProduction: false }) | ||
|
||
expect(compiled.code.indexOf('export default')).toBeGreaterThan(-1) | ||
expect(compiled.code.indexOf('render._withStripped')).toBeGreaterThan(-1) | ||
expect(compiled.code.indexOf('module.hot.accept')).toBe(-1) | ||
}) | ||
|
||
test('should compile template to node module', async () => { | ||
test('should compile template to node module', () => { | ||
const template = { | ||
code: '<div>{{foo}}</div>\n' | ||
} | ||
const compiled = await compiler(template, 'foo.vue', { scopeId: 'xxx', esModule: false, isProduction: false }) | ||
const compiled = compiler(template, 'foo.vue', { scopeId: 'xxx', esModule: false, isProduction: false }) | ||
|
||
expect(compiled.code.indexOf('export default')).toBe(-1) | ||
expect(compiled.code.indexOf('render._withStripped')).toBeGreaterThan(-1) | ||
expect(compiled.code.indexOf('module.hot.accept')).toBe(-1) | ||
}) | ||
|
||
test('should compile with HMR', async () => { | ||
test('should compile with HMR', () => { | ||
const template = { | ||
code: '<div>{{foo}}</div>\n' | ||
} | ||
const compiled = await compiler(template, 'foo.vue', { scopeId: 'xxx', isHot: true, isProduction: false }) | ||
const compiled = compiler(template, 'foo.vue', { scopeId: 'xxx', isHot: true, isProduction: false }) | ||
|
||
expect(compiled.code.indexOf('module.hot.accept')).toBeGreaterThan(-1) | ||
}) |