Skip to content

Commit

Permalink
test: Introduce tests for (some) javascript code
Browse files Browse the repository at this point in the history
This extracts some code out to `Util.ts` and tests it using jest in `Util.test.ts`.
`unochoice.js` has been renamed to `UnoChoice.es6` so we can synthesize `UnoChoice.js`.
  • Loading branch information
rahulsom committed Jun 25, 2023
1 parent be127d8 commit 7aa5787
Show file tree
Hide file tree
Showing 11 changed files with 5,051 additions and 172 deletions.
17 changes: 17 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
root = true

[*]
charset = utf-8
end_of_line = lf
indent_size = 4
indent_style = space
insert_final_newline = false
max_line_length = 160
tab_width = 4
ij_continuation_indent_size = 8
ij_formatter_off_tag = @formatter:off
ij_formatter_on_tag = @formatter:on
ij_formatter_tags_enabled = true
ij_smart_tabs = false
ij_visual_guides = none
ij_wrap_on_typing = false
23 changes: 13 additions & 10 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
work/
.idea/
target/
test-output/
.idea/
.classpath
.settings/
.project
**/*~
*.iml
work/
.idea/
target/
test-output/
.classpath
.settings/
.project
**/*~
*.iml
node/
node_modules/
src/main/resources/org/biouno/unochoice/stapler/unochoice/*.js
src/main/resources/org/biouno/unochoice/stapler/unochoice/*.js.map
66 changes: 66 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
{
"license": "MIT",
"version": "1.0.0",
"description": "Active Choices Plugin UI",
"name": "uno-choice",
"private": true,
"scripts": {
"test": "jest",
"dev": "webpack --config webpack.config.js",
"prod": "webpack --config webpack.config.js --mode=production",
"build": "yarn prod"
},
"devDependencies": {
"@babel/cli": "^7.22.5",
"@babel/core": "7.22.5",
"@babel/preset-env": "^7.22.5",
"@babel/preset-typescript": "^7.22.5",
"@babel/preset-flow": "^7.22.5",
"eslint": "8.43.0",
"eslint-config-prettier": "8.8.0",
"jest": "^29.5.0",
"jest-environment-jsdom": "^29.5.0",
"jest-junit": "^16.0.0",
"jsdom": "^22.1.0",
"prettier": "2.8.8",
"ts-loader": "^9.4.3",
"typescript": "^5.1.3",
"webpack": "5.87.0",
"webpack-cli": "5.1.4",
"jquery": "^3.7.0",
"@types/jquery": "^3.5.16"
},
"dependencies": {
},
"browserslist": [
"defaults",
"not IE 11"
],
"packageManager": "[email protected]",
"jest-junit": {
"outputDirectory": "target/surefire-reports",
"outputName": "TEST-Jest.xml",
"ancestorSeparator": "",
"classNameTemplate": "{classname}",
"titleTemplate": "{title}",
"usePathForSuiteName": "true"
},
"babel": {
"presets": [
["@babel/preset-env", {"targets": {"node": "current"}}],
"@babel/preset-typescript",
"@babel/preset-flow"
]
},
"jest": {
"verbose": true,
"testEnvironment": "jsdom",
"reporters": [
"default",
"jest-junit"
],
"testMatch": [
"<rootDir>/src/test/js/*.test.ts"
]
}
}
55 changes: 55 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
<changelist>-SNAPSHOT</changelist>
<jenkins.version>2.332.4</jenkins.version>
<gitHubRepo>jenkinsci/active-choices-plugin</gitHubRepo>
<node.version>18.16.0</node.version>
<yarn.version>1.22.19</yarn.version>
</properties>

<scm>
Expand Down Expand Up @@ -202,6 +204,59 @@
<compatibleSinceVersion>2.0</compatibleSinceVersion>
</configuration>
</plugin>

<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<version>1.12.1</version>
<executions>

<execution>
<id>install node and yarn</id>
<goals>
<goal>install-node-and-yarn</goal>
</goals>
<phase>initialize</phase>
<configuration>
<nodeVersion>v${node.version}</nodeVersion>
<yarnVersion>v${yarn.version}</yarnVersion>
<nodeDownloadRoot>https://repo.jenkins-ci.org/nodejs-dist/</nodeDownloadRoot>
<!-- tried to create a mirror for yarnDownloadRoot but it did not work -->
</configuration>
</execution>

<execution>
<id>yarn-install</id>
<goals>
<goal>yarn</goal>
</goals>
<phase>initialize</phase>
</execution>

<execution>
<id>yarn-build</id>
<goals>
<goal>yarn</goal>
</goals>
<phase>generate-resources</phase>
<configuration>
<arguments>build</arguments>
</configuration>
</execution>

<execution>
<id>yarn-test</id>
<goals>
<goal>yarn</goal>
</goals>
<phase>test</phase>
<configuration>
<arguments>test</arguments>
</configuration>
</execution>

</executions>
</plugin>
</plugins>
</build>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ Use it like <st:adjunct includes="org.biouno.unochoice.stapler.unochoice"/>
align-items: flex-start;
}
</style>
<script src="${it.packageUrl}/unochoice/unochoice.js" type="text/javascript" />
<script src="${it.packageUrl}/unochoice/UnoChoice.js" type="text/javascript" />
</j:jelly>
Loading

0 comments on commit 7aa5787

Please sign in to comment.