File tree Expand file tree Collapse file tree 7 files changed +914
-9
lines changed
Expand file tree Collapse file tree 7 files changed +914
-9
lines changed Original file line number Diff line number Diff line change 5555 ruby-version : ruby-3.3.7
5656 bundler-cache : true
5757
58- - name : Run tests
58+ - name : Set up Node.js
59+ uses : actions/setup-node@v6
60+ with :
61+ node-version : ' 20'
62+ cache : ' yarn'
63+
64+ - name : Install JavaScript dependencies
65+ run : yarn install --frozen-lockfile
66+
67+ - name : Run JavaScript tests
68+ run : yarn test
69+
70+ - name : Run Rails tests
5971 env :
6072 RAILS_ENV : test
6173 # REDIS_URL: redis://localhost:6379/0
Original file line number Diff line number Diff line change 44 step "Style: Ruby" , "bin/rubocop -f github"
55 step "Style: JavaScript" , "yarn lint"
66
7- step "Tests: prepare" , "env RAILS_ENV=test bin/rails db:test:prepare"
8- step "Tests: run" , "env RAILS_ENV=test bin/rails test:all -d"
7+ step "Tests: JavaScript" , "yarn test"
8+ step "Tests: Rails (prepare)" , "env RAILS_ENV=test bin/rails db:test:prepare"
9+ step "Tests: Rails (run)" , "env RAILS_ENV=test bin/rails test:all -d"
910
1011 unless success?
1112 failure "Signoff: CI failed." , "Fix the issues and try again."
Original file line number Diff line number Diff line change 1818 "@rollup/plugin-node-resolve" : " ^16.0.1" ,
1919 "@rollup/plugin-terser" : " ^0.4.4" ,
2020 "eslint" : " ^9.15.0" ,
21+ "jsdom" : " ^27.3.0" ,
2122 "rollup" : " ^4.44.1" ,
2223 "rollup-plugin-copy" : " ^3.5.0" ,
23- "rollup-plugin-gzip" : " ^4.1.1"
24+ "rollup-plugin-gzip" : " ^4.1.1" ,
25+ "vitest" : " ^4.0.16"
2426 },
2527 "scripts" : {
2628 "build" : " rollup -c" ,
2729 "build:npm" : " rollup -c rollup.config.npm.mjs" ,
2830 "watch" : " rollup -wc --watch.onEnd=\" rails restart\" " ,
2931 "lint" : " eslint" ,
32+ "test" : " vitest --environment=jsdom" ,
3033 "prerelease" : " yarn build:npm" ,
3134 "release" : " yarn build:npm && yarn publish"
3235 },
Original file line number Diff line number Diff line change 1+ import { expect , test } from "vitest"
2+ import Configuration from "../../../src/config/configuration"
3+
4+ const config = new Configuration ( {
5+ default : { richText : true } ,
6+ } )
7+
8+ test ( "gets path" , ( ) => {
9+ expect ( config . get ( "default.richText" ) ) . toBe ( true )
10+ } )
11+
12+ test ( "returns undefined for missing option" , ( ) => {
13+ expect ( config . get ( "default.missing" ) ) . toBe ( undefined )
14+ } )
15+
16+ test ( "overwrites bool with hash" , ( ) => {
17+ const config = new Configuration (
18+ { toolbar : false } ,
19+ { toolbar : { bold : true } }
20+ )
21+ expect ( config . get ( "toolbar.bold" ) ) . toBe ( true )
22+ } )
23+
24+ test ( "ovewrites hash with bool" , ( ) => {
25+ const config = new Configuration (
26+ { toolbar : { bold : true } } ,
27+ { toolbar : false }
28+ )
29+ expect ( config . get ( "toolbar" ) ) . toBe ( false )
30+ } )
Original file line number Diff line number Diff line change 1+ import { expect , test } from "vitest"
2+ import { createElement } from "../helpers/dom_helper"
3+ import EditorConfiguration from "../../../src/editor/configuration"
4+ import { configure } from "../../../src/index"
5+
6+ configure ( {
7+ default : {
8+ richText : true ,
9+ attachments : true
10+ } ,
11+ simple : {
12+ richText : false
13+ }
14+ } )
15+
16+ test ( "uses defaults" , ( ) => {
17+ const element = createElement ( "<lexxy-editor></lexxy-editor>" )
18+ const config = new EditorConfiguration ( element )
19+ expect ( config . get ( "attachments" ) ) . toBe ( true )
20+ } )
21+
22+ test ( "uses preset" , ( ) => {
23+ const element = createElement ( "<lexxy-editor preset='simple'></lexxy-editor>" )
24+ const config = new EditorConfiguration ( element )
25+ expect ( config . get ( "richText" ) ) . toBe ( false )
26+ } )
27+
28+ test ( "preset fallbacks to default" , ( ) => {
29+ const element = createElement ( "<lexxy-editor preset='simple'></lexxy-editor>" )
30+ const config = new EditorConfiguration ( element )
31+ expect ( config . get ( "attachments" ) ) . toBe ( true )
32+ } )
33+
34+ test ( "overrides defaults" , ( ) => {
35+ const element = createElement ( "<lexxy-editor rich-text='false'></lexxy-editor>" )
36+ const config = new EditorConfiguration ( element )
37+ expect ( config . get ( "richText" ) ) . toBe ( false )
38+ } )
Original file line number Diff line number Diff line change 1+ export function createElement ( html ) {
2+ const element = document . createElement ( "div" )
3+ element . innerHTML = html
4+ return element . firstChild ;
5+ }
You can’t perform that action at this time.
0 commit comments