Skip to content

Commit f6ba52d

Browse files
committed
chore: Updated testcases
1 parent b094707 commit f6ba52d

12 files changed

Lines changed: 2723 additions & 31 deletions

File tree

.babelrc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"presets": [
3+
["@babel/preset-env", {
4+
"targets": {
5+
"node": "current"
6+
}
7+
}],
8+
"@babel/preset-react"
9+
]
10+
}

.github/workflows/deploy.yml

Lines changed: 42 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,53 @@
1-
name: Deployment
1+
name: CI/CD Pipeline
22
on:
33
push:
44
branches:
55
- master
6+
pull_request:
7+
branches:
8+
- master
9+
610
env:
7-
CI: false
11+
CI: true
12+
813
jobs:
14+
test:
15+
runs-on: ubuntu-latest
16+
strategy:
17+
matrix:
18+
node-version: [16.x]
19+
steps:
20+
- uses: actions/checkout@v2
21+
- name: Use Node.js ${{ matrix.node-version }}
22+
uses: actions/setup-node@v1
23+
with:
24+
node-version: ${{ matrix.node-version }}
25+
cache: 'npm'
26+
- name: Install dependencies
27+
run: npm ci
28+
- name: Run tests
29+
run: npm run test:ci
30+
931
deploy:
32+
needs: test
1033
runs-on: ubuntu-latest
34+
if: github.ref == 'refs/heads/master'
1135
strategy:
1236
matrix:
13-
node-version: [12.x]
37+
node-version: [16.x]
1438
steps:
15-
- uses: actions/checkout@v2
16-
- name: Use Node.js ${{ matrix.node-version }}
17-
uses: actions/setup-node@v1
18-
with:
19-
node-version: ${{ matrix.node-version }}
20-
- name: Install Packages
21-
run: npm install
22-
- name: Build page
23-
run: npm run build
24-
- name: Deploy to gh-pages
25-
uses: peaceiris/actions-gh-pages@v3
26-
with:
27-
deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }}
28-
publish_dir: ./build
39+
- uses: actions/checkout@v2
40+
- name: Use Node.js ${{ matrix.node-version }}
41+
uses: actions/setup-node@v1
42+
with:
43+
node-version: ${{ matrix.node-version }}
44+
cache: 'npm'
45+
- name: Install Packages
46+
run: npm ci
47+
- name: Build page
48+
run: npm run build
49+
- name: Deploy to gh-pages
50+
uses: peaceiris/actions-gh-pages@v3
51+
with:
52+
deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }}
53+
publish_dir: ./build
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
const React = require('react');
2+
3+
exports.VfButton = ({ children, ...props }) => {
4+
return React.createElement('button', { 'data-testid': 'vf-button' }, 'Mock VF Button');
5+
};
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
const React = require('react');
2+
3+
exports.VfCard = ({ card_title, variant, newTheme, card_image, card_text, card_image__alt }) => {
4+
return React.createElement('div', { 'data-testid': 'vf-card' }, 'Mock VF Card');
5+
};

__mocks__/fileMock.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = 'test-file-stub';

__mocks__/styleMock.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = {};

babel.config.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module.exports = {
2+
presets: [
3+
['@babel/preset-env', {targets: {node: 'current'}}],
4+
'@babel/preset-react'
5+
]
6+
};

jest.config.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
module.exports = {
2+
testEnvironment: 'jsdom',
3+
setupFilesAfterEnv: ['<rootDir>/jest.setup.js'],
4+
transform: {
5+
'^.+\\.(js|jsx)$': 'babel-jest'
6+
},
7+
transformIgnorePatterns: [
8+
'node_modules/(?!(@visual-framework)/.*)'
9+
],
10+
moduleNameMapper: {
11+
'\\.(jpg|jpeg|png|gif|svg|eot|otf|webp|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$': '<rootDir>/__mocks__/fileMock.js',
12+
'\\.(css|less|scss|sass)$': '<rootDir>/__mocks__/styleMock.js'
13+
}
14+
};

jest.setup.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
import '@testing-library/jest-dom/extend-expect';
2+
global.window = {};

package.json

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,15 @@
1414
"predeploy": "gulp build",
1515
"deploy": "gh-pages -d build",
1616
"build": "gulp build",
17-
"test": "react-scripts test",
17+
"test": "jest --config jest.config.js",
18+
"test:ci": "jest --config jest.config.js --ci --watchAll=false",
19+
"test:watch": "jest --config jest.config.js --watch",
1820
"eject": "react-scripts eject",
19-
"update-components": "yarn upgrade-interactive --latest"
21+
"update-components": "npm update"
2022
},
2123
"dependencies": {
24+
"@testing-library/jest-dom": "^5",
25+
"@testing-library/react": "^12",
2226
"@visual-framework/embl-grid": "2.1.2",
2327
"@visual-framework/vf-banner": "1.9.0",
2428
"@visual-framework/vf-body": "1.2.0",
@@ -62,6 +66,7 @@
6266
"@visual-framework/vf-text": "1.0.2",
6367
"@visual-framework/vf-u-fullbleed": "1.2.2",
6468
"@visual-framework/vf-utility-classes": "2.0.0",
69+
"babel-jest": "27.5.1",
6570
"gh-pages": "3.2.3",
6671
"gulp": "4.0.2",
6772
"gulp-autoprefixer": "8.0.0",
@@ -76,6 +81,8 @@
7681
"gulp-stylelint": "13.0.0",
7782
"gulp-svgmin": "4.0.1",
7883
"gulp-watch": "5.0.1",
84+
"jest": "27.5.1",
85+
"jest-environment-jsdom": "27.5.1",
7986
"list-stream": "2.0.0",
8087
"react": "17.0.2",
8188
"react-dom": "17.0.2",
@@ -97,5 +104,9 @@
97104
"last 1 firefox version",
98105
"last 1 safari version"
99106
]
107+
},
108+
"devDependencies": {
109+
"@babel/preset-env": "^7.26.9",
110+
"@babel/preset-react": "^7.26.3"
100111
}
101112
}

0 commit comments

Comments
 (0)