Skip to content

Commit

Permalink
Adding js test
Browse files Browse the repository at this point in the history
  • Loading branch information
MiguelFrias97 committed Apr 30, 2024
1 parent 19a28da commit b74b4b0
Show file tree
Hide file tree
Showing 9 changed files with 4,165 additions and 15 deletions.
2 changes: 1 addition & 1 deletion app/components/bali/chart/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export class ChartController extends Controller {
this.displayPercentInTooltip(options)
}

Chart.register(...registerables);
Chart.register(...registerables)

this.chart = new Chart(element.getContext('2d'), {
type: this.typeValue,
Expand Down
10 changes: 10 additions & 0 deletions babel.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"presets": [
[
"@babel/preset-env"
]
],
"plugins": [
"@babel/plugin-proposal-class-properties"
]
}
2 changes: 1 addition & 1 deletion cypress.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ module.exports = defineConfig({
},
baseUrl: 'http://localhost:3000/rails/view_components'
}
})
})
2 changes: 1 addition & 1 deletion cypress/e2e/formatters.cy.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { toInt, toFloat } from '../../app/javascript/bali/utils/formatters'
import { toInt, toFloat } from '../../app/assets/javascripts/bali/utils/formatters'

describe('toInt', () => {
it('converts an empty string to 0', () => {
Expand Down
39 changes: 39 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"name": "bali-view-components",
"version": "0.76.0",
"description": "Bali ViewComponents",
"repository": "[email protected]:Grupo-AFAL/bali.git",
"author": "Federico Gonzalez <[email protected]>",
"license": "MIT",
"private": false,
"scripts": {
"cy:open": "cypress open",
"cy:run": "cypress run"
},
"devDependencies": {
"@babel/core": "^7.17.10",
"@babel/eslint-parser": "^7.17.0",
"@babel/plugin-proposal-class-properties": "^7.16.7",
"@babel/preset-env": "^7.17.10",
"cypress": "^13.6.4",
"standard": "^17.0.0"
},
"standard": {
"parser": "@babel/eslint-parser",
"globals": [
"cy",
"it",
"context",
"describe",
"expect",
"beforeEach",
"Cypress",
"fetch",
"history",
"FormData",
"CustomEvent",
"localStorage",
"DataTransfer"
]
}
}
13 changes: 6 additions & 7 deletions spec/dummy/app/javascript/application.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
// Configure your import map in config/importmap.rb. Read more: https://github.com/rails/importmap-rails

import { application } from "controllers/application"
import { application } from 'controllers/application'
import { Turbo } from '@hotwired/turbo-rails'
import * as ActiveStorage from "@rails/activestorage"
import * as ActionCable from '@rails/actioncable'
import * as ActiveStorage from '@rails/activestorage'
import 'controllers'

ActiveStorage.start()

window.Turbo = Turbo

import { AutoPlayAudioController } from 'bali/auto-play-audio-controller'
import { AutocompleteAddressController } from 'bali/autocomplete-address-controller'
import { CheckboxToggleController } from 'bali/checkbox-toggle-controller'
Expand Down Expand Up @@ -60,6 +55,10 @@ import { FilterFormController } from 'bali/filters/filter-form'
import { PopupController } from 'bali/filters/popup'
import { SelectedController } from 'bali/filters/selected'

ActiveStorage.start()

window.Turbo = Turbo

application.register('avatar', AvatarController)
application.register('bulk-actions', BulkActionsController)
application.register('carousel', CarouselController)
Expand Down
4 changes: 2 additions & 2 deletions spec/dummy/app/javascript/controllers/application.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Application } from "@hotwired/stimulus"
import { Application } from '@hotwired/stimulus'

const application = Application.start()

// Configure Stimulus development experience
application.debug = false
window.Stimulus = application
window.Stimulus = application

export { application }
6 changes: 3 additions & 3 deletions spec/dummy/app/javascript/controllers/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// Import and register all your controllers from the importmap under controllers/*

import { application } from "controllers/application"
import { application } from 'controllers/application'

// Eager load all controllers defined in the import map under controllers/**/*_controller
import { eagerLoadControllersFrom } from "@hotwired/stimulus-loading"
eagerLoadControllersFrom("controllers", application)
import { eagerLoadControllersFrom } from '@hotwired/stimulus-loading'
eagerLoadControllersFrom('controllers', application)

// Lazy load controllers as they appear in the DOM (remember not to preload controllers in import map!)
// import { lazyLoadControllersFrom } from "@hotwired/stimulus-loading"
Expand Down
Loading

0 comments on commit b74b4b0

Please sign in to comment.