-
Notifications
You must be signed in to change notification settings - Fork 236
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make any npm module a plugin via a proxy plugin config
- Loading branch information
1 parent
7bd79e3
commit 48ca0f0
Showing
6 changed files
with
85 additions
and
3 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
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,40 @@ | ||
/* eslint-env jest */ | ||
|
||
// npm dependencies | ||
const fs = require('fs') | ||
|
||
// local dependencies | ||
const { getProxyPluginConfig } = require('./plugin-utils') | ||
|
||
const testPluginConfig = { | ||
scripts: './dist/test-script.js' | ||
} | ||
jest.mock('fs-extra', () => { | ||
return { | ||
existsSync: jest.fn().mockReturnValue(true) | ||
} | ||
}) | ||
|
||
describe('getProxyPluginConfig', () => { | ||
beforeEach(() => { | ||
jest.spyOn(fs, 'readFileSync').mockImplementation(() => { | ||
return JSON.stringify({ | ||
'test-plugin-config': testPluginConfig | ||
}) | ||
}) | ||
}) | ||
|
||
afterEach(() => { | ||
jest.restoreAllMocks() | ||
}) | ||
|
||
it('get jquery proxy plugin config', () => { | ||
const pluginConfig = getProxyPluginConfig('jquery') | ||
expect(Object.keys(pluginConfig)).toEqual(['scripts', 'assets', 'meta']) | ||
}) | ||
|
||
it('get test script proxy plugin config', () => { | ||
const pluginConfig = getProxyPluginConfig('test-plugin-config') | ||
expect(pluginConfig).toEqual(testPluginConfig) | ||
}) | ||
}) |
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