Skip to content

Commit

Permalink
Change OffCanvas to Offcanvas
Browse files Browse the repository at this point in the history
  • Loading branch information
rohit2sharma95 authored and XhmikosR committed Mar 16, 2021
1 parent e153e5f commit 309def0
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 40 deletions.
4 changes: 2 additions & 2 deletions build/build-plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const bsPlugins = {
Collapse: path.resolve(__dirname, '../js/src/collapse.js'),
Dropdown: path.resolve(__dirname, '../js/src/dropdown.js'),
Modal: path.resolve(__dirname, '../js/src/modal.js'),
OffCanvas: path.resolve(__dirname, '../js/src/offcanvas.js'),
Offcanvas: path.resolve(__dirname, '../js/src/offcanvas.js'),
Popover: path.resolve(__dirname, '../js/src/popover.js'),
ScrollSpy: path.resolve(__dirname, '../js/src/scrollspy.js'),
Tab: path.resolve(__dirname, '../js/src/tab.js'),
Expand Down Expand Up @@ -72,7 +72,7 @@ const getConfigByPluginKey = pluginKey => {
}
}

if (pluginKey === 'Alert' || pluginKey === 'Tab' || pluginKey === 'OffCanvas') {
if (pluginKey === 'Alert' || pluginKey === 'Tab' || pluginKey === 'Offcanvas') {
return defaultPluginConfig
}

Expand Down
4 changes: 2 additions & 2 deletions js/index.esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import Carousel from './src/carousel'
import Collapse from './src/collapse'
import Dropdown from './src/dropdown'
import Modal from './src/modal'
import OffCanvas from './src/offcanvas'
import Offcanvas from './src/offcanvas'
import Popover from './src/popover'
import ScrollSpy from './src/scrollspy'
import Tab from './src/tab'
Expand All @@ -25,7 +25,7 @@ export {
Collapse,
Dropdown,
Modal,
OffCanvas,
Offcanvas,
Popover,
ScrollSpy,
Tab,
Expand Down
4 changes: 2 additions & 2 deletions js/index.umd.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import Carousel from './src/carousel'
import Collapse from './src/collapse'
import Dropdown from './src/dropdown'
import Modal from './src/modal'
import OffCanvas from './src/offcanvas'
import Offcanvas from './src/offcanvas'
import Popover from './src/popover'
import ScrollSpy from './src/scrollspy'
import Tab from './src/tab'
Expand All @@ -25,7 +25,7 @@ export default {
Collapse,
Dropdown,
Modal,
OffCanvas,
Offcanvas,
Popover,
ScrollSpy,
Tab,
Expand Down
10 changes: 5 additions & 5 deletions js/src/offcanvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ const SELECTOR_DATA_TOGGLE = '[data-bs-toggle="offcanvas"]'
* ------------------------------------------------------------------------
*/

class OffCanvas extends BaseComponent {
class Offcanvas extends BaseComponent {
constructor(element) {
super(element)

Expand Down Expand Up @@ -181,7 +181,7 @@ class OffCanvas extends BaseComponent {

static jQueryInterface(config) {
return this.each(function () {
const data = Data.get(this, DATA_KEY) || new OffCanvas(this)
const data = Data.get(this, DATA_KEY) || new Offcanvas(this)

if (typeof config === 'string') {
if (typeof data[config] === 'undefined') {
Expand Down Expand Up @@ -224,7 +224,7 @@ EventHandler.on(document, EVENT_CLICK_DATA_API, SELECTOR_DATA_TOGGLE, function (
return
}

const data = Data.get(target, DATA_KEY) || new OffCanvas(target)
const data = Data.get(target, DATA_KEY) || new Offcanvas(target)
data.toggle(this)
})

Expand All @@ -234,6 +234,6 @@ EventHandler.on(document, EVENT_CLICK_DATA_API, SELECTOR_DATA_TOGGLE, function (
* ------------------------------------------------------------------------
*/

defineJQueryPlugin(NAME, OffCanvas)
defineJQueryPlugin(NAME, Offcanvas)

export default OffCanvas
export default Offcanvas
58 changes: 29 additions & 29 deletions js/tests/unit/offcanvas.spec.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import OffCanvas from '../../src/offcanvas'
import Offcanvas from '../../src/offcanvas'
import EventHandler from '../../src/dom/event-handler'

/** Test helpers */
import { clearFixture, getFixture, jQueryMock, createEvent } from '../helpers/fixture'

describe('OffCanvas', () => {
describe('Offcanvas', () => {
let fixtureEl

beforeAll(() => {
Expand All @@ -18,7 +18,7 @@ describe('OffCanvas', () => {

describe('VERSION', () => {
it('should return plugin version', () => {
expect(OffCanvas.VERSION).toEqual(jasmine.any(String))
expect(Offcanvas.VERSION).toEqual(jasmine.any(String))
})
})

Expand All @@ -32,7 +32,7 @@ describe('OffCanvas', () => {

const offCanvasEl = fixtureEl.querySelector('.offcanvas')
const closeEl = fixtureEl.querySelector('a')
const offCanvas = new OffCanvas(offCanvasEl)
const offCanvas = new Offcanvas(offCanvasEl)

spyOn(offCanvas, 'hide')

Expand All @@ -45,7 +45,7 @@ describe('OffCanvas', () => {
fixtureEl.innerHTML = '<div class="offcanvas"></div>'

const offCanvasEl = fixtureEl.querySelector('.offcanvas')
const offCanvas = new OffCanvas(offCanvasEl)
const offCanvas = new Offcanvas(offCanvasEl)
const keyDownEsc = createEvent('keydown')
keyDownEsc.key = 'Escape'

Expand All @@ -60,7 +60,7 @@ describe('OffCanvas', () => {
fixtureEl.innerHTML = '<div class="offcanvas"></div>'

const offCanvasEl = fixtureEl.querySelector('.offcanvas')
const offCanvas = new OffCanvas(offCanvasEl)
const offCanvas = new Offcanvas(offCanvasEl)
const keydownTab = createEvent('keydown')
keydownTab.key = 'Tab'

Expand All @@ -77,7 +77,7 @@ describe('OffCanvas', () => {
fixtureEl.innerHTML = '<div class="offcanvas"></div>'

const offCanvasEl = fixtureEl.querySelector('.offcanvas')
const offCanvas = new OffCanvas(offCanvasEl)
const offCanvas = new Offcanvas(offCanvasEl)

spyOn(offCanvas, 'show')

Expand All @@ -90,7 +90,7 @@ describe('OffCanvas', () => {
fixtureEl.innerHTML = '<div class="offcanvas show"></div>'

const offCanvasEl = fixtureEl.querySelector('.show')
const offCanvas = new OffCanvas(offCanvasEl)
const offCanvas = new Offcanvas(offCanvasEl)

spyOn(offCanvas, 'hide')

Expand All @@ -107,7 +107,7 @@ describe('OffCanvas', () => {
spyOn(EventHandler, 'trigger')

const offCanvasEl = fixtureEl.querySelector('div')
const offCanvas = new OffCanvas(offCanvasEl)
const offCanvas = new Offcanvas(offCanvasEl)

offCanvas.show()

Expand All @@ -118,7 +118,7 @@ describe('OffCanvas', () => {
fixtureEl.innerHTML = '<div class="offcanvas"></div>'

const offCanvasEl = fixtureEl.querySelector('div')
const offCanvas = new OffCanvas(offCanvasEl)
const offCanvas = new Offcanvas(offCanvasEl)

offCanvasEl.addEventListener('shown.bs.offcanvas', () => {
expect(offCanvasEl.classList.contains('show')).toEqual(true)
Expand All @@ -132,7 +132,7 @@ describe('OffCanvas', () => {
fixtureEl.innerHTML = '<div class="offcanvas"></div>'

const offCanvasEl = fixtureEl.querySelector('div')
const offCanvas = new OffCanvas(offCanvasEl)
const offCanvas = new Offcanvas(offCanvasEl)

const expectEnd = () => {
setTimeout(() => {
Expand Down Expand Up @@ -161,7 +161,7 @@ describe('OffCanvas', () => {
spyOn(EventHandler, 'trigger')

const offCanvasEl = fixtureEl.querySelector('div')
const offCanvas = new OffCanvas(offCanvasEl)
const offCanvas = new Offcanvas(offCanvasEl)

offCanvas.hide()

Expand All @@ -172,7 +172,7 @@ describe('OffCanvas', () => {
fixtureEl.innerHTML = '<div class="offcanvas show"></div>'

const offCanvasEl = fixtureEl.querySelector('div')
const offCanvas = new OffCanvas(offCanvasEl)
const offCanvas = new Offcanvas(offCanvasEl)

offCanvasEl.addEventListener('hidden.bs.offcanvas', () => {
expect(offCanvasEl.classList.contains('show')).toEqual(false)
Expand All @@ -186,7 +186,7 @@ describe('OffCanvas', () => {
fixtureEl.innerHTML = '<div class="offcanvas show"></div>'

const offCanvasEl = fixtureEl.querySelector('div')
const offCanvas = new OffCanvas(offCanvasEl)
const offCanvas = new Offcanvas(offCanvasEl)

const expectEnd = () => {
setTimeout(() => {
Expand Down Expand Up @@ -235,11 +235,11 @@ describe('OffCanvas', () => {

const target = fixtureEl.querySelector('a')

spyOn(OffCanvas.prototype, 'toggle')
spyOn(Offcanvas.prototype, 'toggle')

target.click()

expect(OffCanvas.prototype.toggle).not.toHaveBeenCalled()
expect(Offcanvas.prototype.toggle).not.toHaveBeenCalled()
})
})

Expand All @@ -249,26 +249,26 @@ describe('OffCanvas', () => {

const div = fixtureEl.querySelector('div')

jQueryMock.fn.offcanvas = OffCanvas.jQueryInterface
jQueryMock.fn.offcanvas = Offcanvas.jQueryInterface
jQueryMock.elements = [div]

jQueryMock.fn.offcanvas.call(jQueryMock)

expect(OffCanvas.getInstance(div)).toBeDefined()
expect(Offcanvas.getInstance(div)).toBeDefined()
})

it('should not re create an offcanvas', () => {
fixtureEl.innerHTML = '<div></div>'

const div = fixtureEl.querySelector('div')
const offCanvas = new OffCanvas(div)
const offCanvas = new Offcanvas(div)

jQueryMock.fn.offcanvas = OffCanvas.jQueryInterface
jQueryMock.fn.offcanvas = Offcanvas.jQueryInterface
jQueryMock.elements = [div]

jQueryMock.fn.offcanvas.call(jQueryMock)

expect(OffCanvas.getInstance(div)).toEqual(offCanvas)
expect(Offcanvas.getInstance(div)).toEqual(offCanvas)
})

it('should throw error on undefined method', () => {
Expand All @@ -277,7 +277,7 @@ describe('OffCanvas', () => {
const div = fixtureEl.querySelector('div')
const action = 'undefinedMethod'

jQueryMock.fn.offcanvas = OffCanvas.jQueryInterface
jQueryMock.fn.offcanvas = Offcanvas.jQueryInterface
jQueryMock.elements = [div]

try {
Expand All @@ -292,13 +292,13 @@ describe('OffCanvas', () => {

const div = fixtureEl.querySelector('div')

spyOn(OffCanvas.prototype, 'show')
spyOn(Offcanvas.prototype, 'show')

jQueryMock.fn.offcanvas = OffCanvas.jQueryInterface
jQueryMock.fn.offcanvas = Offcanvas.jQueryInterface
jQueryMock.elements = [div]

jQueryMock.fn.offcanvas.call(jQueryMock, 'show')
expect(OffCanvas.prototype.show).toHaveBeenCalled()
expect(Offcanvas.prototype.show).toHaveBeenCalled()
})
})

Expand All @@ -307,18 +307,18 @@ describe('OffCanvas', () => {
fixtureEl.innerHTML = '<div></div>'

const div = fixtureEl.querySelector('div')
const offCanvas = new OffCanvas(div)
const offCanvas = new Offcanvas(div)

expect(OffCanvas.getInstance(div)).toEqual(offCanvas)
expect(OffCanvas.getInstance(div)).toBeInstanceOf(OffCanvas)
expect(Offcanvas.getInstance(div)).toEqual(offCanvas)
expect(Offcanvas.getInstance(div)).toBeInstanceOf(Offcanvas)
})

it('should return null when there is no offcanvas instance', () => {
fixtureEl.innerHTML = '<div></div>'

const div = fixtureEl.querySelector('div')

expect(OffCanvas.getInstance(div)).toEqual(null)
expect(Offcanvas.getInstance(div)).toEqual(null)
})
})
})

0 comments on commit 309def0

Please sign in to comment.