Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
wxsms committed Nov 2, 2021
1 parent 8d76437 commit 4b4ae64
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 1 deletion.
6 changes: 6 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion build/rollup.umd.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const baseConfig = require('./rollup.base')
const { name } = require('../package.json')

module.exports = _.merge({}, baseConfig, {
input: path.join(__dirname, '..', 'src', 'index-browser.js'),
input: path.join(__dirname, '..', 'src', 'index.browser.js'),
plugins: [uglify(), filesize()],
output: {
format: 'umd',
Expand Down
File renamed without changes.
36 changes: 36 additions & 0 deletions src/index.browser.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
describe('install', () => {
function Vue() {
// nothing
}

let cSpy, dSpy

beforeEach(() => {
Vue.component = (key) => {
// console.log(key)
}
Vue.directive = (key) => {
// console.log(key)
}
window.Vue = Vue

cSpy = jest.spyOn(Vue, 'component')
dSpy = jest.spyOn(Vue, 'directive')
})

it('should be able to auto install with prefix', () => {
window.__uiv_options = {
prefix: 'uiv',
}
require('./index.browser')
// components
expect(cSpy).toBeCalledWith('uivAlert', expect.any(Object))
expect(cSpy).toBeCalledWith('uivModal', expect.any(Object))
// directives
expect(dSpy).toBeCalledWith('uiv-tooltip', expect.any(Object))
expect(dSpy).toBeCalledWith('uiv-scrollspy', expect.any(Object))
// methods
expect(Vue.prototype.$uiv_alert).toEqual(expect.any(Function))
expect(Vue.prototype.$uiv_notify).toEqual(expect.any(Function))
})
})

0 comments on commit 4b4ae64

Please sign in to comment.