Skip to content

Commit

Permalink
Merge 4a93783 into 50b52f2
Browse files Browse the repository at this point in the history
  • Loading branch information
joaopaulovieira committed Aug 21, 2020
2 parents 50b52f2 + 4a93783 commit 9597f17
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 8 deletions.
6 changes: 3 additions & 3 deletions src/base/ui_container_plugin/ui_container_plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

import { extend } from '../../utils'
import UIObject from '../ui_object'
import ErrorMixin from '../error_mixin'
import { extend } from '@/utils'
import UIObject from '@/base/ui_object'
import ErrorMixin from '@/base/error_mixin'

/**
* The base class for an ui container plugin
Expand Down
57 changes: 52 additions & 5 deletions src/base/ui_container_plugin/ui_container_plugin.test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import UIContainerPlugin from './ui_container_plugin'
import ErrorMixin from '@/base/error_mixin'

describe('UI Container Plugin', function() {
describe('UI Container Plugin', () => {
describe('#constructor', () => {
test('enables', function() {
test('enables the plugin', () => {
const plugin = new UIContainerPlugin({})

expect(plugin.enabled).toBeTruthy()
Expand All @@ -22,7 +23,7 @@ describe('UI Container Plugin', function() {
})
})

test('enables', () => {
test('enables the plugin', () => {
const plugin = new UIContainerPlugin({})
const spy = jest.spyOn(plugin, 'bindEvents')
const show = jest.fn()
Expand All @@ -36,7 +37,32 @@ describe('UI Container Plugin', function() {
expect(plugin.enabled).toBeTruthy()
})

test('disables', () => {
test('can be enabled after your creation', () => {
const plugin = new UIContainerPlugin({})

plugin.disable()

expect(plugin.enabled).toBeFalsy()

plugin.enable()

expect(plugin.enabled).toBeTruthy()
})

test('ignores enable call if the plugin is already enabled', () => {
const plugin = new UIContainerPlugin({})
const spy = jest.spyOn(plugin, 'bindEvents')

expect(plugin.enabled).toBeTruthy()

plugin.enable()
plugin.enable()

expect(spy).not.toHaveBeenCalled()
expect(plugin.enabled).toBeTruthy()
})

test('disables the plugin', () => {
const plugin = new UIContainerPlugin({})
const spy = jest.spyOn(plugin, 'stopListening')
const hide = jest.fn()
Expand All @@ -49,12 +75,33 @@ describe('UI Container Plugin', function() {
expect(plugin.enabled).toBeFalsy()
})

test('destroys', () => {
test('can be disabled after your creation', () => {
const plugin = new UIContainerPlugin({})

plugin.disable()

expect(plugin.enabled).toBeFalsy()
})

test('destroys the plugin', () => {
const plugin = new UIContainerPlugin({})
const spy = jest.spyOn(plugin, 'destroy')

plugin.destroy()

expect(spy).toHaveBeenCalledTimes(1)
})

test('receives createdError method from ErrorMixin', () => {
const plugin = new UIContainerPlugin({})

expect(plugin.createError).not.toBeUndefined()
expect(plugin.createError).toEqual(ErrorMixin.createError)
})

test('can be created via extends method', () => {
const plugin = UIContainerPlugin.extend({ name: 'test_plugin' })

expect(plugin.prototype instanceof UIContainerPlugin).toBeTruthy()
})
})

0 comments on commit 9597f17

Please sign in to comment.